mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
multicloud: ICloudNic: fix GetMAC()
This commit is contained in:
@@ -334,9 +334,16 @@ func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) {
|
||||
nics := make([]cloudprovider.ICloudNic, 0)
|
||||
for _, ip := range self.VpcAttributes.PrivateIpAddress.IpAddress {
|
||||
nic := SInstanceNic{instance: self, ipAddr: ip}
|
||||
var (
|
||||
networkInterfaces = self.NetworkInterfaces.NetworkInterface
|
||||
nics []cloudprovider.ICloudNic
|
||||
)
|
||||
for _, networkInterface := range networkInterfaces {
|
||||
nic := SInstanceNic{
|
||||
instance: self,
|
||||
ipAddr: networkInterface.PrimaryIpAddress,
|
||||
macAddr: networkInterface.MacAddress,
|
||||
}
|
||||
nics = append(nics, &nic)
|
||||
}
|
||||
return nics, nil
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
package aliyun
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SInstanceNic struct {
|
||||
instance *SInstance
|
||||
ipAddr string
|
||||
macAddr string
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetIP() string {
|
||||
@@ -30,8 +29,7 @@ func (self *SInstanceNic) GetIP() string {
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
ip, _ := netutils.NewIPV4Addr(self.ipAddr)
|
||||
return ip.ToMac("00:16:")
|
||||
return self.macAddr
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) InClassicNetwork() bool {
|
||||
|
||||
@@ -334,9 +334,16 @@ func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) {
|
||||
nics := make([]cloudprovider.ICloudNic, 0)
|
||||
for _, ip := range self.VpcAttributes.PrivateIpAddress.IpAddress {
|
||||
nic := SInstanceNic{instance: self, ipAddr: ip}
|
||||
var (
|
||||
networkInterfaces = self.NetworkInterfaces.NetworkInterface
|
||||
nics []cloudprovider.ICloudNic
|
||||
)
|
||||
for _, networkInterface := range networkInterfaces {
|
||||
nic := SInstanceNic{
|
||||
instance: self,
|
||||
ipAddr: networkInterface.PrimaryIpAddress,
|
||||
macAddr: networkInterface.MacAddress,
|
||||
}
|
||||
nics = append(nics, &nic)
|
||||
}
|
||||
return nics, nil
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
package apsara
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SInstanceNic struct {
|
||||
instance *SInstance
|
||||
ipAddr string
|
||||
macAddr string
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetIP() string {
|
||||
@@ -30,8 +29,7 @@ func (self *SInstanceNic) GetIP() string {
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
ip, _ := netutils.NewIPV4Addr(self.ipAddr)
|
||||
return ip.ToMac("00:16:")
|
||||
return self.macAddr
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) InClassicNetwork() bool {
|
||||
|
||||
@@ -277,9 +277,16 @@ func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) {
|
||||
nics := make([]cloudprovider.ICloudNic, 0)
|
||||
for _, ip := range self.VpcAttributes.PrivateIpAddress.IpAddress {
|
||||
nic := SInstanceNic{instance: self, ipAddr: ip}
|
||||
var (
|
||||
networkInterfaces = self.NetworkInterfaces.NetworkInterface
|
||||
nics = make([]cloudprovider.ICloudNic, 0)
|
||||
)
|
||||
for _, networkInterface := range networkInterfaces {
|
||||
nic := SInstanceNic{
|
||||
instance: self,
|
||||
ipAddr: networkInterface.PrivateIpAddress,
|
||||
macAddr: networkInterface.MacAddress,
|
||||
}
|
||||
nics = append(nics, &nic)
|
||||
}
|
||||
return nics, nil
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
package aws
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SInstanceNic struct {
|
||||
instance *SInstance
|
||||
ipAddr string
|
||||
macAddr string
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetIP() string {
|
||||
@@ -30,8 +29,7 @@ func (self *SInstanceNic) GetIP() string {
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
ip, _ := netutils.NewIPV4Addr(self.ipAddr)
|
||||
return ip.ToMac("00:16:")
|
||||
return self.macAddr
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) InClassicNetwork() bool {
|
||||
|
||||
@@ -85,10 +85,6 @@ func (self *SInstanceNic) Delete() error {
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
mac := self.Properties.MacAddress
|
||||
if len(mac) == 0 {
|
||||
ip, _ := netutils.NewIPV4Addr(self.GetIP())
|
||||
return ip.ToMac("00:16:")
|
||||
}
|
||||
return strings.Replace(strings.ToLower(mac), "-", ":", -1)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package ctyun
|
||||
import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
@@ -45,9 +44,7 @@ func (self *SInstanceNic) GetIP() string {
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
ipAddr := self.GetIP()
|
||||
ip, _ := netutils.NewIPV4Addr(ipAddr)
|
||||
return ip.ToMac("00:16:")
|
||||
return self.MACAddr
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetDriver() string {
|
||||
|
||||
@@ -345,7 +345,11 @@ func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) {
|
||||
for _, ipAddresses := range self.Addresses {
|
||||
for _, ipAddress := range ipAddresses {
|
||||
if ipAddress.OSEXTIPSType == "fixed" {
|
||||
nic := SInstanceNic{instance: self, ipAddr: ipAddress.Addr}
|
||||
nic := SInstanceNic{
|
||||
instance: self,
|
||||
ipAddr: ipAddress.Addr,
|
||||
macAddr: ipAddress.OSEXTIPSMACMACAddr,
|
||||
}
|
||||
nics = append(nics, &nic)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ package huawei
|
||||
|
||||
import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud/huawei/client/modules"
|
||||
@@ -59,6 +58,7 @@ type FixedIP struct {
|
||||
type SInstanceNic struct {
|
||||
instance *SInstance
|
||||
ipAddr string
|
||||
macAddr string
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetIP() string {
|
||||
@@ -66,8 +66,7 @@ func (self *SInstanceNic) GetIP() string {
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
ip, _ := netutils.NewIPV4Addr(self.ipAddr)
|
||||
return ip.ToMac("00:16:")
|
||||
return self.macAddr
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetDriver() string {
|
||||
|
||||
@@ -300,7 +300,11 @@ func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
nic := SInstanceNic{instance: self, ipAddr: ip.IP}
|
||||
nic := SInstanceNic{
|
||||
instance: self,
|
||||
ipAddr: ip.IP,
|
||||
macAddr: ip.MAC,
|
||||
}
|
||||
nics = append(nics, &nic)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
package ucloud
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SInstanceNic struct {
|
||||
instance *SInstance
|
||||
ipAddr string
|
||||
macAddr string
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetIP() string {
|
||||
@@ -30,8 +29,7 @@ func (self *SInstanceNic) GetIP() string {
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
ip, _ := netutils.NewIPV4Addr(self.ipAddr)
|
||||
return ip.ToMac("00:16:")
|
||||
return self.macAddr
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetDriver() string {
|
||||
|
||||
Reference in New Issue
Block a user