public static ApplicationContainer GetFromUuid(string containerUuid, Hourglass hourglass = null) { EtcUser etcUser = GetPasswdFor(containerUuid); string nameSpace = null; Dictionary <string, string> env = Environ.Load(Path.Combine(etcUser.Dir, ".env")); if (!string.IsNullOrEmpty(env["OPENSHIFT_GEAR_DNS"])) { nameSpace = Regex.Replace(Regex.Replace("testing-uhu.openshift.local", @"\..*$", ""), @"^.*\-", ""); } if (string.IsNullOrEmpty(env["OPENSHIFT_APP_UUID"])) { //Maybe we should improve the exceptions we throw. throw new Exception("OPENSHIFT_APP_UUID is missing!"); } if (string.IsNullOrEmpty(env["OPENSHIFT_APP_NAME"])) { throw new Exception("OPENSHIFT_APP_NAME is missing!"); } if (string.IsNullOrEmpty(env["OPENSHIFT_GEAR_NAME"])) { throw new Exception("OPENSHIFT_GEAR_NAME is missing!"); } ApplicationContainer applicationContainer = new ApplicationContainer(env["OPENSHIFT_APP_UUID"], containerUuid, etcUser, env["OPENSHIFT_APP_NAME"], env["OPENSHIFT_GEAR_NAME"], nameSpace, null, null, hourglass); return(applicationContainer); }
public ApplicationContainer(string applicationUuid, string containerUuid, EtcUser userId, string applicationName, string containerName, string namespaceName, object quotaBlocks, object quotaFiles, Hourglass hourglass, int applicationUid = 0) { this.config = NodeConfig.Values; this.Uuid = containerUuid; this.ApplicationUuid = applicationUuid; this.ApplicationName = applicationName; this.ContainerName = containerName; this.Namespace = namespaceName; this.QuotaBlocks = quotaBlocks; this.QuotaFiles = quotaFiles; this.State = new ApplicationState(this); this.hourglass = hourglass ?? new Hourglass(3600); this.BaseDir = this.config["GEAR_BASE_DIR"]; this.containerPlugin = new ContainerPlugin(this); this.Cartridge = new CartridgeModel(this, this.State, this.hourglass); if (userId != null) { this.uid = userId.Uid; this.gid = userId.Gid; this.gecos = userId.Gecos; } if (applicationUid > 0) { this.uid = applicationUid; } }
public void Test_Etc() { bool testresults = true; try { NodeConfig config = new NodeConfig(); Etc etcobj = new Etc(config); if (etcobj.GetAllUsers().Count() > 0) { EtcUser user = etcobj.GetAllUsers().FirstOrDefault(); if (etcobj.GetPwanam(user.Name) == null) { testresults = false; } } } catch { testresults = false; } Assert.AreEqual(true, testresults); }