/// <summary> /// Update the VSEM repository. /// </summary> /// <param name="txnMng">Transaction manager.</param> public void UpdateConnection(TransactionManager txnMng) { var JavaScriptSerializer = new JavaScriptSerializer(); JavaScriptSerializer.MaxJsonLength = int.MaxValue; StringBuilder json = new StringBuilder("\"TransactionManager\":" + JavaScriptSerializer.Serialize(txnMng)); ODLVSEMETW.EventWriteStartLibrary(MethodBase.GetCurrentMethod().Name, json.ToString()); if (txnMng == null) { throw new ArgumentException( "txnMng' is null or invalid."); } string VtnHostName = this.ConnectionString; if (VtnHostName.StartsWith(@"https://", StringComparison.Ordinal)) { VtnHostName = VtnHostName.Substring(8); } VtnHostName = VtnHostName.Split('.', ':').First(); var vseminformation = this.CreateVSEMInfo(); // Make sure we can connect to the ODL if (!this.VerifyConnection(vseminformation.MinVTNCoVersion)) { ODLVSEMETW.EventWriteProcesOdlLibraryError(MethodBase.GetCurrentMethod().Name, "WebAPI version is not supported."); throw new ArgumentException("WebAPI version is not supported."); } Controller odl_ctr = new Controller(this.ConnectionString, this.controllers, this.Credential); odl_ctr.Create_ctr(Constants.CTR_NAME); ODLVSEMETW.EventWriteCreateODLData( MethodBase.GetCurrentMethod().Name, "Creating VSEM repository."); VSEMConfig vsemConfig = new VSEMConfig(); txnMng.SetConfigManager(vsemConfig, TransactionManager.OpenMode.WriteMode); // Update Configuration Data; vsemConfig.Info = vseminformation; vsemConfig.Controller = new VSEMController(); vsemConfig.Controller.ControllerInfo = this.controllers; if (vsemConfig.NetworkServiceSystemInformation.Id.CompareTo(Guid.Empty) == 0) { vsemConfig.NetworkServiceSystemInformation = VSEMConnection.CreateSystemInfo(); } else { VSEMODLConstants.SYSTEM_INFO_ID = vsemConfig.NetworkServiceSystemInformation.Id; } if (vsemConfig.SwitchExtensionInfo.Count == 0) { vsemConfig.SwitchExtensionInfo = VSEMConnection.CreateSwitchExtensionInfos(); } else { VSEMODLConstants.SWITCH_EXTENSION_INFO_ID = vsemConfig.SwitchExtensionInfo[0].Id; } vsemConfig.SwitchExtensionInfo.ForEach((i) => VSEMConnection.AddSwitchFeatureToSwitchExtInfos(i, this.controllers)); LogicalNetworkConfig logicalNetworkConfig = new LogicalNetworkConfig(VtnHostName); txnMng.SetConfigManager(logicalNetworkConfig, TransactionManager.OpenMode.WriteMode); if (logicalNetworkConfig.LogicalNetworks.Count == 0) { logicalNetworkConfig.LogicalNetworks = this.CreateLogicalNetworks(); } PortProfileConfig portProfileConfig = new PortProfileConfig(); txnMng.SetConfigManager(portProfileConfig, TransactionManager.OpenMode.WriteMode); if (portProfileConfig.UplinkPortProfiles.Count == 0) { portProfileConfig.UplinkPortProfiles = VSEMConnection.CreateUplinkPortProfiles(); } else { VSEMODLConstants.UPLINK_PORT_PROFILE_ID = portProfileConfig.UplinkPortProfiles[0].Id; } if (portProfileConfig.VirtualPortProfiles.Count == 0) { portProfileConfig.VirtualPortProfiles = VSEMConnection.CreateVirtualPortProfiles(); } // Create HNV default resource. HNVLogicalNetworkManagement hnvMgmt = new HNVLogicalNetworkManagement(this.VtnHostName); hnvMgmt.CreateHNVLogicalNetwork(logicalNetworkConfig); hnvMgmt.AssociatePortProfileWithHNV(portProfileConfig); this.SaveVtncoInfo(txnMng, VtnHostName); ODLVSEMETW.EventWriteEndLibrary(MethodBase.GetCurrentMethod().Name, string.Empty); }