public string GetStatus(MachineResource machineResource) { if (IsHealthStatusPendingDeprication) { var status = machineResource.HealthStatus.ToString(); if (machineResource.IsDisabled) status = status + " - Disabled"; return status; } return machineResource.Status.ToString(); }
public void WhenDeletingMachine_ThenDeleteTheMachineFromOctopusServer() { var thisMachine = new MachineResource(); var machineRepo = _container.Resolve<IOctopusRepository>().Machines; machineRepo .FindByName(MachineName) .Returns(thisMachine); _sut.DeleteMachine(); machineRepo .Received() .Delete(thisMachine); }
public void Init() { _ps = Utilities.CreatePowerShell(CmdletName, typeof(GetMachine)); var octoRepo = Utilities.AddOctopusRepo(_ps.Runspace.SessionStateProxy.PSVariable); var machine = new MachineResource {Name = "dbserver-01", Id = "Machines-1"}; var machines = new List<MachineResource> { machine, new MachineResource {Name = "dbserver-02", Id = "Machines-2"} }; octoRepo.Setup(o => o.Machines.FindAll()).Returns(machines); octoRepo.Setup(o => o.Machines.FindByNames(new[] { "dbserver-01" })).Returns(new List<MachineResource> { machine }); octoRepo.Setup(o => o.Machines.FindByNames(new[] { "Gibberish" })).Returns(new List<MachineResource>()); octoRepo.Setup(o => o.Machines.Get("Machines-1")).Returns(machine); octoRepo.Setup(o => o.Machines.Get(It.Is((string s) => s != "Machines-1"))).Throws(new OctopusResourceNotFoundException("Not Found")); }
public MachineResource ModifyMachine(MachineResource machine, string thumbprint, string hostname, int port, IEnumerable<string> environmentNames, IEnumerable<string> roles) { machine.EnvironmentIds.Clear(); var environments = Repository.Environments.FindByNames(environmentNames); foreach (var environment in environments) { machine.EnvironmentIds.Add(environment.Id); } machine.Roles.Clear(); foreach (var role in roles) { machine.Roles.Add(role); } var endpoint = new ListeningTentacleEndpointResource(); endpoint.Uri = $"https://{hostname}:{port}"; endpoint.Thumbprint = thumbprint; machine.Endpoint = endpoint; return Repository.Machines.Modify(machine); }
void ApplyChanges(MachineResource machine, IEnumerable<EnvironmentResource> environment, MachinePolicyResource machinePolicy, IEnumerable<TenantResource> tenants) { machine.EnvironmentIds = new ReferenceCollection(environment.Select(e => e.Id).ToArray()); machine.TenantIds = new ReferenceCollection(tenants.Select(t => t.Id).ToArray()); machine.TenantTags = new ReferenceCollection(TenantTags); machine.Roles = new ReferenceCollection(Roles); machine.Name = MachineName; machine.MachinePolicyId = machinePolicy?.Id; if (CommunicationStyle == CommunicationStyle.TentaclePassive) { var listening = new ListeningTentacleEndpointResource(); listening.Uri = new Uri("https://" + TentacleHostname.ToLowerInvariant() + ":" + TentaclePort.ToString(CultureInfo.InvariantCulture) + "/").ToString(); listening.Thumbprint = TentacleThumbprint; machine.Endpoint = listening; } else if (CommunicationStyle == CommunicationStyle.TentacleActive) { var polling = new PollingTentacleEndpointResource(); polling.Uri = SubscriptionId.ToString(); polling.Thumbprint = TentacleThumbprint; machine.Endpoint = polling; } }
public void DeleteMachine(MachineResource machine) { Repository.Machines.Delete(machine); }
private static OctopusMachineInfo Convert(MachineResource machine) { return new OctopusMachineInfo(machine.Id, machine.Name, machine.IsDisabled); }