add instance nic

This commit is contained in:
TangBin
2018-10-16 16:33:50 +08:00
parent feead7a53d
commit 37ddd6002f
+20 -4
View File
@@ -1,6 +1,9 @@
package aws
import "yunion.io/x/onecloud/pkg/cloudprovider"
import (
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/pkg/util/netutils"
)
type SInstanceNic struct {
instance *SInstance
@@ -8,17 +11,30 @@ type SInstanceNic struct {
}
func (self *SInstanceNic) GetIP() string {
return ""
return self.ipAddr
}
func (self *SInstanceNic) GetMAC() string {
return ""
ip, _ := netutils.NewIPV4Addr(self.ipAddr)
return ip.ToMac("00:16:")
}
func (self *SInstanceNic) GetDriver() string {
return ""
return "virtio"
}
func (self *SInstanceNic) GetINetwork() cloudprovider.ICloudNetwork {
vswitchId := self.instance.VpcAttributes.VSwitchId
wires, err := self.instance.host.GetIWires()
if err != nil {
return nil
}
for i := 0; i < len(wires); i += 1 {
wire := wires[i].(*SWire)
net := wire.getNetworkById(vswitchId)
if net != nil {
return net
}
}
return nil
}