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); } }); }
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); } }); }
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); }
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); }
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)); }
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); } }
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); }); }); }); }
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); } } }
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 }); } }
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 }; } }
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); }); }
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); }); }
public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress) { var installer = new WindowsInstallerImpl(this.UploadFile); installer.InstallByTicket(ticket, node, localAddress); }
private void ShouldReportIfError(InstallationTicket ticket, Action code) { ErrorWrap(ticket, true, code); }
private void ShouldReport(InstallationTicket ticket, Action code) { ErrorWrap(ticket, false, code); }
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); }
public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress) { //var installer = new WindowsInstallerImpl(); }