Exemple #1
0
        /// <summary>
        /// Override method to customize how to report the NIC data
        /// </summary>
        /// <param name="device">The device needs to be reported</param>
        /// <param name="nic">nic object inside VM</param>
        override protected void writeDevice(string device, NetworkInterface nic)
        {
            if (null == device || null == nic)
            {
                return;                                // We trust xenstore, it is a SR-IOV device
            }
            string deviceId = getDeviceIndexFromIndexedDevicePath(device);
            string nameKey  = String.Format("{0}/{1}/name", attrPath, deviceId);
            string macKey   = String.Format("{0}/{1}/mac", attrPath, deviceId);

            // Update the xenstore info
            try
            {
                // Update name
                AXenStoreItem xenName = wmisession.GetXenStoreItem(nameKey);
                xenName.value = nic.Name;

                // Update mac
                AXenStoreItem xenMac  = wmisession.GetXenStoreItem(macKey);
                byte[]        byteMac = nic.GetPhysicalAddress().GetAddressBytes();
                xenMac.value = NicUtil.getMacStringFromByteArray(byteMac);

                // Update ipv4 info
                updateVFIpInfo(deviceId, System.Net.Sockets.AddressFamily.InterNetwork, nic);

                // Update the ipv6 info
                updateVFIpInfo(deviceId, System.Net.Sockets.AddressFamily.InterNetworkV6, nic);
            }
            catch (Exception e)
            {
                Debug.Print("updateVFXenstoreAttrInfo error: {0}", e);
            }
        }
        public void TestGetMacStringFromByteArray()
        {
            string expectedResult = UTFunctions.getMacString(mac1);
            string result         = NicUtil.getMacStringFromByteArray(mac1);

            Assert.AreEqual(expectedResult, result);
        }