Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit f67dc2c

Browse files
author
FengyunPan
committed
Update gophercloud to support list interfaces of OpenStack instance
1 parent 7f023c2 commit f67dc2c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

pkg/cloudprovider/providers/openstack/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ go_library(
3434
"//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions:go_default_library",
3535
"//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes:go_default_library",
3636
"//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes:go_default_library",
37+
"//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces:go_default_library",
3738
"//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach:go_default_library",
3839
"//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers:go_default_library",
3940
"//vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts:go_default_library",

pkg/cloudprovider/providers/openstack/openstack.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/gophercloud/gophercloud"
3232
"github.com/gophercloud/gophercloud/openstack"
3333
apiversions_v1 "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions"
34+
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces"
3435
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
3536
"github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts"
3637
tokens3 "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
@@ -444,6 +445,26 @@ func getAddressByName(client *gophercloud.ServiceClient, name types.NodeName) (s
444445
return addrs[0].Address, nil
445446
}
446447

448+
// getAttachedInterfacesByID returns the node interfaces of the specified instance.
449+
func getAttachedInterfacesByID(client *gophercloud.ServiceClient, serviceID string) ([]attachinterfaces.Interface, error) {
450+
var interfaces []attachinterfaces.Interface
451+
452+
pager := attachinterfaces.List(client, serviceID)
453+
err := pager.EachPage(func(page pagination.Page) (bool, error) {
454+
s, err := attachinterfaces.ExtractInterfaces(page)
455+
if err != nil {
456+
return false, err
457+
}
458+
interfaces = append(interfaces, s...)
459+
return true, nil
460+
})
461+
if err != nil {
462+
return interfaces, err
463+
}
464+
465+
return interfaces, nil
466+
}
467+
447468
func (os *OpenStack) Clusters() (cloudprovider.Clusters, bool) {
448469
return nil, false
449470
}

0 commit comments

Comments
 (0)