public static ApplicationContainer GetFromUuid(string containerUuid, Hourglass hourglass = null)
        {
            EtcUser etcUser   = GetPasswdFor(containerUuid);
            string  nameSpace = null;
            Dictionary <string, string> env = Environ.Load(Path.Combine(LinuxFiles.Cygpath(etcUser.Dir, true), ".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);
        }
示例#2
0
 private void CheckUsers()
 {
     VerboseMessage(string.Format("checking {0} user accounts", users.Length));
     foreach (EtcUser user in users)
     {
         if (!Directory.Exists(LinuxFiles.Cygpath(user.Dir, true)))
         {
             DoFail(string.Format("user {0} does not have a home directory {1}", user.Name, user.Dir));
         }
     }
 }
示例#3
0
        private static void Extract(string method, string source, string target)
        {
            // use intermediate temp directory to reset cygwin directories ACLs
            string tempPath = target + ".temp";

            Directory.CreateDirectory(tempPath);
            Path.Combine(NodeConfig.Values["SSHD_BASE_DIR"], @"bin\tar.exe");
            Logger.Debug("Extracting {0} to {2} using {1} method", source, method, target);
            switch (method)
            {
            case "zip":
            {
                ZipFile.ExtractToDirectory(source, tempPath);
                break;
            }

            case "tgz":
            {
                ProcessResult result = ProcessExtensions.RunCommandAndGetOutput(Path.Combine(NodeConfig.Values["SSHD_BASE_DIR"], @"bin\tar.exe"), string.Format("-C {0} -zxpf {1}", LinuxFiles.Cygpath(tempPath), LinuxFiles.Cygpath(source)));
                Logger.Debug(result.StdOut + result.StdErr);
                break;
            }

            case "tar":
            {
                ProcessResult result = ProcessExtensions.RunCommandAndGetOutput(Path.Combine(NodeConfig.Values["SSHD_BASE_DIR"], @"bin\tar.exe"), string.Format("-C {0} -xpf {1}", LinuxFiles.Cygpath(tempPath), LinuxFiles.Cygpath(source)));
                Logger.Debug(result.StdOut + result.StdErr);
                break;
            }

            default:
            {
                throw new Exception(string.Format("Packaging method {0} not yet supported.", method));
            }
            }

            DirectoryUtil.DirectoryCopy(tempPath, target, true);
            Directory.Delete(tempPath, true);

            string[] files = Directory.GetFileSystemEntries(target);
            if (files.Length == 1)
            {
                Logger.Debug(string.Join(",", files));
                // A directory of one file is not legal move everyone up a level (github zip's are this way)
                string to_delete = files[0] + ".to_delete";
                Directory.Move(files[0], to_delete);
                DirectoryUtil.DirectoryCopy(to_delete, target, true);
                Directory.Delete(to_delete);
            }
        }