Beispiel #1
0
 /// <summary>
 /// Clear the reported NIC attr info
 /// </summary>
 virtual protected void removeNicAttr()
 {
     try
     {
         foreach (string node in netAttrItem.children)
         {
             try
             {
                 wmisession.GetXenStoreItem(node).Remove();
             }
             catch { }; // Ignore failure, if nodes don't exist
         }
     }
     catch { }; // If there are no nodes, then we can also ignore failure
 }
Beispiel #2
0
        /// <summary>
        /// Constructor of the NetInfo class
        /// </summary>
        /// <param name="exceptionhandler">The exception handler, trigger when exception occurs</param>
        /// <param name="devicePath"> xenstore device path of NIC device</param>
        /// <param name="attrPath"> xenstore path NIC device data info report back to</param>
        /// <param name="session"> wmi session, mainly used to access xenstore</param>
        public NetInfo(IExceptionHandler exceptionhandler, string devicePath, string attrPath, AWmiSession session)
        {
            wmisession            = session;
            this.exceptionhandler = exceptionhandler;
            updating = new Object();

            this.devicePath = devicePath;
            this.attrPath   = attrPath;

            netDeviceItem = wmisession.GetXenStoreItem(devicePath);
            netAttrItem   = wmisession.GetXenStoreItem(attrPath);

            netDeviceItem.Watch(onXenstoreNetChanged);

            addrChangeHandler = new NetworkAddressChangedEventHandler(onVmNicAddrChange);
            NetworkChange.NetworkAddressChanged += addrChangeHandler;

            netStaticIpSetting = wmisession.GetXenStoreItem(STATIC_IP_FEATURE_MONITOR_KEY);
            netStaticIpSetting.Watch(onXenstoreStaticIpSettingChanged);

            // trigger the first update
            needsRefresh = true;
        }