diff --git a/pkg/util/aws/instancenic.go b/pkg/util/aws/instancenic.go index 6a3ca44d3d..f10262fea2 100644 --- a/pkg/util/aws/instancenic.go +++ b/pkg/util/aws/instancenic.go @@ -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 } \ No newline at end of file