public StagingTask(StagingStartMessageRequest message) { UhuruSection uhuruSection = (UhuruSection)ConfigurationManager.GetSection("uhuru"); this.TaskId = message.TaskID; this.Message = message; this.workspace = new StagingWorkspace(Path.Combine(uhuruSection.DEA.BaseDir, "staging"), message.TaskID); this.buildpacksDir = Path.GetFullPath(uhuruSection.DEA.Staging.BuildpacksDirectory); this.stagingTimeout = uhuruSection.DEA.Staging.StagingTimeoutMs; this.gitExe = Path.GetFullPath(uhuruSection.DEA.Staging.GitExecutable); var prisonInfo = new ProcessPrisonCreateInfo(); prisonInfo.Id = this.TaskId; prisonInfo.TotalPrivateMemoryLimit = (long)this.Message.Properties.Resources.MemoryMbytes * 1024 * 1024; if (uhuruSection.DEA.UseDiskQuota) { prisonInfo.DiskQuotaBytes = (long)this.Message.Properties.Resources.DiskMbytes * 1024 * 1024; prisonInfo.DiskQuotaPath = this.workspace.BaseDir; } if (uhuruSection.DEA.UploadThrottleBitsps > 0) { prisonInfo.NetworkOutboundRateLimitBitsPerSecond = uhuruSection.DEA.UploadThrottleBitsps; } this.prison = new ProcessPrison(); prison.Create(prisonInfo); }
public void TC002_ServiceTestConfig() { Assert.AreEqual(".\\", UhuruSection.GetSection().Service.BaseDir); Assert.AreEqual(0, UhuruSection.GetSection().Service.Index); Assert.AreEqual("198.41.0.4", UhuruSection.GetSection().Service.LocalRoute); Assert.AreEqual("(local)", UhuruSection.GetSection().Service.MSSql.Host); Assert.AreEqual("sa", UhuruSection.GetSection().Service.MSSql.User); Assert.AreEqual(1433, UhuruSection.GetSection().Service.MSSql.Port); }
public void TC001_TestConfig() { UhuruSection uhuruSection = (UhuruSection)ConfigurationManager.GetSection("uhuru"); if (!File.Exists("uhuruTest.config")) { Assert.Fail(); } Assert.AreEqual("c:\\droplets", uhuruSection.DEA.BaseDir); }
public void TC001_TestConfig() { if (!File.Exists("uhuruTest.config")) { Assert.Fail(); } Assert.AreEqual("c:\\droplets", UhuruSection.GetSection().DEA.BaseDir); Assert.AreEqual("iis", UhuruSection.GetSection().DEA.Runtimes["iis"].Name); Assert.AreEqual("7.0", UhuruSection.GetSection().DEA.Runtimes["iis"].Environment["iisVersion"].Value); Assert.AreEqual("3.5;4.0", UhuruSection.GetSection().DEA.Runtimes["iis"].Environment["supportedFrameworks"].Value); Assert.AreEqual("true", UhuruSection.GetSection().DEA.Runtimes["iis"].Debug["simple"].Environment["useCredentials"].Value); Assert.AreEqual("60000", UhuruSection.GetSection().DEA.Runtimes["iis"].Debug["simple"].Environment["connectionTimeout"].Value); }
public void TC002_ServiceTestConfig() { UhuruSection uhuruSection = (UhuruSection)ConfigurationManager.GetSection("uhuru"); Assert.AreEqual(".\\", uhuruSection.Service.BaseDir); Assert.AreEqual(0, uhuruSection.Service.Index); Assert.AreEqual("198.41.0.4", uhuruSection.Service.LocalRoute); Assert.AreEqual("(local)", uhuruSection.Service.MSSql.Host); Assert.AreEqual("sa", uhuruSection.Service.MSSql.User); Assert.AreEqual(1433, uhuruSection.Service.MSSql.Port); Assert.AreEqual(200, uhuruSection.Service.Uhurufs.MaxStorageSize); Assert.AreEqual(false, uhuruSection.Service.FqdnHosts); }
/// <summary> /// Starts the MS SQL Node using the specified arguments. /// </summary> internal void Start() { ServiceElement serviceConfig = UhuruSection.GetSection().Service; Options options = new Options(); options.AvailableStorage = serviceConfig.AvailableStorage; options.Capacity = serviceConfig.Capacity; options.BaseDir = serviceConfig.BaseDir; options.Index = serviceConfig.Index; options.LocalDB = serviceConfig.LocalDB; options.MaxDBSize = serviceConfig.MaxDBSize; options.MaxLengthyQuery = serviceConfig.MaxLengthyQuery; options.MaxLengthTX = serviceConfig.MaxLengthTX; options.MigrationNFS = serviceConfig.MigrationNFS; options.NodeId = serviceConfig.NodeId; options.Plan = serviceConfig.Plan; options.Uri = new System.Uri(serviceConfig.MBus); options.ZInterval = serviceConfig.ZInterval; options.LocalRoute = serviceConfig.LocalRoute; options.StatusPort = serviceConfig.StatusPort; MSSqlOptions sqlServerOptions = new MSSqlOptions(); sqlServerOptions.Host = serviceConfig.MSSql.Host; sqlServerOptions.User = serviceConfig.MSSql.User; sqlServerOptions.Port = serviceConfig.MSSql.Port; sqlServerOptions.Password = serviceConfig.MSSql.Password; sqlServerOptions.LogicalStorageUnits = serviceConfig.MSSql.LogicalStorageUnits; sqlServerOptions.InitialDataSize = serviceConfig.MSSql.InitialDataSize; sqlServerOptions.InitialLogSize = serviceConfig.MSSql.InitialLogSize; sqlServerOptions.MaxDataSize = serviceConfig.MSSql.MaxDataSize; sqlServerOptions.MaxLogSize = serviceConfig.MSSql.MaxLogSize; sqlServerOptions.DataFileGrowth = serviceConfig.MSSql.DataFileGrowth; sqlServerOptions.LogFileGrowth = serviceConfig.MSSql.LogFileGrowth; this.node = new Node(); this.node.Start(options, sqlServerOptions); }
public VCAPComponent() { this.VarzLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); this.Varz = new Dictionary <string, object>(); this.Discover = new Dictionary <string, object>(); this.ConstructReactor(); this.UUID = Guid.NewGuid().ToString("N"); UhuruSection uhuruSection = (UhuruSection)ConfigurationManager.GetSection("uhuru"); this.Host = NetworkInterface.GetLocalIPAddress(uhuruSection.DEA.LocalRoute); VCAPReactor.Uri = new Uri(uhuruSection.DEA.MessageBus); // http server port this.Port = NetworkInterface.GrabEphemeralPort(); this.Authentication = new string[] { Credentials.GenerateCredential(32), Credentials.GenerateCredential(32) }; }
/// <summary> /// Set the Ms SQL database storage options /// </summary> /// <param name="section"> The Uhuru configuration section</param> private void SetMsSqlStorageOptions(UhuruSection section) { if (!string.IsNullOrEmpty(Context.Parameters[Argument.LogicalStorageUnits])) { section.Service.MSSql.LogicalStorageUnits = Context.Parameters[Argument.LogicalStorageUnits]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.InitialDataSize])) { section.Service.MSSql.InitialDataSize = Context.Parameters[Argument.InitialDataSize]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.InitialLogSize])) { section.Service.MSSql.InitialLogSize = Context.Parameters[Argument.InitialLogSize]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxDataSize])) { section.Service.MSSql.MaxDataSize = Context.Parameters[Argument.MaxDataSize]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxLogSize])) { section.Service.MSSql.MaxLogSize = Context.Parameters[Argument.MaxLogSize]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.DataFileGrowth])) { section.Service.MSSql.DataFileGrowth = Context.Parameters[Argument.DataFileGrowth]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LogFileGrowth])) { section.Service.MSSql.LogFileGrowth = Context.Parameters[Argument.LogFileGrowth]; } }
public VCAPComponent() { this.VarzLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); this.Varz = new Dictionary <string, object>(); this.Discover = new Dictionary <string, object>(); this.ConstructReactor(); this.UUID = Guid.NewGuid().ToString("N"); // Initialize Index from config file if (this.Index != null) { this.UUID = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", this.Index, this.UUID); } this.Host = NetworkInterface.GetLocalIPAddress(UhuruSection.GetSection().DEA.LocalRoute); VCAPReactor.Uri = new Uri(UhuruSection.GetSection().DEA.MessageBus); // http server port this.Port = NetworkInterface.GrabEphemeralPort(); this.Authentication = new string[] { Credentials.GenerateCredential(32), Credentials.GenerateCredential(32) }; }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); string targetDir = Context.Parameters[Arguments.TargetDir].TrimEnd('\\'); string configFile = Path.Combine(targetDir, Assembly.GetExecutingAssembly().Location + ".config"); System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(configFile); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) { return(Assembly.LoadFile(Path.Combine(targetDir, args.Name + ".dll"))); }); UhuruSection section = (UhuruSection)config.GetSection("uhuru"); if (!string.IsNullOrEmpty(Context.Parameters[Arguments.BaseDir])) { section.DEA.BaseDir = Context.Parameters[Arguments.BaseDir]; } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.EnforceUlimit])) { section.DEA.EnforceUsageLimit = Convert.ToBoolean(Context.Parameters[Arguments.EnforceUlimit], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.FilerPort])) { int port = Convert.ToInt32(Context.Parameters[Arguments.FilerPort], CultureInfo.InvariantCulture); section.DEA.FilerPort = port; FirewallTools.OpenPort(port, "DEA FileServer"); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.StatusPort])) { int port = Convert.ToInt32(Context.Parameters[Arguments.StatusPort], CultureInfo.InvariantCulture); section.DEA.StatusPort = port; FirewallTools.OpenPort(port, "DEA Status"); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.ForceHttpSharing])) { section.DEA.ForceHttpSharing = Convert.ToBoolean(Context.Parameters[Arguments.ForceHttpSharing], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.HeartBeatInterval])) { section.DEA.HeartbeatInterval = Convert.ToInt32(Context.Parameters[Arguments.HeartBeatInterval], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.LocalRoute])) { section.DEA.LocalRoute = Context.Parameters[Arguments.LocalRoute]; } else { string ip = string.Empty; foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ip = address.ToString(); break; } } section.DEA.LocalRoute = ip; } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.MaxMemory])) { section.DEA.MaxMemory = Convert.ToInt32(Context.Parameters[Arguments.MaxMemory], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.MessageBus])) { section.DEA.MessageBus = Context.Parameters[Arguments.MessageBus]; } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.MultiTenant])) { section.DEA.Multitenant = Convert.ToBoolean(Context.Parameters[Arguments.MultiTenant], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Arguments.Secure])) { section.DEA.Secure = Convert.ToBoolean(Context.Parameters[Arguments.Secure], CultureInfo.InvariantCulture); } section.Service = null; config.Save(); using (ServerManager serverManager = new ServerManager()) { Microsoft.Web.Administration.Configuration authenticationConfig = serverManager.GetApplicationHostConfiguration(); Microsoft.Web.Administration.ConfigurationSection anonymousAuthenticationSection = authenticationConfig.GetSection("system.webServer/security/authentication/anonymousAuthentication"); anonymousAuthenticationSection["enabled"] = true; anonymousAuthenticationSection["userName"] = string.Empty; anonymousAuthenticationSection["password"] = string.Empty; anonymousAuthenticationSection["logonMethod"] = @"ClearText"; serverManager.CommitChanges(); } }
public void CreateDatabaseTest() { try { Node node = new Node(); Node_Accessor target = new Node_Accessor(new PrivateObject(node)); target.mssqlConfig = new MSSqlOptions(); UhuruSection config = (UhuruSection)ConfigurationManager.GetSection("uhuru"); var po = new PrivateObject(node, new PrivateType(typeof(NodeBase))); NodeBase_Accessor nodebase = new NodeBase_Accessor(po); nodebase.capacity = config.Service.Capacity; target.mssqlConfig.Host = config.Service.MSSql.Host; target.mssqlConfig.User = config.Service.MSSql.User; target.mssqlConfig.Password = config.Service.MSSql.Password; target.mssqlConfig.Port = config.Service.MSSql.Port; target.maxLongQuery = config.Service.MSSql.MaxLengthyQuery; target.mssqlConfig.LogicalStorageUnits = config.Service.MSSql.LogicalStorageUnits; target.mssqlConfig.InitialDataSize = config.Service.MSSql.InitialDataSize; target.mssqlConfig.InitialLogSize = config.Service.MSSql.InitialLogSize; target.mssqlConfig.MaxDataSize = config.Service.MSSql.MaxDataSize; target.mssqlConfig.MaxLogSize = config.Service.MSSql.MaxLogSize; target.mssqlConfig.DataFileGrowth = config.Service.MSSql.DataFileGrowth; target.mssqlConfig.LogFileGrowth = config.Service.MSSql.LogFileGrowth; target.connection = target.ConnectMSSql(); ProvisionedService provisionedService = new ProvisionedService(); DateTime now = DateTime.Now; string decoration = string.Format( "{0}_{1}_{2}", now.Hour, now.Minute, now.Second); provisionedService.Name = "CreateDatabaseTest_" + decoration; provisionedService.User = "******" + decoration; provisionedService.Password = "******"; provisionedService.Plan = "free"; ////////////////////////////////////////////////////////////////////////// // create the provisioned service db and user ////////////////////////////////////////////////////////////////////////// target.CreateDatabase(provisionedService); Thread.Sleep(500); ////////////////////////////////////////////////////////////////////////// // assert the existence of the db files ////////////////////////////////////////////////////////////////////////// string dbScript = target.createDBScript; Regex fnRegex = new Regex(@"FILENAME = N'(.*)'"); MatchCollection matches = fnRegex.Matches(dbScript); foreach (Match m in matches) { string fileName = m.Value.Substring(m.Value.IndexOf('\'')).Trim(new char[] { '\'' }); Assert.IsTrue(File.Exists(fileName), string.Format("File '{0}' does not exist", fileName)); } ////////////////////////////////////////////////////////////////////////// // try to connect as the newly created user ////////////////////////////////////////////////////////////////////////// string sqlTestConnString = string.Format( CultureInfo.InvariantCulture, "Data Source={0},{1};User Id={2};Password={3};MultipleActiveResultSets=true;Pooling=false", target.mssqlConfig.Host, target.mssqlConfig.Port, provisionedService.User, provisionedService.Password); SqlConnection sqlTest = new SqlConnection(sqlTestConnString); sqlTest.Open(); ////////////////////////////////////////////////////////////////////////// // try to connect create a table as the newly created user ////////////////////////////////////////////////////////////////////////// SqlCommand cmdTest = new SqlCommand( string.Format("CREATE TABLE [{0}].[dbo].[TestTable]([Command] [varchar](100) NULL, [Description] [varchar](50) NULL) ON [DATA]", provisionedService.Name), sqlTest); cmdTest.ExecuteNonQuery(); sqlTest.Close(); ////////////////////////////////////////////////////////////////////////// // try to operate on the service db as a different user ////////////////////////////////////////////////////////////////////////// // connect as sa sqlTest.ConnectionString = string.Format( CultureInfo.InvariantCulture, "Data Source={0},{1};User Id={2};Password={3};MultipleActiveResultSets=true;Pooling=false", target.mssqlConfig.Host, target.mssqlConfig.Port, target.mssqlConfig.User, target.mssqlConfig.Password); sqlTest.Open(); string dummyUser = "******" + decoration; string dummyPwd = "password1234!"; //create a dummy user string createLoginString = string.Format(@"CREATE LOGIN {0} WITH PASSWORD = '******'", dummyUser, dummyPwd); cmdTest = new SqlCommand(createLoginString, sqlTest); cmdTest.ExecuteNonQuery(); sqlTest.Close(); // connect as the dummy user sqlTest.ConnectionString = string.Format( CultureInfo.InvariantCulture, "Data Source={0},{1};User Id={2};Password={3};MultipleActiveResultSets=true;Pooling=false", target.mssqlConfig.Host, target.mssqlConfig.Port, dummyUser, dummyPwd); sqlTest.Open(); // try to drop the service db try { cmdTest.CommandText = string.Format("CREATE TABLE [{0}].[dbo].[DummyTable]([Command] [varchar](100) NULL, [Description] [varchar](50) NULL) ON [DATA]", provisionedService.Name); cmdTest.ExecuteNonQuery(); Assert.Fail("Other users have read/write access to the service db"); } catch (SqlException sex) { } ////////////////////////////////////////////////////////////////////////// //Remove database ////////////////////////////////////////////////////////////////////////// ServiceCredentials sc = new ServiceCredentials(); sc.UserName = provisionedService.User; sc.Password = provisionedService.Password; sc.Name = provisionedService.Name; sc.User = provisionedService.User; target.DeleteDatabase(provisionedService); //target.Unprovision(provisionedService.Name, new ServiceCredentials[] { sc }); sqlTest.Close(); target.connection.Close(); } catch (System.Exception ex) { Assert.Fail(ex.Message); } }
public void KillLongTransactionsTest() { Node_Accessor target = new Node_Accessor(); target.mssqlConfig = new MSSqlOptions(); UhuruSection config = (UhuruSection)ConfigurationManager.GetSection("uhuru"); target.mssqlConfig.Host = config.Service.MSSql.Host; target.mssqlConfig.User = config.Service.MSSql.User; target.mssqlConfig.Password = config.Service.MSSql.Password; target.mssqlConfig.Port = config.Service.MSSql.Port; target.maxLongTx = config.Service.MSSql.MaxLengthTX; target.ConnectMSSql(); int queryTime = target.maxLongTx + 5; string longQuery = string.Format(@" DECLARE @startTime datetime2(0) = GETDATE(); WHILE (GETDATE() < DATEADD(SECOND, {0}, @startTime)) BEGIN WAITFOR DELAY '00:00:02'; END", queryTime); DateTime dueQueryCompletion = DateTime.Now.AddSeconds(queryTime); int INDEX_COMPLETED = 0; int INDEX_KILLED = 1; WaitHandle[] events = new WaitHandle[] { new ManualResetEvent(false), new ManualResetEvent(false) }; ThreadPool.QueueUserWorkItem(new WaitCallback( (object o) => { SqlConnection testConnection = new SqlConnection(target.ConnectionString); testConnection.Open(); SqlCommand sqlLongQuery = new SqlCommand(longQuery, testConnection); try { sqlLongQuery.ExecuteNonQuery(); (events[INDEX_COMPLETED] as ManualResetEvent).Set(); } catch (SqlException) { (events[INDEX_KILLED] as ManualResetEvent).Set(); } } )); Thread t = new Thread(new ThreadStart( () => { while (DateTime.Now.CompareTo(dueQueryCompletion) <= 0) { target.KillLongTransactions(); Thread.Sleep(100); } } )); t.Start(); int index = ManualResetEvent.WaitAny(events); if (index == 0) { Assert.Fail("Long query completed without being killed"); } t.Abort(); }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); string targetDir = Context.Parameters[Argument.TargetDir].TrimEnd('\\'); string configFile = Path.Combine(targetDir, Assembly.GetExecutingAssembly().Location + ".config"); System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(configFile); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) { return(Assembly.LoadFile(Path.Combine(targetDir, args.Name + ".dll"))); }); UhuruSection section = (UhuruSection)config.GetSection("uhuru"); this.SetMsSqlStorageOptions(section); if (!string.IsNullOrEmpty(Context.Parameters[Argument.BaseDir])) { section.Service.BaseDir = Context.Parameters[Argument.BaseDir]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Index])) { section.Service.Index = int.Parse(Context.Parameters[Argument.Index], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.StatusPort])) { int port = Convert.ToInt32(Context.Parameters[Argument.StatusPort], CultureInfo.InvariantCulture); section.Service.StatusPort = port; FirewallTools.OpenPort(port, "MsSqlNode Status"); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LocalDb])) { section.Service.LocalDB = Context.Parameters[Argument.LocalDb]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LocalRoute])) { section.Service.LocalRoute = Context.Parameters[Argument.LocalRoute]; } else { string ip = string.Empty; foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ip = address.ToString(); break; } } section.Service.LocalRoute = ip; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxDbSize])) { section.Service.MSSql.MaxDBSize = long.Parse(Context.Parameters[Argument.MaxDbSize], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxLongQuery])) { section.Service.MSSql.MaxLengthyQuery = int.Parse(Context.Parameters[Argument.MaxLongQuery], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxLongTx])) { section.Service.MSSql.MaxLengthTX = int.Parse(Context.Parameters[Argument.MaxLongTx], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Mbus])) { section.Service.MBus = Context.Parameters[Argument.Mbus]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MigrationNfs])) { section.Service.MigrationNFS = Context.Parameters[Argument.MigrationNfs]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.NodeId])) { section.Service.NodeId = Context.Parameters[Argument.NodeId]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.ZInterval])) { section.Service.ZInterval = int.Parse(Context.Parameters[Argument.ZInterval], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Host])) { section.Service.MSSql.Host = Context.Parameters[Argument.Host]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Password])) { section.Service.MSSql.Password = Context.Parameters[Argument.Password]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Port])) { section.Service.MSSql.Port = int.Parse(Context.Parameters[Argument.Port], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.User])) { section.Service.MSSql.User = Context.Parameters[Argument.User]; } section.DEA = null; config.Save(); }
/// <summary> /// Gets the DEA config element. /// </summary> /// <returns>A DEAElement that contains all DEA configuration settings, including the Directory Server.</returns> public static DEAElement ReadConfig() { UhuruSection uhuruSection = (UhuruSection)ConfigurationManager.GetSection("uhuru"); return(uhuruSection.DEA); }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); string targetDir = Context.Parameters[Argument.TargetDir].TrimEnd('\\'); string configFile = Path.Combine(targetDir, Assembly.GetExecutingAssembly().Location + ".config"); System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(configFile); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) { return(Assembly.LoadFile(Path.Combine(targetDir, args.Name + ".dll"))); }); UhuruSection section = (UhuruSection)config.GetSection("uhuru"); if (!string.IsNullOrEmpty(Context.Parameters[Argument.Capacity])) { section.Service.Capacity = int.Parse(Context.Parameters[Argument.Capacity], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.BaseDir])) { section.Service.BaseDir = Context.Parameters[Argument.BaseDir]; if (!Directory.Exists(section.Service.BaseDir)) { Directory.CreateDirectory(section.Service.BaseDir); } } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Index])) { section.Service.Index = int.Parse(Context.Parameters[Argument.Index], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.StatusPort])) { int port = Convert.ToInt32(Context.Parameters[Argument.StatusPort], CultureInfo.InvariantCulture); section.Service.StatusPort = port; if (port != 0) { FirewallTools.OpenPort(port, "FileService Status"); } } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LocalDb])) { section.Service.LocalDB = Context.Parameters[Argument.LocalDb]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LocalRoute])) { section.Service.LocalRoute = Context.Parameters[Argument.LocalRoute]; } else { string ip = string.Empty; foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ip = address.ToString(); break; } } section.Service.LocalRoute = ip; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Mbus])) { section.Service.MBus = Context.Parameters[Argument.Mbus]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MigrationNfs])) { section.Service.MigrationNFS = Context.Parameters[Argument.MigrationNfs]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.NodeId])) { section.Service.NodeId = Context.Parameters[Argument.NodeId]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.ZInterval])) { section.Service.ZInterval = int.Parse(Context.Parameters[Argument.ZInterval], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Plan])) { section.Service.Plan = Context.Parameters[Argument.Plan]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.UseVhd])) { section.Service.Uhurufs.UseVHD = bool.Parse(Context.Parameters[Argument.UseVhd]); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxStorageSize])) { section.Service.Uhurufs.MaxStorageSize = long.Parse(Context.Parameters[Argument.MaxStorageSize], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.VhdFixedSize])) { section.Service.Uhurufs.VHDFixedSize = bool.Parse(Context.Parameters[Argument.VhdFixedSize]); } section.DEA = null; config.Save(); int lowPort = 5000; int highPort = 6000; using (ServerManager serverManager = new ServerManager()) { Microsoft.Web.Administration.Configuration iisConfig = serverManager.GetApplicationHostConfiguration(); Microsoft.Web.Administration.ConfigurationSection firewallSupportSection = iisConfig.GetSection("system.ftpServer/firewallSupport"); firewallSupportSection["lowDataChannelPort"] = lowPort; firewallSupportSection["highDataChannelPort"] = highPort; Microsoft.Web.Administration.ConfigurationSection sitesSection = iisConfig.GetSection("system.applicationHost/sites"); Microsoft.Web.Administration.ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults"); Microsoft.Web.Administration.ConfigurationElement ftpServerElement = siteDefaultsElement.GetChildElement("ftpServer"); Microsoft.Web.Administration.ConfigurationElement firewallSupportElement = ftpServerElement.GetChildElement("firewallSupport"); firewallSupportElement["externalIp4Address"] = @"0.0.0.0"; serverManager.CommitChanges(); } FirewallTools.OpenPortRange(lowPort, highPort, "UhuruFS Ports"); }
/// <summary> /// Initializes a new instance of the <see cref="BackupBase"/> class. /// </summary> protected BackupBase() { this.uhuruSection = (UhuruSection)ConfigurationManager.GetSection("uhuru"); this.shutdown = false; }