@@ -108,6 +108,74 @@ func TestClient_DeployServer_Success(test *testing.T) {
108
108
expect .EqualsString ("serverID" , "7b62aae5-bdbe-4595-b58d-c78f95db2a7f" , serverID )
109
109
}
110
110
111
+ // Deploy uncustomised server (successful).
112
+ func TestClient_DeployUncustomizedServer_Success (test * testing.T ) {
113
+ expect := expect (test )
114
+
115
+ testServer := httptest .NewServer (http .HandlerFunc (func (writer http.ResponseWriter , request * http.Request ) {
116
+ deploymentConfiguration := & UncustomizedServerDeploymentConfiguration {}
117
+ err := readRequestBodyAsJSON (request , deploymentConfiguration )
118
+ if err != nil {
119
+ test .Fatal (err .Error ())
120
+ }
121
+
122
+ verifyDeployUncustomizedServerTestRequest (test , deploymentConfiguration )
123
+
124
+ writer .Header ().Set ("Content-Type" , "application/json" )
125
+ writer .WriteHeader (http .StatusOK )
126
+
127
+ fmt .Fprintln (writer , deployUncustomizedServerTestResponse )
128
+ }))
129
+ defer testServer .Close ()
130
+
131
+ client := NewClientWithBaseAddress (testServer .URL , "user1" , "password" )
132
+ client .setAccount (& Account {
133
+ OrganizationID : "dummy-organization-id" ,
134
+ })
135
+
136
+ serverConfiguration := UncustomizedServerDeploymentConfiguration {
137
+ Name : "Production Server" ,
138
+ Description : "Uncustomized appliance server." ,
139
+ ImageID : "e926545b-1b9c-4068-8cef-076830a9a0bc" ,
140
+ CPU : VirtualMachineCPU {
141
+ Count : 9 ,
142
+ CoresPerSocket : 3 ,
143
+ Speed : "ECONOMY" ,
144
+ },
145
+ MemoryGB : 2 ,
146
+ Network : VirtualMachineNetwork {
147
+ NetworkDomainID : "e926545b-1b9c-4068-8cef-076830a9a0bc" ,
148
+ PrimaryAdapter : VirtualMachineNetworkAdapter {
149
+ PrivateIPv4Address : stringToPtr ("10.0.1.15" ),
150
+ AdapterType : stringToPtr (NetworkAdapterTypeVMXNET3 ),
151
+ },
152
+ AdditionalNetworkAdapters : []VirtualMachineNetworkAdapter {
153
+ VirtualMachineNetworkAdapter {
154
+ VLANID : stringToPtr ("e0b4d43c-c648-11e4-b33a-72802a5322b2" ),
155
+ AdapterType : stringToPtr (NetworkAdapterTypeVMXNET3 ),
156
+ },
157
+ },
158
+ },
159
+ Disks : []VirtualMachineDisk {
160
+ VirtualMachineDisk {
161
+ ID : "d99e4d2a-24c0-4c54-b491-e56697b8f004" ,
162
+ Speed : "ECONOMY" ,
163
+ },
164
+ VirtualMachineDisk {
165
+ ID : "e6a3c0b7-cd32-4224-b8ec-5f1359940204" ,
166
+ Speed : "HIGHPERFORMANCE" ,
167
+ },
168
+ },
169
+ }
170
+
171
+ serverID , err := client .DeployUncustomizedServer (serverConfiguration )
172
+ if err != nil {
173
+ test .Fatal (err )
174
+ }
175
+
176
+ expect .EqualsString ("serverID" , "7b62aae5-bdbe-4595-b58d-c78f95db2a7f" , serverID )
177
+ }
178
+
111
179
// Add disk to server (successful).
112
180
func TestClient_AddServerDisk_Success (test * testing.T ) {
113
181
expect := expect (test )
@@ -417,6 +485,99 @@ func verifyDeployServerTestRequest(test *testing.T, deploymentConfiguration *Ser
417
485
expect .EqualsString ("ServerDeploymentConfiguration.SCSIControllers[0].Disks[1].Speed" , "HIGHPERFORMANCE" , deploymentConfiguration .SCSIControllers [0 ].Disks [1 ].Speed )
418
486
}
419
487
488
+ const deployUncustomizedServerTestRequest = `
489
+ {
490
+ "name": "Production Server",
491
+ "description": "Uncustomized appliance server.",
492
+ "imageId": "e926545b-1b9c-4068-8cef-076830a9a0bc",
493
+ "start": false,
494
+ "cpu": {
495
+ "speed": "ECONOMY",
496
+ "count": "9",
497
+ "coresPerSocket": "3"
498
+ },
499
+ "memoryGb": "2",
500
+ "clusterId": "NA9-01",
501
+ "networkInfo": {
502
+ "networkDomainId": "e926545b-1b9c-4068-8cef-076830a9a0bc",
503
+ "primaryNic": {
504
+ "privateIpv4": "10.0.1.15",
505
+ "networkAdapter": "VMXNET3"
506
+ },
507
+ "additionalNic": [
508
+ {
509
+ "vlanId": "e0b4d43c-c648-11e4-b33a-72802a5322b2",
510
+ "networkAdapter": "VMXNET3"
511
+ }
512
+ ]
513
+ },
514
+ "disk": [
515
+ {
516
+ "id": "d99e4d2a-24c0-4c54-b491-e56697b8f004",
517
+ "speed": "ECONOMY"
518
+ },
519
+ {
520
+ "id": "e6a3c0b7-cd32-4224-b8ec-5f1359940204",
521
+ "speed": "HIGHPERFORMANCE"
522
+ }
523
+ ],
524
+ "tag": [
525
+ {
526
+ "tagKeyName": "department",
527
+ "value": "IT"
528
+ },
529
+ {
530
+ "tagKeyName": "backup",
531
+ "value": "nope"
532
+ }
533
+ ]
534
+ }
535
+ `
536
+
537
+ func verifyDeployUncustomizedServerTestRequest (test * testing.T , deploymentConfiguration * UncustomizedServerDeploymentConfiguration ) {
538
+ expect := expect (test )
539
+
540
+ expect .NotNil ("UncustomizedServerDeploymentConfiguration" , deploymentConfiguration )
541
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Name" , "Production Server" , deploymentConfiguration .Name )
542
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Description" , "Uncustomized appliance server." , deploymentConfiguration .Description )
543
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.ImageID" , "e926545b-1b9c-4068-8cef-076830a9a0bc" , deploymentConfiguration .ImageID )
544
+
545
+ // CPU
546
+ expect .EqualsInt ("UncustomizedServerDeploymentConfiguration.CPU.Count" , 9 , deploymentConfiguration .CPU .Count )
547
+ expect .EqualsInt ("UncustomizedServerDeploymentConfiguration.CPU.CoresPerSocket" , 3 , deploymentConfiguration .CPU .CoresPerSocket )
548
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.CPU.Speed" , "ECONOMY" , deploymentConfiguration .CPU .Speed )
549
+
550
+ // Memory
551
+ expect .EqualsInt ("UncustomizedServerDeploymentConfiguration.MemoryGB" , 2 , deploymentConfiguration .MemoryGB )
552
+
553
+ // Network.
554
+ network := deploymentConfiguration .Network
555
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Network.NetworkDomainID" , "e926545b-1b9c-4068-8cef-076830a9a0bc" , network .NetworkDomainID )
556
+
557
+ expect .IsNil ("UncustomizedServerDeploymentConfiguration.Network.PrimaryAdapter.VLANID" , network .PrimaryAdapter .VLANID )
558
+ expect .NotNil ("UncustomizedServerDeploymentConfiguration.Network.PrimaryAdapter.PrivateIPv4Address" , network .PrimaryAdapter .PrivateIPv4Address )
559
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Network.PrimaryAdapter.PrivateIPv4Address" , "10.0.1.15" , * network .PrimaryAdapter .PrivateIPv4Address )
560
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Network.PrimaryAdapter.AdapterType" , "VMXNET3" , * network .AdditionalNetworkAdapters [0 ].AdapterType )
561
+
562
+ // Network adapters.
563
+ expect .EqualsInt ("UncustomizedServerDeploymentConfiguration.Network.AdditionalNetworkAdapters.Length" , 1 , len (network .AdditionalNetworkAdapters ))
564
+
565
+ expect .NotNil ("UncustomizedServerDeploymentConfiguration.Network.AdditionalNetworkAdapters[0].VLANID" , network .AdditionalNetworkAdapters [0 ].VLANID )
566
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Network.AdditionalNetworkAdapters[0].VLANID" , "e0b4d43c-c648-11e4-b33a-72802a5322b2" , * network .AdditionalNetworkAdapters [0 ].VLANID )
567
+ expect .IsNil ("UncustomizedServerDeploymentConfiguration.Network.AdditionalNetworkAdapters[0].PrivateIPv4Address" , network .AdditionalNetworkAdapters [0 ].PrivateIPv4Address )
568
+ expect .NotNil ("UncustomizedServerDeploymentConfiguration.Network.AdditionalNetworkAdapters[0].AdapterType" , network .AdditionalNetworkAdapters [0 ].AdapterType )
569
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Network.AdditionalNetworkAdapters[0].AdapterType" , "VMXNET3" , * network .AdditionalNetworkAdapters [0 ].AdapterType )
570
+
571
+ // Disks.
572
+ expect .EqualsInt ("UncustomizedServerDeploymentConfiguration.Disks.Length" , 2 , len (deploymentConfiguration .Disks ))
573
+
574
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Disks[0].ID" , "d99e4d2a-24c0-4c54-b491-e56697b8f004" , deploymentConfiguration .Disks [0 ].ID )
575
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Disks[0].Speed" , "ECONOMY" , deploymentConfiguration .Disks [0 ].Speed )
576
+
577
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Disks[1].ID" , "e6a3c0b7-cd32-4224-b8ec-5f1359940204" , deploymentConfiguration .Disks [1 ].ID )
578
+ expect .EqualsString ("UncustomizedServerDeploymentConfiguration.Disks[1].Speed" , "HIGHPERFORMANCE" , deploymentConfiguration .Disks [1 ].Speed )
579
+ }
580
+
420
581
const addDiskToServerTestRequest = `
421
582
{
422
583
"id": "7b62aae5-bdbe-4595-b58d-c78f95db2a7f",
@@ -653,6 +814,23 @@ const deployServerTestResponse = `
653
814
}
654
815
`
655
816
817
+ const deployUncustomizedServerTestResponse = `
818
+ {
819
+ "operation": "DEPLOY_UNCUSTOMIZED_SERVER",
820
+ "responseCode": "IN_PROGRESS",
821
+ "message": "Request to deploy uncustomized Server 'Production Server' has been accepted and is being processed.",
822
+ "info": [
823
+ {
824
+ "name": "serverId",
825
+ "value": "7b62aae5-bdbe-4595-b58d-c78f95db2a7f"
826
+ }
827
+ ],
828
+ "warning": [],
829
+ "error": [],
830
+ "requestId": "na9_20160321T074626030-0400_7e9fffe7-190b-46f2-9107-9d52fe57d0ad"
831
+ }
832
+ `
833
+
656
834
func verifyDeployServerTestResponse (test * testing.T , response * APIResponseV2 ) {
657
835
expect := expect (test )
658
836
0 commit comments