/// <summary> /// Constructor, construct the VIfInfo object, NIC object, Session object /// </summary> public VifInfoTester() { // arr = new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }; mac1 = new byte[] { 0x32, 0x70, 0xd5, 0xa0, 0x5a, 0x21 }; mac2 = new byte[] { 0x06, 0x49, 0xdf, 0xd0, 0xbb, 0x2b }; session = new MockWmiSession(); // Init mock session session.GetXenStoreItem("xenserver/device/net-sriov-vf", ""); session.GetXenStoreItem("xenserver/device/net-sriov-vf/1", ""); session.GetXenStoreItem("xenserver/device/net-sriov-vf/1/mac", UTFunctions.getMacString(mac1)); session.GetXenStoreItem("xenserver/device/net-sriov-vf/2", ""); session.GetXenStoreItem("xenserver/device/net-sriov-vf/2/mac", UTFunctions.getMacString(mac2)); vf = new MockVifInfo(null, session); // Construct mock Nics info nics = new MockNetworkInterface[2]; // Construct first Nic nics[0] = new MockNetworkInterface("Ethernet UT1", "This is mock NIC for UT1"); ipv4BytesNic1 = new byte[] { 10, 71, 153, 8 }; IPAddress addrIpv4 = new IPAddress(ipv4BytesNic1); ipv6BytesNic1 = new byte[] { 0xfd, 0x06, 0x77, 0x68, 0xb9, 0xe5, 0x8a, 0x40, 0x4, 0x49, 0xdf, 0xff, 0xfe, 0xd0, 0xbb, 0x2b }; IPAddress addrIpv6 = new IPAddress(ipv6BytesNic1); PhysicalAddress physicalAddr = new PhysicalAddress(mac1); nics[0].SetPhysicalAddress(physicalAddr); MockUnicastIPAddressInformationCollection uniIPCol = new MockUnicastIPAddressInformationCollection(); MockIPAddressInformation ipv4AddressInformation = new MockIPAddressInformation(); ipv4AddressInformation.SetIPAddress(addrIpv4); MockIPAddressInformation ipv6AddressInformation = new MockIPAddressInformation(); ipv6AddressInformation.SetIPAddress(addrIpv6); uniIPCol.Add(ipv4AddressInformation); uniIPCol.Add(ipv6AddressInformation); MockIPInterfaceProperties nicProperties = new MockIPInterfaceProperties(uniIPCol); nics[0].SetIPProperties(nicProperties); //Construct second Nic nics[1] = new MockNetworkInterface("Ethernet UT2", "This is mock NIC for UT2"); ipv4BytesNic2 = new byte[] { 10, 71, 153, 9 }; addrIpv4 = new IPAddress(ipv4BytesNic2); ipv6BytesNic2 = new byte[] { 0xfd, 0x06, 0x77, 0x68, 0xb9, 0xe5, 0x8a, 0x40, 0x04, 0x49, 0xdf, 0xff, 0xfe, 0xd0, 0xbb, 0xbb }; addrIpv6 = new IPAddress(ipv6BytesNic2); uniIPCol = new MockUnicastIPAddressInformationCollection(); ipv4AddressInformation = new MockIPAddressInformation(); ipv4AddressInformation.SetIPAddress(addrIpv4); ipv6AddressInformation = new MockIPAddressInformation(); ipv6AddressInformation.SetIPAddress(addrIpv6); uniIPCol.Add(ipv4AddressInformation); uniIPCol.Add(ipv6AddressInformation); nicProperties = new MockIPInterfaceProperties(uniIPCol); nics[1].SetIPProperties(nicProperties); physicalAddr = new PhysicalAddress(mac2); nics[1].SetPhysicalAddress(physicalAddr); }
/// <summary> /// Set the IPInterfaceProperties /// </summary> /// <param name="properties"></param> public void SetIPProperties(MockIPInterfaceProperties properties) { this.properties = properties; }