/// <summary> /// Override to Task.Execute to run custom process for gathering data on a server instance running within RightScale /// </summary> /// <returns></returns> public override bool Execute() { bool retVal = false; Log.LogMessage(" GetInstanceInfo.Execute - beginning at " + DateTime.Now.ToString()); ValidateInputs(); if (RightScale.netClient.Core.APIClient.Instance.Authenticate(this.OAuthRefreshToken).Result) { RightScale.netClient.Server server = RightScale.netClient.Server.show(this.ServerID, "instance_detail"); if (server.current_instance != null) { RightScale.netClient.Instance currentInstance = server.current_instance; this.PrivateIPAddresses = currentInstance.private_ip_addresses; this.PublicIPAddresses = currentInstance.public_ip_addresses; this.CreatedAt = currentInstance.created_at; this.UpdatedAt = currentInstance.updated_at; this.Name = currentInstance.name; this.ResourceUid = currentInstance.resource_uid; this.State = currentInstance.state; this.OSPlatform = currentInstance.os_platform; this.PrivateDNSNames = currentInstance.private_dns_names; this.InstanceID = currentInstance.ID; } } else { Log.LogMessage(" Cannot authenticate to RSAPI"); } Log.LogMessage(" GetInstanceInfo.Execute - complete at " + DateTime.Now.ToString()); return(retVal); }
/// <summary> /// Override to Execute method refreshes the application as defined by inputs /// </summary> /// <returns>True if successful, false if not</returns> public override bool Execute() { Log.LogMessage("RefreshApplication process starting"); bool retVal = false; ValidateInputs(); if (RightScale.netClient.Core.APIClient.Instance.Authenticate(this.OAuthRefreshToken).Result) { Log.LogMessage(" RSAPI is authenticated"); RightScale.netClient.Server deployServer = RightScale.netClient.Server.show(this.ServerID); if (deployServer == null) { Log.LogError("deployServer object not found for server ID specified (" + this.ServerID + ")."); } Log.LogMessage(" DeloyServer is populated"); List <KeyValuePair <string, string> > inputs = buildInputs(); Log.LogMessage(" Inputs for refresh process built"); RightScale.netClient.Instance instance = deployServer.currentInstance; if (instance != null) { Log.LogMessage(" Beginning run_rightscript"); RightScale.netClient.Instance curr_instance = RightScale.netClient.Server.show(this.ServerID).currentInstance; RightScale.netClient.Task task = RightScale.netClient.Instance.run_rightScript(curr_instance.cloud.ID, curr_instance.ID, this.RightScriptID, inputs); if (task != null) { retVal = true; Log.LogMessage(" multi_run_executable queued successfully"); } Log.LogMessage(" Complete multi_run_executable"); } else { Log.LogError("There is no current instance to deploy to for server ID specified (" + this.ServerID + ")."); } } Log.LogMessage("RefreshApplication Execute Complete"); return(retVal); }