/// <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); }
public IList <MachineCreationResult> CreateMachines(ConnectionSettings connectionSettings, HostingSettings hostingSettings, ProvisioningSettings provisioningSettings, IList <MachineCreationRequest> machineCreationRequests) { // Just log to prove that we got here, but no implementation as yet. logger.TraceMsg("An instance creation request has been received!"); var client = connectionSettings.GetComputeClient(); List <MachineCreationResult> results = new List <MachineCreationResult>(); foreach (var request in machineCreationRequests) { /// Something kinda like this... DeployServerType details = new DeployServerType { // Provision the VM into the default network domain and VLAN networkInfo = new DeployServerTypeNetworkInfo { networkDomainId = GetNetworkDomainId(connectionSettings).ToString(), primaryNic = new VlanIdOrPrivateIpType { vlanId = GetVlanId(connectionSettings).ToString() } }, administratorPassword = "******", imageId = GetDefaultImageId(connectionSettings), cpu = new DeployServerTypeCpu { coresPerSocket = _defaultCoresPerSocket, coresPerSocketSpecified = true, count = _defaultCpuCount, countSpecified = true, speed = "STANDARD" // TODO : Make this configurable }, description = "Provisioned by Citrix", name = request.MachineName }; var response = client.ServerManagement.Server.DeployServer(details).Result; // This isn't correct. but an indication of how it's done. results.Add(new MachineCreationResult(response.info[0].value, response.info[0].value, null)); } return(results); }
/// <summary>Deploys a server to MCP1.0 or MCP 2.0 data centers </summary> /// <param name="serverDetails">Details of the server to be deployed</param> /// <returns>Response containing the server id</returns> public async Task <ResponseType> DeployServer(DeployServerType serverDetails) { return(await _apiClient.PostAsync <DeployServerType, ResponseType>( ApiUris.DeployMCP20Server(_apiClient.OrganizationId), serverDetails)); }
/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { Api.Contracts.Network20.ServerType deployedServer = null; base.ProcessRecord(); try { var primaryNic = new NewNicType { vlanId = PrimaryVlan != null ? PrimaryVlan.id : null, privateIpv4 = PrimaryPrivateIp, connected = PrimaryNicConnected.Value, connectedSpecified = PrimaryNicConnected.HasValue }; var server = new DeployServerType { name = Name, description = Description, imageId = ServerImage.id, start = IsStarted, administratorPassword = AdminPassword, networkInfo = new DeployServerTypeNetworkInfo { networkDomainId = NetworkDomain.id, primaryNic = primaryNic } }; var response = Connection.ApiClient.ServerManagement.Server.DeployServer(server).Result; // get the server id from status message var serverInfo = response.info.Single(info => info.name == "serverId"); if (serverInfo != null) { deployedServer = Connection.ApiClient.ServerManagement.Server.GetServer(Guid.Parse(serverInfo.value)).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); }); } if (PassThru.IsPresent) { WriteObject(deployedServer); } }
/// <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); }
/// <summary> /// The deploy server task. /// </summary> /// <returns> /// The <see cref="ServerType" />. /// </returns> private Api.Contracts.Network20.ServerType DeployServerTask() { Api.Contracts.Network20.ServerType deployedServer = null; DeployServerTypeNetwork networkInfo = null; DeployServerTypeNetworkInfo networkDomainInfo = null; if (ServerDetails.NetworkDomain != null) { networkDomainInfo = new DeployServerTypeNetworkInfo { networkDomainId = ServerDetails.NetworkDomain.id, primaryNic = new NewNicType { vlanId = ServerDetails.PrimaryVlan != null ? ServerDetails.PrimaryVlan.id : null, privateIpv4 = ServerDetails.PrivateIp, connected = ServerDetails.PrimaryNicConnected != null ? ServerDetails.PrimaryNicConnected.Value : true, connectedSpecified = ServerDetails.PrimaryNicConnected.HasValue } }; } else { networkInfo = new DeployServerTypeNetwork { networkId = ServerDetails.Network != null ? ServerDetails.Network.id : null, privateIpv4 = ServerDetails.PrivateIp }; } // convert CaasServerDiskDetails to Disk[] DeployServerTypeDisk[] diskarray = null; if (ServerDetails.InternalDiskDetails != null && ServerDetails.InternalDiskDetails.Count > 0) { var disks = new List <DeployServerTypeDisk>(); foreach (CaasServerDiskDetails item in ServerDetails.InternalDiskDetails) { var disk = new DeployServerTypeDisk { id = item.DiskId, speed = item.SpeedId }; disks.Add(disk); } diskarray = disks.ToArray(); } ResponseType response = null; if (GuestOsCustomization.HasValue && GuestOsCustomization == false) { var server = new DeployUncustomizedServerType { name = ServerDetails.Name, description = ServerDetails.Description, imageId = ServerDetails.ImageId, start = ServerDetails.IsStarted, networkInfo = networkDomainInfo, disk = diskarray, cpu = ServerDetails.CpuDetails, memoryGb = ServerDetails.MemoryGb, memoryGbSpecified = (ServerDetails.MemoryGb > 0), clusterId = ServerDetails.ClusterId }; response = Connection.ApiClient.ServerManagement.Server.DeployUncustomizedServer(server).Result; } else { var server = new DeployServerType { name = ServerDetails.Name, description = ServerDetails.Description, imageId = ServerDetails.ImageId, start = ServerDetails.IsStarted, administratorPassword = ServerDetails.AdministratorPassword, network = networkInfo, networkInfo = networkDomainInfo, disk = diskarray, cpu = ServerDetails.CpuDetails, primaryDns = ServerDetails.PrimaryDns, secondaryDns = ServerDetails.SecondaryDns, microsoftTimeZone = ServerDetails.MicrosoftTimeZone, memoryGb = ServerDetails.MemoryGb, memoryGbSpecified = (ServerDetails.MemoryGb > 0), clusterId = ServerDetails.ClusterId }; response = Connection.ApiClient.ServerManagement.Server.DeployServer(server).Result; } // get the server id from status message var serverInfo = response.info.Single(info => info.name == "serverId"); if (serverInfo != null) { deployedServer = Connection.ApiClient.ServerManagement.Server.GetServer(Guid.Parse(serverInfo.value)).Result; } if (response != null) { WriteDebug( string.Format( "{0} resulted in {1} ({2}): requestId: {3}", response.operation, response.responseCode, response.message, response.requestId)); } return(deployedServer); }