/// <summary>
 /// Store the config info to field member(Entity).
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected override void SetEntity(ConfigManagerBase config)
 {
     if (config == null) {
         this.VLANIDMapping = new List<VSEMVLANIDMapping>();
     } else {
         this.VLANIDMapping = ((VLANIDMappingConfig)config).VLANIDMapping;
     }
 }
예제 #2
0
 /// <summary>
 /// Store the config info to field member(Entity).
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected override void SetEntity(ConfigManagerBase config)
 {
     if (config == null) {
         this.VMNetwork = new VSEMVMNetwork();
         this.VMNetwork.VmNetworks = new List<VMNetwork>();
         this.VMNetwork.VMNetworkMappingInformation = new VMNetworkMappingInfo();
         this.VMNetwork.VMNetworkMappingInformation.VMNetworkInfo = new List<VMNetworkInfo>();
     } else {
         this.VMNetwork = ((VMNetworkConfig)config).VMNetwork;
     }
 }
예제 #3
0
        /// <summary>
        /// Delete the config file.
        /// </summary>
        /// <param name="config">ConfigManager object.</param>
        public void DelConfig(ConfigManagerBase config)
        {
            // Parameter check.
            if (config == null)
            {
                ODLVSEMETW.EventWriteConfigManagerDiagError(MethodBase.GetCurrentMethod().Name,
                                                            "The parameter 'config' is null or invalid.");
                throw new ArgumentException(
                          "The parameter 'config' is null or invalid.");
            }

            // Delete the config file.
            config.Del();
        }
예제 #4
0
        /// <summary>
        /// Set the ConfigManager to Managers.
        /// </summary>
        /// <param name="config">ConfigManager object.</param>
        /// <param name="mode">Open mode of config file.</param>
        public void SetConfigManager(ConfigManagerBase config, OpenMode mode)
        {
            // Parameter check.
            if (config == null)
            {
                ODLVSEMETW.EventWriteConfigManagerDiagError(MethodBase.GetCurrentMethod().Name,
                                                            "The parameter 'config' is null or invalid.");
                throw new ArgumentException(
                          "The parameter 'config' is null or invalid.");
            }
            if (!OpenMode.IsDefined(typeof(OpenMode), mode))
            {
                ODLVSEMETW.EventWriteConfigManagerDiagError(MethodBase.GetCurrentMethod().Name,
                                                            "The parameter 'mode' is null or invalid.");
                throw new ArgumentException(
                          "The parameter 'mode' is null or invalid.");
            }

            // Initialize ConfigManager.
            config.Initialize(mode);

            // Set the Managers.
            this.Managers.Add(config);
        }
예제 #5
0
        /// <summary>
        /// Initialize of ConfigManager.
        /// </summary>
        /// <param name="mode">Open mode of config file.</param>
        public void Initialize(TransactionManager.OpenMode mode)
        {
            ConfigManagerBase config = null;

            if (mode == TransactionManager.OpenMode.WriteMode)
            {
                FileInfo info = new FileInfo(this.Path);
                if (info.Directory.Exists == false)
                {
                    info.Directory.Create();
                }
            }

            // Open the config file.
            // (Retry max RETRY_COUNT times at RETRY_INTERVAL msec intervals)
            for (var cnt = 1; cnt <= RETRY_COUNT; cnt++)
            {
                try {
                    if (mode == TransactionManager.OpenMode.WriteMode)
                    {
                        // Open the config file by WriteMode.
                        this.FileStreamInfo = new FileStream(this.Path,
                                                             FileMode.OpenOrCreate,
                                                             FileAccess.ReadWrite,
                                                             FileShare.None);
                    }
                    else if (mode == TransactionManager.OpenMode.ReadMode)
                    {
                        // Open the config file by ReadMode.
                        this.FileStreamInfo = new FileStream(this.Path,
                                                             FileMode.Open,
                                                             FileAccess.Read,
                                                             FileShare.Read);
                    }

                    ODLVSEMETW.EventWriteConfigManagerFileOpen(this.Path, (uint)mode);
                    break;
                } catch (Exception e) {
                    // If the config file is locked, retry the open.
                    if (e.HResult != unchecked ((int)FILE_LOCK_FAILED_CODE) || cnt == RETRY_COUNT)
                    {
                        ODLVSEMETW.EventWriteConfigManagerFileIOError(MethodBase.GetCurrentMethod().Name, e.Message);
                        throw;
                    }
                    Thread.Sleep(RETRY_INTERVAL);
                }
            }

            try {
                // If the config file is not empty, get the config info.
                if (this.FileStreamInfo.Length != 0)
                {
                    var dcs = new DataContractSerializer(this.GetType());
                    config = (ConfigManagerBase)dcs.ReadObject(this.FileStreamInfo);
                }

                this.SetEntity(config);
            } catch (Exception e) {
                // The config file closed because failed to get the config info.
                ODLVSEMETW.EventWriteConfigManagerFileIOError(MethodBase.GetCurrentMethod().Name, e.Message);
                this.FileStreamInfo.Close();
                throw;
            }
        }
예제 #6
0
 /// <summary>
 /// Store the config info to field member(Entity) of inheritance class.
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected abstract void SetEntity(ConfigManagerBase config);
예제 #7
0
 /// <summary>
 /// Store the config info to field member(Entity).
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected override void SetEntity(ConfigManagerBase config)
 {
     if (config == null) {
         this.Info = null;
     } else {
         this.Info = ((OdlInformation)config).Info;
     }
 }
 /// <summary>
 /// Store the config info to field member(Entity).
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected override void SetEntity(ConfigManagerBase config)
 {
     if (config == null) {
         this.LogicalNetworks = new List<LogicalNetwork>();
     } else {
         this.LogicalNetworks = ((LogicalNetworkConfig)config).LogicalNetworks;
     }
 }
 /// <summary>
 /// Store the config info to field member(Entity).
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected override void SetEntity(ConfigManagerBase config)
 {
     if (config == null) {
         this.UplinkPortProfiles = new List<VSEMUplinkPortProfile>();
         this.VirtualPortProfiles = new List<VSEMVirtualPortProfile>();
     } else {
         this.UplinkPortProfiles = ((PortProfileConfig)config).UplinkPortProfiles;
         this.VirtualPortProfiles = ((PortProfileConfig)config).VirtualPortProfiles;
     }
 }
 /// <summary>
 /// Store the config info to field member(Entity) of inheritance class.
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected abstract void SetEntity(ConfigManagerBase config);
        /// <summary>
        /// Delete the config file.
        /// </summary>
        /// <param name="config">ConfigManager object.</param>
        public void DelConfig(ConfigManagerBase config)
        {
            // Parameter check.
            if (config == null) {
                ODLVSEMETW.EventWriteConfigManagerDiagError(MethodBase.GetCurrentMethod().Name,
                    "The parameter 'config' is null or invalid.");
                throw new ArgumentException(
                    "The parameter 'config' is null or invalid.");
            }

            // Delete the config file.
            config.Del();
        }
        /// <summary>
        /// Set the ConfigManager to Managers.
        /// </summary>
        /// <param name="config">ConfigManager object.</param>
        /// <param name="mode">Open mode of config file.</param>
        public void SetConfigManager(ConfigManagerBase config, OpenMode mode)
        {
            // Parameter check.
            if (config == null) {
                ODLVSEMETW.EventWriteConfigManagerDiagError(MethodBase.GetCurrentMethod().Name,
                    "The parameter 'config' is null or invalid.");
                throw new ArgumentException(
                    "The parameter 'config' is null or invalid.");
            }
            if (!OpenMode.IsDefined(typeof(OpenMode), mode)) {
                ODLVSEMETW.EventWriteConfigManagerDiagError(MethodBase.GetCurrentMethod().Name,
                    "The parameter 'mode' is null or invalid.");
                throw new ArgumentException(
                    "The parameter 'mode' is null or invalid.");
            }

            // Initialize ConfigManager.
            config.Initialize(mode);

            // Set the Managers.
            this.Managers.Add(config);
        }
예제 #13
0
 /// <summary>
 /// Store the config info to field member(Entity).
 /// </summary>
 /// <param name="config">ConfigManager object.</param>
 protected override void SetEntity(ConfigManagerBase config)
 {
     if (config == null) {
         this.Info = new VSEMInfo();
         this.NetworkServiceSystemInformation = new NetworkServiceSystemInformation();
         this.Controller = new VSEMController();
         this.SwitchExtensionInfo = new List<VSEMSwitchExtensionInfo>();
     } else {
         this.Info = ((VSEMConfig)config).Info;
         this.NetworkServiceSystemInformation = ((VSEMConfig)config).NetworkServiceSystemInformation;
         this.Controller = ((VSEMConfig)config).Controller;
         this.SwitchExtensionInfo = ((VSEMConfig)config).SwitchExtensionInfo;
     }
 }