-
Notifications
You must be signed in to change notification settings - Fork 19
/
changeTags.go
40 lines (36 loc) · 1.04 KB
/
changeTags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"github.com/Symantec/Dominator/lib/errors"
"github.com/Symantec/Dominator/lib/log"
"github.com/Symantec/Dominator/lib/srpc"
proto "github.com/Symantec/Dominator/proto/fleetmanager"
)
func changeTagsSubcommand(args []string, logger log.DebugLogger) error {
if err := changeTags(logger); err != nil {
return fmt.Errorf("Error changing Hypervisor tags: %s\n", err)
}
return nil
}
func changeTags(logger log.DebugLogger) error {
if *hypervisorHostname == "" {
return errors.New("no hypervisorHostname specified")
}
request := proto.ChangeMachineTagsRequest{
Hostname: *hypervisorHostname,
Tags: hypervisorTags,
}
var reply proto.ChangeMachineTagsResponse
clientName := fmt.Sprintf("%s:%d", *fleetManagerHostname,
*fleetManagerPortNum)
client, err := srpc.DialHTTPWithDialer("tcp", clientName, rrDialer)
if err != nil {
return err
}
defer client.Close()
err = client.RequestReply("FleetManager.ChangeMachineTags", request, &reply)
if err != nil {
return err
}
return errors.New(reply.Error)
}