Пример #1
0
        public void InstallByNodeName(string farmName, InstallationTicket ticket)
        {
            Resource[] resources = ResourceBase.GetAllResources();

            var resource =
                resources.First(x => (farmName == null? true: x.Controller.FarmId == farmName) &&
                                x.ResourceName == ticket.ResourceName &&
                                x.Nodes.Any(y => y.NodeName == ticket.NodeName)
                                );

            if (resource == null)
            {
                throw new InvalidDataException(string.Format("Node wasn't found with FarmName: {0}, ResourceName: {1}, NodeName: {2}", farmName, ticket.ResourceName, ticket.NodeName));
            }

            Common.Utility.ExceptionablePlaceWrapper(() =>
            {
                var address = resource.Controller.Url + "PackageInstaller";

                using (var client = PackageFactoryImpl.GetInstallationServiceClient(address))
                {
                    client.InstallPackage(ticket);
                }
            });
        }
Пример #2
0
        public void InstallByNodeName(string farmName, InstallationTicket ticket)
        {
            Resource[] resources = ResourceBase.GetAllResources();

            var resource =
                resources.First(x => (farmName==null? true: x.Controller.FarmId == farmName)
                                        && x.ResourceName == ticket.ResourceName
                                        && x.Nodes.Any(y => y.NodeName == ticket.NodeName)
                                );

            if (resource == null)
            {
                throw new InvalidDataException(string.Format("Node wasn't found with FarmName: {0}, ResourceName: {1}, NodeName: {2}", farmName, ticket.ResourceName, ticket.NodeName));
            }

            Common.Utility.ExceptionablePlaceWrapper(() =>
            {
                var address = resource.Controller.Url + "PackageInstaller";

                using (var client = PackageFactoryImpl.GetInstallationServiceClient(address))
                {
                    client.InstallPackage(ticket);
                }
            });
        }
Пример #3
0
 private void ReportResult(InstallationTicket ticket, Exception error)
 {
     Common.Utility.ExceptionablePlaceWrapper(() =>
     {
         InstallationUtility.ReportResult(ticket.BackAddress, createResult(ticket, error));
     }, string.Format("Failed to report, BackAddress: {0}", ticket.BackAddress),
                                              string.Format("Succeseded to report, BackAddress: {0}", ticket.BackAddress), false);
 }
Пример #4
0
        public void InstallPackage(InstallationTicket ticket)
        {
            Common.Utility.ExceptionablePlaceWrapper(() =>
            {
                var resource = ResourceCache.GetByName(ticket.ResourceName);

                InstallationUtility.RouteToController(resource, ticket);
            }, "Error at installation start. TicketId: " + ticket.Id, "Installation start was successful. TicketId: " + ticket.Id);
        }
Пример #5
0
        public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress)
        {
            var fileName = Path.GetFileName(localAddress);
            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(localAddress);
            var remotePath = Path.Combine(ticket.FolderToInstall, fileName).Replace('\\', '/');

            this.UploadFile(node, remotePath, localAddress);

            string result = SshExec(node,
                                    string.Format(SshInstallationCommand.InstallUploadedPackage, remotePath, ticket.FolderToInstall, fileNameWithoutExtension));
        }
Пример #6
0
        public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress)
        {
            var farmId   = ResourceCache.GetByName(node.ResourceName).Resource.Controller.FarmId;
            var fileName = Path.GetFileName(localAddress);

            var uri = new Uri(ticket.StorageAddress);

            var taskId = string.Format("{0}.{1}.{2}", uri.Host, uri.LocalPath,
                                       String.Format("{0:dd/MM/yyyy_HH-mm-ss}", DateTime.Now));

            this._uploadFile(node, fileName, localAddress, taskId, farmId);

            using (var client = GetInstallationServiceClient(node))
            {
                ticket.FolderToInstall = client.InstallPackage(farmId, taskId, fileName);
            }
        }
Пример #7
0
        public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress)
        {
            var farmId = ResourceCache.GetByName(node.ResourceName).Resource.Controller.FarmId;
            var fileName = Path.GetFileName(localAddress);

            var uri = new Uri(ticket.StorageAddress);

            var taskId = string.Format("{0}.{1}.{2}", uri.Host, uri.LocalPath,
                    String.Format("{0:dd/MM/yyyy_HH-mm-ss}", DateTime.Now));

            this._uploadFile(node, fileName, localAddress, taskId, farmId);

            using (var client = GetInstallationServiceClient(node))
            {
                ticket.FolderToInstall = client.InstallPackage(farmId, taskId, fileName);
            }
        }
Пример #8
0
        private void Install(InstallationTicket ticket, ResourceNode node, IInstallationController controller)
        {
            ShouldReportIfError(ticket, () =>
            {
                _packageObtainer.ObtainPackage(ticket.StorageAddress, (address, error) =>
                {
                    if (error != null)
                    {
                        ReportResult(ticket, error);
                        return;
                    }

                    ShouldReport(ticket, () =>
                    {
                        controller.InstallByTicket(ticket, node, address);
                    });
                });
            });
        }
Пример #9
0
        private void ErrorWrap(InstallationTicket ticket, bool onlyIfError, Action code)
        {
            Exception exception = null;

            try
            {
                code();
            }
            catch (Exception ex)
            {
                Common.Utility.LogError(
                    string.Format("Exception occured while installing to node:{0}", ticket.NodeName), ex);
                exception = ex;
            }
            finally
            {
                if (!onlyIfError || exception != null)
                {
                    ReportResult(ticket, exception);
                }
            }
        }
Пример #10
0
 private TicketResult createResult(InstallationTicket ticket, Exception error)
 {
     if (error != null)
     {
         Common.Utility.LogError(string.Format(" Error occured while trying to install package. PackageAddress: {0},  ResourceName: {1}, NodeName: {2}, Exception: {3}, ticketId: {4}",
                                               ticket.StorageAddress, ticket.ResourceName, ticket.NodeName, error, ticket.Id));
         return(new TicketResult()
         {
             IsSuccessful = false,
             OccuredException =
                 new Exception(
                     "Installation to node: " + ticket.NodeName +
                     " was failed"),
             TicketId = ticket.Id,
             FolderToInstall = ticket.FolderToInstall,
             PackageName = ticket.PackageName,
             VersionName = ticket.VersionName,
             ResourceName = ticket.ResourceName,
             NodeName = ticket.NodeName
         });
     }
     else
     {
         Common.Utility.LogInfo(string.Format(" Installation was succesful. PackageAddress: {0}, ResourceName: {1}, NodeName: {2}, ticketId: {3}",
                                              ticket.StorageAddress, ticket.ResourceName, ticket.NodeName, ticket.Id));
         return(new TicketResult()
         {
             IsSuccessful = true,
             OccuredException = null,
             TicketId = ticket.Id,
             FolderToInstall = ticket.FolderToInstall,
             PackageName = ticket.PackageName,
             VersionName = ticket.VersionName,
             ResourceName = ticket.ResourceName,
             NodeName = ticket.NodeName
         });
     }
 }
Пример #11
0
 private TicketResult createResult(InstallationTicket ticket, Exception error)
 {
     if (error != null)
     {
         Common.Utility.LogError(string.Format(" Error occured while trying to install package. PackageAddress: {0},  ResourceName: {1}, NodeName: {2}, Exception: {3}, ticketId: {4}",
                                                        ticket.StorageAddress, ticket.ResourceName, ticket.NodeName, error, ticket.Id));
         return new TicketResult()
         {
             IsSuccessful = false,
             OccuredException =
                 new Exception(
                     "Installation to node: " + ticket.NodeName +
                     " was failed"),
             TicketId = ticket.Id,
             FolderToInstall = ticket.FolderToInstall,
             PackageName = ticket.PackageName,
             VersionName = ticket.VersionName,
             ResourceName = ticket.ResourceName,
             NodeName = ticket.NodeName
         };
     }
     else
     {
         Common.Utility.LogInfo(string.Format(" Installation was succesful. PackageAddress: {0}, ResourceName: {1}, NodeName: {2}, ticketId: {3}",
                                                         ticket.StorageAddress, ticket.ResourceName, ticket.NodeName, ticket.Id));
         return new TicketResult()
         {
             IsSuccessful = true,
             OccuredException = null,
             TicketId = ticket.Id,
             FolderToInstall = ticket.FolderToInstall,
             PackageName = ticket.PackageName,
             VersionName = ticket.VersionName,
             ResourceName = ticket.ResourceName,
             NodeName = ticket.NodeName
         };
     }
 }
Пример #12
0
        public void InstallByTicket(Resource resource, InstallationTicket ticket, IInstallationController controller)
        {
            var nodes = resource.Nodes.Where(x => x.NodeName == ticket.NodeName);

            if (nodes.Count() > 1)
            {
                var message = string.Format("Several nodes was founded with given NodeName: {0}. Use first. TicketId: {1} ", ticket.NodeName, ticket.Id);
                Common.Utility.LogWarn(message);
            }
            else if (!nodes.Any())
            {
                var message = string.Format("Node with given NodeName: {0} wasn't founded. TicketId: {1}", ticket.NodeName, ticket.Id);
                Common.Utility.LogError(message);
                ReportResult(ticket, new InvalidDataException(message));
            }

            var node = nodes.First();

            Task.Factory.StartNew(() =>
            {
                Install(ticket,node,controller);
            });
        }
Пример #13
0
        public void InstallByTicket(Resource resource, InstallationTicket ticket, IInstallationController controller)
        {
            var nodes = resource.Nodes.Where(x => x.NodeName == ticket.NodeName);

            if (nodes.Count() > 1)
            {
                var message = string.Format("Several nodes was founded with given NodeName: {0}. Use first. TicketId: {1} ", ticket.NodeName, ticket.Id);
                Common.Utility.LogWarn(message);
            }
            else if (!nodes.Any())
            {
                var message = string.Format("Node with given NodeName: {0} wasn't founded. TicketId: {1}", ticket.NodeName, ticket.Id);
                Common.Utility.LogError(message);
                ReportResult(ticket, new InvalidDataException(message));
            }

            var node = nodes.First();

            Task.Factory.StartNew(() =>
            {
                Install(ticket, node, controller);
            });
        }
Пример #14
0
        public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress)
        {
            var installer = new WindowsInstallerImpl(this.UploadFile);

            installer.InstallByTicket(ticket, node, localAddress);
        }
Пример #15
0
 private void ErrorWrap(InstallationTicket ticket, bool onlyIfError, Action code)
 {
     Exception exception = null;
     try
     {
         code();
     }
     catch (Exception ex)
     {
         Common.Utility.LogError(
                 string.Format("Exception occured while installing to node:{0}", ticket.NodeName), ex);
         exception = ex;
     }
     finally
     {
         if (!onlyIfError || exception != null)
         {
             ReportResult(ticket, exception);
         }
     }
 }
Пример #16
0
 private void ShouldReportIfError(InstallationTicket ticket, Action code)
 {
     ErrorWrap(ticket, true, code);
 }
Пример #17
0
 private void ShouldReport(InstallationTicket ticket, Action code)
 {
     ErrorWrap(ticket, false, code);
 }
Пример #18
0
 private void ReportResult(InstallationTicket ticket, Exception error)
 {
     Common.Utility.ExceptionablePlaceWrapper(() =>
     {
        InstallationUtility.ReportResult(ticket.BackAddress,createResult(ticket,error));
     }, string.Format("Failed to report, BackAddress: {0}", ticket.BackAddress),
        string.Format("Succeseded to report, BackAddress: {0}", ticket.BackAddress), false);
 }
Пример #19
0
        private void Install(InstallationTicket ticket, ResourceNode node, IInstallationController controller)
        {
            ShouldReportIfError(ticket, () =>
            {
                _packageObtainer.ObtainPackage(ticket.StorageAddress, (address, error) =>
                {
                    if (error != null)
                    {
                        ReportResult(ticket, error);
                        return;
                    }

                    ShouldReport(ticket, () =>
                    {
                        controller.InstallByTicket(ticket, node, address);
                    });

                });
            });
        }
Пример #20
0
 private void ShouldReportIfError(InstallationTicket ticket, Action code)
 {
     ErrorWrap(ticket, true, code);
 }
Пример #21
0
 private void ShouldReport(InstallationTicket ticket, Action code)
 {
     ErrorWrap(ticket, false, code);
 }
Пример #22
0
 public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress)
 {
     //var installer = new WindowsInstallerImpl();
 }