Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
adapt calls to dev branch
Browse files Browse the repository at this point in the history
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
  • Loading branch information
Yoan Blanc committed Dec 14, 2017
1 parent 6b001e6 commit 66694f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (engine *Engine) FetchNicAndVm() {

func (engine *Engine) ObtainNic(nic_id string) error {

_, err := engine.Exo.AddIpToNic(nic_id, engine.ExoIP.String())
_, err := engine.Exo.AddIpToNic(nic_id, engine.ExoIP.String(), engine.AsyncInfo)
if err != nil {
Logger.Crit(fmt.Sprintf("could not add ip %s to nic %s: %s",
engine.ExoIP.String(),
Expand Down Expand Up @@ -76,7 +76,7 @@ func (engine *Engine) ReleaseMyNic() error {
return fmt.Errorf("could not remove ip from nic: unknown association")
}

_, err = engine.Exo.RemoveIpFromNic(nic_address_id)
err = engine.Exo.RemoveIpFromNic(nic_address_id, engine.AsyncInfo)
if err != nil {
Logger.Crit(fmt.Sprintf("could not dissociate ip %s: %s",
engine.ExoIP.String(), err))
Expand Down Expand Up @@ -112,7 +112,7 @@ func (engine *Engine) ReleaseNic(nic_id string) {
return
}

_, err = engine.Exo.RemoveIpFromNic(nic_address_id)
err = engine.Exo.RemoveIpFromNic(nic_address_id, engine.AsyncInfo)
if err != nil {
Logger.Crit(fmt.Sprintf("could not remove ip from nic %s (%s): %s",
nic_id, nic_address_id, err))
Expand All @@ -122,7 +122,7 @@ func (engine *Engine) ReleaseNic(nic_id string) {

func VMHasSecurityGroup(vm *egoscale.VirtualMachine, sgname string) bool {

for _, sg := range vm.SecurityGroups {
for _, sg := range vm.SecurityGroup {
if sg.Name == sgname {
return true
}
Expand All @@ -140,7 +140,7 @@ func GetSecurityGroupPeers(ego *egoscale.Client, sgname string) ([]string, error

for _, vm := range vms {
if VMHasSecurityGroup(vm, sgname) {
primary_ip := vm.Nic[0].Ipaddress
primary_ip := vm.Nic[0].IpAddress
peers = append(peers, fmt.Sprintf("%s:%d", primary_ip, DefaultPort))
}
}
Expand All @@ -157,7 +157,7 @@ func FindPeerNic(ego *egoscale.Client, ip string) (string, error) {

for _, vm := range vms {

if vm.Nic[0].Ipaddress == ip {
if vm.Nic[0].IpAddress == ip {
return vm.Nic[0].Id, nil
}
}
Expand Down
4 changes: 4 additions & 0 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func NewEngine(client *egoscale.Client, ip string) *Engine {
engine := Engine{
ExoIP: netip,
Exo: client,
AsyncInfo: egoscale.AsyncInfo{
Retries: 3,
Delay: 10,
},
}
engine.FetchNicAndVm()
return &engine
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ type Engine struct {
NicId string
ExoIP net.IP
Exo *egoscale.Client
AsyncInfo egoscale.AsyncInfo
}

0 comments on commit 66694f3

Please sign in to comment.