Пример #1
0
        private void PublishConDepNode(ServerConfig server, ConDepSettings settings)
        {
            Logger.WithLogSection("Validating ConDepNode", () =>
            {
                string path;

                var executionPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ConDepNode.exe");
                if (!File.Exists(executionPath))
                {
                    var currentPath = Path.Combine(Directory.GetCurrentDirectory(), "ConDepNode.exe");
                    if (!File.Exists(currentPath))
                    {
                        throw new FileNotFoundException("Could not find ConDepNode.exe. Paths tried: \n" +
                                                        executionPath + "\n" + currentPath);
                    }
                    path = currentPath;
                }
                else
                {
                    path = executionPath;
                }

                var nodeUrl = new ConDepNodeUrl(server);

                var nodePublisher = new ConDepNodePublisher(path, Path.Combine(server.GetServerInfo().OperatingSystem.ProgramFilesFolder, "ConDepNode", Path.GetFileName(path)), nodeUrl, new PowerShellExecutor());
                nodePublisher.Execute(server);
                if (!nodePublisher.ValidateNode(nodeUrl, server.DeploymentUser.UserName, server.DeploymentUser.Password, server))
                {
                    throw new ConDepNodeValidationException("Unable to make contact with ConDep Node or return content from API.");
                }

                Logger.Info(string.Format("ConDep Node successfully validated on {0}", server.Name));
                Logger.Info(string.Format("Node listening on {0}", nodeUrl.ListenUrl));
            });
        }
Пример #2
0
        public Api(ConDepNodeUrl url, string userName, string password, int timeoutInMs)
        {
            ServicePointManager.ServerCertificateValidationCallback = ValidateConDepNodeServerCert;

            var messageHandler = new HttpClientHandler { Credentials = new NetworkCredential(userName, password) };
            _client = new HttpClient(messageHandler) { BaseAddress = new Uri(url.RemoteUrl) };
            _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            if(timeoutInMs > 0) _client.Timeout = TimeSpan.FromMilliseconds(timeoutInMs);
        }
        public ConDepNodePublisher(string srcPath, string destPath, ConDepNodeUrl url, PowerShellExecutor psExecutor)
        {
            _srcPath    = srcPath;
            _destPath   = destPath;
            _url        = url;
            _psExecutor = psExecutor;

            //_psExecutor.LoadConDepNodeModule = true;
            //_psExecutor.LoadConDepModule = false;
        }
 public bool ValidateNode(ConDepNodeUrl url, string userName, string password, ServerConfig server)
 {
     var api = new Api(url, userName, password, server.Node.TimeoutInSeconds.Value * 1000);
     if (!api.Validate())
     {
         Thread.Sleep(1000);
         return api.Validate();
     }
     return true;
 }
        public ConDepNodePublisher(string srcPath, string destPath, ConDepNodeUrl url, PowerShellExecutor psExecutor)
        {
            _srcPath = srcPath;
            _destPath = destPath;
            _url = url;
            _psExecutor = psExecutor;

            //_psExecutor.LoadConDepNodeModule = true;
            //_psExecutor.LoadConDepModule = false;
        }
Пример #6
0
        public bool ValidateNode(ConDepNodeUrl url, string userName, string password, ServerConfig server)
        {
            var api = new Node.Api(url, userName, password, server.Node.TimeoutInSeconds.Value * 1000);

            if (!api.Validate())
            {
                Thread.Sleep(1000);
                return(api.Validate());
            }
            return(true);
        }
Пример #7
0
 public ConDepNodePublisher(string srcPath, string destPath, ConDepNodeUrl url)
 {
     _srcPath  = srcPath;
     _destPath = destPath;
     _url      = url;
 }