예제 #1
0
        public Depends(ContainerType type)
        {
            _containerType = type;
            if (EnableDocker)
            {
                using (var client = new WebClientWithExtendedTimeout
                {
                    Credentials = CredentialCache.DefaultNetworkCredentials
                })
                {
                    string result        = "";
                    string containerType = ConvertToString(_containerType);
                    string address       = $"http://{RigOpsIP}:3142/public/Container/Async/Start/{containerType}.json";
                    var    retryCount    = 0;
                    do
                    {
                        result    = client.DownloadString(address);
                        Container = JsonConvert.DeserializeObject <Container>(result);
                    } while (string.IsNullOrEmpty(Container.Port) && retryCount++ < 10);

                    if (string.IsNullOrEmpty(Container.Port))
                    {
                        throw new Exception($"Container for {containerType} type dependency not found.");
                    }

                    Container.IP = RigOpsIP;
                }
            }

            switch (_containerType)
            {
            case ContainerType.MySQL:
                InjectMySQLContainer(EnableDocker);
                break;

            case ContainerType.MSSQL:
                InjectMSSQLContainer(EnableDocker);
                break;

            case ContainerType.RabbitMQ:
                InjectRabbitMQContainer(EnableDocker);
                break;

            case ContainerType.CIRemote:
                InjectCIRemoteContainer(EnableDocker);
                break;

            case ContainerType.PostGreSQL:
                InjectPostGreSQLContainer(EnableDocker);
                break;
            }
        }
예제 #2
0
        public Depends(ContainerType type, bool performSourceInjection = true)
        {
            _containerType = type;
            if (EnableRigOpsWorkflows)
            {
                using (var client = new WebClientWithExtendedTimeout
                {
                    Credentials = CredentialCache.DefaultNetworkCredentials
                })
                {
                    var result       = "";
                    var retryCount   = 0;
                    var containerUrl = GitURL(_containerType);
                    do
                    {
                        SelectedHost = RigOpsHosts.ElementAt(retryCount);
                        var address = $"http://{SelectedHost}:3142/public/Container/Run%20From%20Git.json?RepoURL={containerUrl}&ScriptPath={(_containerType==ContainerType.Warewolf?"Dev%5CDev2.Server%5CDockerfile.deploy.bat":"")}";
                        try
                        {
                            result = client.DownloadString(address);
                        }
                        catch (WebException)
                        {
                            //Retry another Rig Ops host
                        }
                        if (result == "" || result.Contains("\"ID\": \"\""))
                        {
                            retryCount++;
                        }
                        else
                        {
                            retryCount = RigOpsHosts.Count;
                        }
                    } while (retryCount < RigOpsHosts.Count);

                    Container = JsonConvert.DeserializeObject <Container>(result) ?? new Container();

                    if (!int.TryParse(Container.Port, out _))
                    {
                        Container.Port = GetBackupPort(_containerType);
                    }

                    Container.IP = SelectedHost;
                }
            }
            else
            {
                Container = new Container()
                {
                    IP   = BackupServer,
                    Port = GetBackupPort(_containerType)
                };
            }

            if (!performSourceInjection)
            {
                return;
            }
            switch (_containerType)
            {
            case ContainerType.MySQL:
                InjectMySQLContainer();
                break;

            case ContainerType.MSSQL:
                InjectMSSQLContainer();
                break;

            case ContainerType.RabbitMQ:
                InjectRabbitMQContainer();
                break;

            case ContainerType.CIRemote:
                InjectCIRemoteContainer();
                break;

            case ContainerType.PostGreSQL:
                InjectPostGreSQLContainer();
                break;

            case ContainerType.AnonymousElasticsearch:
                InjectElasticContainer();
                break;

            case ContainerType.WebApi:
                InjectWebApiContainer();
                break;
            }
        }
예제 #3
0
        public Depends(ContainerType type)
        {
            _containerType = type;
            if (EnableDocker)
            {
                using (var client = new WebClientWithExtendedTimeout
                {
                    Credentials = CredentialCache.DefaultNetworkCredentials
                })
                {
                    var result        = "";
                    var retryCount    = 0;
                    var containerType = ConvertToString(_containerType);
                    do
                    {
                        SelectedHost = RigOpsHosts.ElementAt(retryCount);
                        var address = $"http://{SelectedHost}:3142/public/Container/Async/Start/{containerType}.json";
                        try
                        {
                            result = client.DownloadString(address);
                        }
                        catch (WebException)
                        {
                            //Retry another Rig Ops host
                        }
                        if (result == "" || result.Contains("\"IP\": \"\""))
                        {
                            retryCount++;
                        }
                        else
                        {
                            retryCount = RigOpsHosts.Count;
                        }
                    } while (retryCount < RigOpsHosts.Count);

                    Container = JsonConvert.DeserializeObject <Container>(result) ?? new Container();

                    if (!int.TryParse(Container.Port, out _))
                    {
                        Container.Port = GetBackupPort(_containerType);
                    }

                    Container.IP = SelectedHost;
                }
            }
            else
            {
                Container.IP   = BackupServer;
                Container.Port = GetBackupPort(_containerType);
            }

            switch (_containerType)
            {
            case ContainerType.MySQL:
                InjectMySQLContainer(EnableDocker);
                break;

            case ContainerType.MSSQL:
                InjectMSSQLContainer(EnableDocker);
                break;

            case ContainerType.RabbitMQ:
                InjectRabbitMQContainer(EnableDocker);
                break;

            case ContainerType.CIRemote:
                InjectCIRemoteContainer(EnableDocker);
                break;

            case ContainerType.PostGreSQL:
                InjectPostGreSQLContainer(EnableDocker);
                break;

            case ContainerType.AnonymousElasticsearch:
                InjectElasticContainer(EnableDocker);
                break;
            }
        }