-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
517 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"os" | ||
|
||
"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 moveIpAddressSubcommand(args []string, logger log.DebugLogger) { | ||
if err := moveIpAddress(args[0], logger); err != nil { | ||
fmt.Fprintf(os.Stderr, "Error moving IP address: %s\n", err) | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
} | ||
|
||
func moveIpAddress(addr string, logger log.DebugLogger) error { | ||
ipAddr := net.ParseIP(addr) | ||
if len(ipAddr) < 4 { | ||
return fmt.Errorf("invalid IP address: %s", addr) | ||
} | ||
request := proto.MoveIpAddressesRequest{ | ||
HypervisorHostname: *hypervisorHostname, | ||
IpAddresses: []net.IP{ipAddr}, | ||
} | ||
var reply proto.MoveIpAddressesResponse | ||
clientName := fmt.Sprintf("%s:%d", | ||
*fleetManagerHostname, *fleetManagerPortNum) | ||
client, err := srpc.DialHTTP("tcp", clientName, 0) | ||
if err != nil { | ||
return err | ||
} | ||
defer client.Close() | ||
err = client.RequestReply("FleetManager.MoveIpAddresses", request, &reply) | ||
if err != nil { | ||
return err | ||
} | ||
return errors.New(reply.Error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"os" | ||
|
||
"github.com/Symantec/Dominator/lib/errors" | ||
"github.com/Symantec/Dominator/lib/log" | ||
"github.com/Symantec/Dominator/lib/srpc" | ||
proto "github.com/Symantec/Dominator/proto/hypervisor" | ||
) | ||
|
||
func removeIpAddressSubcommand(args []string, logger log.DebugLogger) { | ||
ipAddr := net.ParseIP(args[0]) | ||
if len(ipAddr) < 4 { | ||
fmt.Fprintf(os.Stderr, "Invalid IP address: %s\n", args[0]) | ||
os.Exit(1) | ||
} | ||
err := removeAddress(proto.Address{IpAddress: ipAddr}, logger) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error removing IP address: %s\n", err) | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
} | ||
|
||
func removeMacAddressSubcommand(args []string, logger log.DebugLogger) { | ||
address := proto.Address{MacAddress: args[0]} | ||
err := removeAddress(address, logger) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error removing MAC address: %s\n", err) | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
} | ||
|
||
func removeAddress(address proto.Address, logger log.DebugLogger) error { | ||
address.Shrink() | ||
request := proto.ChangeAddressPoolRequest{ | ||
AddressesToRemove: []proto.Address{address}} | ||
var reply proto.ChangeAddressPoolResponse | ||
clientName := fmt.Sprintf("%s:%d", *hypervisorHostname, *hypervisorPortNum) | ||
client, err := srpc.DialHTTP("tcp", clientName, 0) | ||
if err != nil { | ||
return err | ||
} | ||
defer client.Close() | ||
err = client.RequestReply("Hypervisor.ChangeAddressPool", request, &reply) | ||
if err != nil { | ||
return err | ||
} | ||
return errors.New(reply.Error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package fsstorer | ||
|
||
import ( | ||
"net" | ||
) | ||
|
||
func (s *Storer) getHypervisorForIp(addr net.IP) (net.IP, error) { | ||
if ip, err := netIpToIp(addr); err != nil { | ||
return nil, err | ||
} else { | ||
s.mutex.RLock() | ||
hypervisor, ok := s.ipToHypervisor[ip] | ||
s.mutex.RUnlock() | ||
if !ok { | ||
return nil, nil | ||
} | ||
return hypervisor[:], nil | ||
} | ||
} |
Oops, something went wrong.