/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { VlanIdOrPrivateIpType primaryNic = new VlanIdOrPrivateIpType { vlanId = PrimaryNetwork.id, privateIpv4 = PrimaryPrivateIp }; var server = new DeployServerType { name = Name, description = Description, imageId = ServerImage.id, start = IsStarted, administratorPassword = AdminPassword, networkInfo = new DeployServerTypeNetworkInfo { networkDomainId = NetworkDomain.id, primaryNic = primaryNic } }; response = Connection.ApiClient.DeployServerOnNetworkDomain(server).Result; } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { // if (e is HttpRequestException) ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return true; }); } WriteObject(response); }
/// <summary> /// This function deploys a new network domains to Cloud /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="server"> /// The network Domain. /// </param> /// <returns> /// Response containing status. /// </returns> public static async Task<ResponseType> DeployServerOnNetworkDomain(this IComputeApiClient client, DeployServerType server) { var response = await client.WebApi.PostAsync<DeployServerType, ResponseType>(ApiUris.DeployServerOnNetworkDomain(client.WebApi.OrganizationId), server); return response; }