multicloud: ICloudNic: add GetId()

This commit is contained in:
Yousong Zhou
2020-11-26 21:18:58 +08:00
parent 1569966aa3
commit ab7ad856b5
16 changed files with 55 additions and 1 deletions
+1
View File
@@ -329,6 +329,7 @@ type ICloudVM interface {
}
type ICloudNic interface {
GetId() string
GetIP() string
GetMAC() string
InClassicNetwork() bool
+1
View File
@@ -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,
}
+5
View File
@@ -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
}
+1
View File
@@ -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,
}
+7
View File
@@ -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 {
+4
View File
@@ -24,6 +24,10 @@ type SInstanceNic struct {
macAddr string
}
func (self *SInstanceNic) GetId() string {
return ""
}
func (self *SInstanceNic) GetIP() string {
return self.ipAddr
}
@@ -31,6 +31,10 @@ type SClassicInstanceNic struct {
Location string
}
func (self *SClassicInstanceNic) GetId() string {
return ""
}
func (self *SClassicInstanceNic) GetIP() string {
return self.IP
}
-1
View File
@@ -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"
+4
View File
@@ -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"
}
+4
View File
@@ -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 {
+4
View File
@@ -33,6 +33,10 @@ type SNetworkInterface struct {
Kind string
}
func (nic *SNetworkInterface) GetId() string {
return ""
}
func (nic *SNetworkInterface) GetIP() string {
return nic.NetworkIP
}
+4
View File
@@ -61,6 +61,10 @@ type SInstanceNic struct {
macAddr string
}
func (self *SInstanceNic) GetId() string {
return ""
}
func (self *SInstanceNic) GetIP() string {
return self.ipAddr
}
+4
View File
@@ -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) {
+4
View File
@@ -26,6 +26,10 @@ type SInstanceNic struct {
classic bool
}
func (self *SInstanceNic) GetId() string {
return ""
}
func (self *SInstanceNic) GetIP() string {
return self.ipAddr
}
+4
View File
@@ -24,6 +24,10 @@ type SInstanceNic struct {
macAddr string
}
func (self *SInstanceNic) GetId() string {
return ""
}
func (self *SInstanceNic) GetIP() string {
return self.ipAddr
}
+4
View File
@@ -37,6 +37,10 @@ type SInstanceNic struct {
ZStackTime
}
func (nic *SInstanceNic) GetId() string {
return ""
}
func (nic *SInstanceNic) GetIP() string {
return nic.IP
}