示例#1
0
        private string PopulateGearRepo(string cartName, string softwareVersion, string templateGitUrl)
        {
            ApplicationRepository repo = new ApplicationRepository(this.container);

            if (string.IsNullOrEmpty(templateGitUrl))
            {
                repo.PopulateFromCartridge(cartName);
            }
            else
            {
                repo.PopulateFromUrl(cartName, templateGitUrl);
            }
            if (repo.Exists())
            {
                repo.Archive(Path.Combine(this.container.ContainerDir, "app-root", "runtime", "repo"), "master");
            }

            var prison = Prison.Prison.LoadPrisonNoAttach(PrisonIdConverter.Generate(this.container.Uuid));

            // TODO (vladi): make sure there isn't a more elegant way to deal with SQL Server Instances
            if (cartName == "mssql" && softwareVersion == "2008")
            {
                Uhuru.Prison.MsSqlInstanceTool.ConfigureMsSqlInstanceRegistry(prison, "MSSQL10_50", "MSSQLSERVER");
                CreateSQLServerInstanceDatabases(cartName, prison, "MSSQL10_50", "MSSQLSERVER");
                ChangeConfigControl(cartName, softwareVersion, "MSSQL10_50");
            }
            else if (cartName == "mssql" && softwareVersion == "2012")
            {
                Uhuru.Prison.MsSqlInstanceTool.ConfigureMsSqlInstanceRegistry(prison, "MSSQL11", "MSSQLSERVER2012");
                CreateSQLServerInstanceDatabases(cartName, prison, "MSSQL11", "MSSQLSERVER2012");
                ChangeConfigControl(cartName, softwareVersion, "MSSQL11");
            }

            Logger.Debug("Setting permisions to home dir gear {0}, prison user {1}", this.container.Uuid, prison.User.Username);
            LinuxFiles.TakeOwnershipOfGearHome(this.container.ContainerDir, prison.User.Username);

            string gitDir = Path.Combine(this.container.ContainerDir, "git", "template", ".git");

            Logger.Debug("Setting permisions to git dir {0}, prison user {1}", gitDir, prison.User.Username);
            if (Directory.Exists(gitDir))
            {
                LinuxFiles.TakeOwnership(gitDir, prison.User.Username);
            }

            Logger.Debug("Setting permisions to git dir {0}, prison user {1}", repo.RepositoryPath, prison.User.Username);
            LinuxFiles.TakeOwnership(repo.RepositoryPath, prison.User.Username);

            return(string.Empty);
        }
示例#2
0
        private string PopulateGearRepo(string cartName, string templateGitUrl)
        {
            ApplicationRepository repo = new ApplicationRepository(this.container);

            if (string.IsNullOrEmpty(templateGitUrl))
            {
                repo.PopulateFromCartridge(cartName);
            }
            else
            {
                repo.PopulateFromUrl(cartName, templateGitUrl);
            }
            if (repo.Exists())
            {
                repo.Archive(Path.Combine(this.container.ContainerDir, "app-root", "runtime", "repo"), "master");
            }

            var prison = Prison.Prison.LoadPrisonNoAttach(Guid.Parse(this.container.Uuid.PadLeft(32, '0')));

            // TODO (vladi): make sure there isn't a more elegant way to deal with SQL Server Instances
            if (cartName == "mssql")
            {
                CreateSQLServerInstanceDatabases(cartName, prison);
            }

            Logger.Debug("Setting permisions to home dir gear {0}, prison user {1}", this.container.Uuid, prison.User.Username);
            LinuxFiles.TakeOwnershipOfGearHome(this.container.ContainerDir, prison.User.Username);

            string gitDir = Path.Combine(this.container.ContainerDir, "git", "template", ".git");

            Logger.Debug("Setting permisions to git dir {0}, prison user {1}", gitDir, prison.User.Username);
            if (Directory.Exists(gitDir))
            {
                LinuxFiles.TakeOwnership(gitDir, prison.User.Username);
            }

            Logger.Debug("Setting permisions to git dir {0}, prison user {1}", repo.RepositoryPath, prison.User.Username);
            LinuxFiles.TakeOwnership(repo.RepositoryPath, prison.User.Username);

            return(string.Empty);
        }
示例#3
0
        private void CreateCartridgeDirectory(Manifest cartridge, string softwareVersion)
        {
            string target = Path.Combine(this.container.ContainerDir, cartridge.Dir);

            CartridgeRepository.InstantiateCartridge(cartridge, target);

            string ident = Manifest.BuildIdent(cartridge.CartridgeVendor, cartridge.Name, softwareVersion, cartridge.CartridgeVersion);
            Dictionary <string, string> envs = new Dictionary <string, string>();

            envs[string.Format("{0}_DIR", cartridge.ShortName)]   = target + Path.DirectorySeparatorChar;
            envs[string.Format("{0}_IDENT", cartridge.ShortName)] = ident;
            WriteEnvironmentVariables(Path.Combine(target, "env"), envs);
            envs = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(this.container.Namespace))
            {
                envs["namespace"] = this.container.Namespace;
            }

            Dictionary <string, string> currentGearEnv = Environ.ForGear(this.container.ContainerDir);

            if (!currentGearEnv.ContainsKey("OPENSHIFT_PRIMARY_CARTRIDGE_DIR"))
            {
                envs["PRIMARY_CARTRIDGE_DIR"] = target + Path.DirectorySeparatorChar;
            }
            if (envs.Count > 0)
            {
                WriteEnvironmentVariables(Path.Combine(this.container.ContainerDir, ".env"), envs);
            }

            var prison = Prison.Prison.LoadPrisonNoAttach(PrisonIdConverter.Generate(this.container.Uuid));

            Logger.Debug("Setting permisions to dir {0}, prison user {1}", target, prison.User.Username);

            LinuxFiles.TakeOwnership(target, prison.User.Username);

            Logger.Info("Created cartridge directory {0}/{1}", container.Uuid, cartridge.Dir);
        }