From ab7ad856b593caa80504cef6a824d0dfaa195d02 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Sat, 21 Nov 2020 15:32:42 +0800 Subject: [PATCH] multicloud: ICloudNic: add GetId() --- pkg/cloudprovider/resources.go | 1 + pkg/multicloud/aliyun/instance.go | 1 + pkg/multicloud/aliyun/instancenic.go | 5 +++++ pkg/multicloud/apsara/instance.go | 1 + pkg/multicloud/apsara/instancenic.go | 7 +++++++ pkg/multicloud/aws/instancenic.go | 4 ++++ pkg/multicloud/azure/classic_instancenic.go | 4 ++++ pkg/multicloud/azure/instancenic.go | 1 - pkg/multicloud/ctyun/instancenic.go | 4 ++++ pkg/multicloud/esxi/vnic.go | 4 ++++ pkg/multicloud/google/instancenic.go | 4 ++++ pkg/multicloud/huawei/instancenic.go | 4 ++++ pkg/multicloud/openstack/instancenic.go | 4 ++++ pkg/multicloud/qcloud/instancenic.go | 4 ++++ pkg/multicloud/ucloud/instancenic.go | 4 ++++ pkg/multicloud/zstack/instancenic.go | 4 ++++ 16 files changed, 55 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/resources.go b/pkg/cloudprovider/resources.go index 57910bda2c..f01d04ee55 100644 --- a/pkg/cloudprovider/resources.go +++ b/pkg/cloudprovider/resources.go @@ -329,6 +329,7 @@ type ICloudVM interface { } type ICloudNic interface { + GetId() string GetIP() string GetMAC() string InClassicNetwork() bool diff --git a/pkg/multicloud/aliyun/instance.go b/pkg/multicloud/aliyun/instance.go index 067e6b279e..dc1881787d 100644 --- a/pkg/multicloud/aliyun/instance.go +++ b/pkg/multicloud/aliyun/instance.go @@ -341,6 +341,7 @@ func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) { for _, networkInterface := range networkInterfaces { nic := SInstanceNic{ instance: self, + id: networkInterface.NetworkInterfaceId, ipAddr: networkInterface.PrimaryIpAddress, macAddr: networkInterface.MacAddress, } diff --git a/pkg/multicloud/aliyun/instancenic.go b/pkg/multicloud/aliyun/instancenic.go index aa99b1f65c..e3ae67096b 100644 --- a/pkg/multicloud/aliyun/instancenic.go +++ b/pkg/multicloud/aliyun/instancenic.go @@ -20,10 +20,15 @@ import ( type SInstanceNic struct { instance *SInstance + id string ipAddr string macAddr string } +func (self *SInstanceNic) GetId() string { + return self.id +} + func (self *SInstanceNic) GetIP() string { return self.ipAddr } diff --git a/pkg/multicloud/apsara/instance.go b/pkg/multicloud/apsara/instance.go index 9ff6fc116b..aa6b7b9fb7 100644 --- a/pkg/multicloud/apsara/instance.go +++ b/pkg/multicloud/apsara/instance.go @@ -341,6 +341,7 @@ func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) { for _, networkInterface := range networkInterfaces { nic := SInstanceNic{ instance: self, + id: networkInterface.NetworkInterfaceId, ipAddr: networkInterface.PrimaryIpAddress, macAddr: networkInterface.MacAddress, } diff --git a/pkg/multicloud/apsara/instancenic.go b/pkg/multicloud/apsara/instancenic.go index d84ea5400c..479d520291 100644 --- a/pkg/multicloud/apsara/instancenic.go +++ b/pkg/multicloud/apsara/instancenic.go @@ -20,8 +20,15 @@ import ( type SInstanceNic struct { instance *SInstance + id string ipAddr string macAddr string + + cloudprovider.DummyICloudNic +} + +func (self *SInstanceNic) GetId() string { + return self.id } func (self *SInstanceNic) GetIP() string { diff --git a/pkg/multicloud/aws/instancenic.go b/pkg/multicloud/aws/instancenic.go index ea22499f20..ae13c1aa54 100644 --- a/pkg/multicloud/aws/instancenic.go +++ b/pkg/multicloud/aws/instancenic.go @@ -24,6 +24,10 @@ type SInstanceNic struct { macAddr string } +func (self *SInstanceNic) GetId() string { + return "" +} + func (self *SInstanceNic) GetIP() string { return self.ipAddr } diff --git a/pkg/multicloud/azure/classic_instancenic.go b/pkg/multicloud/azure/classic_instancenic.go index 6c40bcf9e6..ccb7943a8e 100644 --- a/pkg/multicloud/azure/classic_instancenic.go +++ b/pkg/multicloud/azure/classic_instancenic.go @@ -31,6 +31,10 @@ type SClassicInstanceNic struct { Location string } +func (self *SClassicInstanceNic) GetId() string { + return "" +} + func (self *SClassicInstanceNic) GetIP() string { return self.IP } diff --git a/pkg/multicloud/azure/instancenic.go b/pkg/multicloud/azure/instancenic.go index 6470ec053a..0aa622356e 100644 --- a/pkg/multicloud/azure/instancenic.go +++ b/pkg/multicloud/azure/instancenic.go @@ -20,7 +20,6 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - "yunion.io/x/pkg/util/netutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudprovider" diff --git a/pkg/multicloud/ctyun/instancenic.go b/pkg/multicloud/ctyun/instancenic.go index 2ab7c4336c..a19dc08401 100644 --- a/pkg/multicloud/ctyun/instancenic.go +++ b/pkg/multicloud/ctyun/instancenic.go @@ -47,6 +47,10 @@ func (self *SInstanceNic) GetMAC() string { return self.MACAddr } +func (self *SInstanceNic) GetId() string { + return "" +} + func (self *SInstanceNic) GetDriver() string { return "virtio" } diff --git a/pkg/multicloud/esxi/vnic.go b/pkg/multicloud/esxi/vnic.go index d328dde25f..01f60ba17d 100644 --- a/pkg/multicloud/esxi/vnic.go +++ b/pkg/multicloud/esxi/vnic.go @@ -41,6 +41,10 @@ func (nic *SVirtualNIC) getVirtualEthernetCard() *types.VirtualEthernetCard { return nil } +func (nic *SVirtualNIC) GetId() string { + return "" +} + func (nic *SVirtualNIC) GetIP() string { guestIps := nic.vm.getGuestIps() if ip, ok := guestIps[nic.GetMAC()]; ok { diff --git a/pkg/multicloud/google/instancenic.go b/pkg/multicloud/google/instancenic.go index e2d01e3f95..b0bc506f80 100644 --- a/pkg/multicloud/google/instancenic.go +++ b/pkg/multicloud/google/instancenic.go @@ -33,6 +33,10 @@ type SNetworkInterface struct { Kind string } +func (nic *SNetworkInterface) GetId() string { + return "" +} + func (nic *SNetworkInterface) GetIP() string { return nic.NetworkIP } diff --git a/pkg/multicloud/huawei/instancenic.go b/pkg/multicloud/huawei/instancenic.go index 047f3be3ff..69d31b999a 100644 --- a/pkg/multicloud/huawei/instancenic.go +++ b/pkg/multicloud/huawei/instancenic.go @@ -61,6 +61,10 @@ type SInstanceNic struct { macAddr string } +func (self *SInstanceNic) GetId() string { + return "" +} + func (self *SInstanceNic) GetIP() string { return self.ipAddr } diff --git a/pkg/multicloud/openstack/instancenic.go b/pkg/multicloud/openstack/instancenic.go index 3c49a74c80..9c54c803e5 100644 --- a/pkg/multicloud/openstack/instancenic.go +++ b/pkg/multicloud/openstack/instancenic.go @@ -59,6 +59,10 @@ func (region *SRegion) GetInstancePorts(instanceId string) ([]SInstancePort, err return ports, nil } +func (nic *SInstancePort) GetId() string { + return "" +} + func (nic *SInstancePort) GetIP() string { for i := range nic.FixedIps { if regutils.MatchIPAddr(nic.FixedIps[i].IpAddress) { diff --git a/pkg/multicloud/qcloud/instancenic.go b/pkg/multicloud/qcloud/instancenic.go index ed4c968ce6..4152b98804 100644 --- a/pkg/multicloud/qcloud/instancenic.go +++ b/pkg/multicloud/qcloud/instancenic.go @@ -26,6 +26,10 @@ type SInstanceNic struct { classic bool } +func (self *SInstanceNic) GetId() string { + return "" +} + func (self *SInstanceNic) GetIP() string { return self.ipAddr } diff --git a/pkg/multicloud/ucloud/instancenic.go b/pkg/multicloud/ucloud/instancenic.go index 7cbb126bc7..5b72815cb2 100644 --- a/pkg/multicloud/ucloud/instancenic.go +++ b/pkg/multicloud/ucloud/instancenic.go @@ -24,6 +24,10 @@ type SInstanceNic struct { macAddr string } +func (self *SInstanceNic) GetId() string { + return "" +} + func (self *SInstanceNic) GetIP() string { return self.ipAddr } diff --git a/pkg/multicloud/zstack/instancenic.go b/pkg/multicloud/zstack/instancenic.go index a6f7ebb615..c49082216a 100644 --- a/pkg/multicloud/zstack/instancenic.go +++ b/pkg/multicloud/zstack/instancenic.go @@ -37,6 +37,10 @@ type SInstanceNic struct { ZStackTime } +func (nic *SInstanceNic) GetId() string { + return "" +} + func (nic *SInstanceNic) GetIP() string { return nic.IP }