Skip to content

Commit

Permalink
Merge 058065d into f0540c5
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Jun 29, 2019
2 parents f0540c5 + 058065d commit bbbac73
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/hyper-control/netbootHost.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func netbootHost(hostname string, logger log.DebugLogger) error {
hypervisorAddresses = append(hypervisorAddresses,
fmt.Sprintf("%s:%d", *hypervisorHostname, *hypervisorPortNum))
} else {
hypervisorAddresses, err = listGoodHypervisorsInLocation(fmCR,
hypervisorAddresses, err = listConnectedHypervisorsInLocation(fmCR,
info.Location)
if err != nil {
return err
Expand Down
14 changes: 9 additions & 5 deletions cmd/hyper-control/rolloutImage.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ func rolloutImage(imageName string, logger log.DebugLogger) error {
fmt.Sprintf("%s:%d", *fleetManagerHostname, *fleetManagerPortNum))
defer fleetManagerClientResource.ScheduleClose()
logger.Debugln(0, "finding good Hypervisors")
hypervisorAddresses, err := listGoodHypervisors(fleetManagerClientResource)
hypervisorAddresses, err := listConnectedHypervisors(
fleetManagerClientResource)
if err != nil {
return err
}
Expand Down Expand Up @@ -246,19 +247,22 @@ func getTagsForHypervisors(clientResource *srpc.ClientResource) (
return tagsForHypervisors, nil
}

func listGoodHypervisors(clientResource *srpc.ClientResource) (
func listConnectedHypervisors(clientResource *srpc.ClientResource) (
[]string, error) {
return listGoodHypervisorsInLocation(clientResource, *location)
return listConnectedHypervisorsInLocation(clientResource, *location)
}

func listGoodHypervisorsInLocation(clientResource *srpc.ClientResource,
func listConnectedHypervisorsInLocation(clientResource *srpc.ClientResource,
location string) ([]string, error) {
client, err := clientResource.GetHTTP(nil, 0)
if err != nil {
return nil, err
}
defer client.Put()
request := fm_proto.ListHypervisorsInLocationRequest{Location: location}
request := fm_proto.ListHypervisorsInLocationRequest{
IncludeUnhealthy: true,
Location: location,
}
var reply fm_proto.ListHypervisorsInLocationResponse
err = client.RequestReply("FleetManager.ListHypervisorsInLocation",
request, &reply)
Expand Down
12 changes: 9 additions & 3 deletions cmd/vm-control/listHypervisors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"sort"
"strings"

"github.com/Symantec/Dominator/lib/errors"
Expand All @@ -25,8 +26,9 @@ func listHypervisors(logger log.DebugLogger) error {
}
defer client.Close()
request := proto.ListHypervisorsInLocationRequest{
Location: *location,
SubnetId: *subnetId,
IncludeUnhealthy: *includeUnhealthy,
Location: *location,
SubnetId: *subnetId,
}
var reply proto.ListHypervisorsInLocationResponse
err = client.RequestReply("FleetManager.ListHypervisorsInLocation",
Expand All @@ -37,8 +39,12 @@ func listHypervisors(logger log.DebugLogger) error {
if err := errors.New(reply.Error); err != nil {
return err
}
hypervisors := make([]string, 0, len(reply.HypervisorAddresses))
for _, address := range reply.HypervisorAddresses {
hypervisor := strings.Split(address, ":")[0]
hypervisors = append(hypervisors, strings.Split(address, ":")[0])
}
sort.Strings(hypervisors)
for _, hypervisor := range hypervisors {
if _, err := fmt.Println(hypervisor); err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/vm-control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
"Hostname of hypervisor")
hypervisorPortNum = flag.Uint("hypervisorPortNum",
constants.HypervisorPortNumber, "Port number of hypervisor")
includeUnhealthy = flag.Bool("includeUnhealthy", false,
"If true, list connected but unhealthy hypervisors")
imageFile = flag.String("imageFile", "",
"Name of RAW image file to boot with")
imageName = flag.String("imageName", "", "Name of image to boot with")
Expand Down
6 changes: 5 additions & 1 deletion fleetmanager/hypervisors/listHypervisors.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ func (m *Manager) listHypervisorsHandler(w http.ResponseWriter,

func (m *Manager) listHypervisorsInLocation(
request proto.ListHypervisorsInLocationRequest) ([]string, error) {
hypervisors, err := m.listHypervisors(request.Location, showOK,
showFilter := showOK
if request.IncludeUnhealthy {
showFilter = showConnected
}
hypervisors, err := m.listHypervisors(request.Location, showFilter,
request.SubnetId)
if err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions proto/fleetmanager/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ type ListHypervisorLocationsResponse struct {
}

type ListHypervisorsInLocationRequest struct {
Location string
SubnetId string
IncludeUnhealthy bool
Location string
SubnetId string
}

type ListHypervisorsInLocationResponse struct {
Expand Down

0 comments on commit bbbac73

Please sign in to comment.