-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathCloudStackClient.php
More file actions
2810 lines (2392 loc) · 104 KB
/
Copy pathCloudStackClient.php
File metadata and controls
2810 lines (2392 loc) · 104 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* This file is part of the CloudStack PHP Client.
*
* (c) Quentin Pleplé <quentin.pleple@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . "/BaseCloudStackClient.php";
require_once dirname(__FILE__) . "/CloudStackClientException.php";
class CloudStackClient extends BaseCloudStackClient {
/**
* Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.
*
* @param string $serviceOfferingId the ID of the service offering for the virtual
* machine
* @param string $templateId the ID of the template for the virtual machine
* @param string $zoneId availability zone for the virtual machine
* @param string $account an optional account for the virtual machine. Must be used
* with domainId.
* @param string $diskOfferingId the ID of the disk offering for the virtual machin
* e. If the template is of ISO format, the diskOfferingId is for the root disk vol
* ume. Otherwise this parameter is used to indicate the offering for the data disk
* volume. If the templateId parameter passed is from a Template object, the diskO
* fferingId refers to a DATA Disk Volume created. If the templateId parameter pass
* ed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume create
* d.
* @param string $displayName an optional user generated name for the virtual machi
* ne
* @param string $domainId an optional domainId for the virtual machine. If the acc
* ount parameter is used, domainId must also be used.
* @param string $group an optional group for the virtual machine
* @param string $hostId destination Host ID to deploy the VM to - parameter availa
* ble for root admin only
* @param string $hypervisor the hypervisor on which to deploy the virtual machine
* @param string $keyPair name of the ssh key pair used to login to the virtual mac
* hine
* @param string $name host name for the virtual machine
* @param string $networkIds list of network ids used by virtual machine
* @param string $securityGroupIds comma separated list of security groups id that
* going to be applied to the virtual machine. Should be passed only when vm is cre
* ated from a zone with Basic Network support. Mutually exclusive with securitygro
* upnames parameter
* @param string $securityGroupNames comma separated list of security groups names
* that going to be applied to the virtual machine. Should be passed only when vm i
* s created from a zone with Basic Network support. Mutually exclusive with securi
* tygroupids parameter
* @param string $size the arbitrary size for the DATADISK volume. Mutually exclusi
* ve with diskOfferingId
* @param string $userData an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be base64 encoded be
* fore adding it to the request. Currently only HTTP GET is supported. Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding.
*/
public function deployVirtualMachine($serviceOfferingId, $templateId, $zoneId, $account = "", $diskOfferingId = "", $displayName = "", $domainId = "", $group = "", $hostId = "", $hypervisor = "", $keyPair = "", $name = "", $networkIds = "", $securityGroupIds = "", $securityGroupNames = "", $size = "", $userData = "") {
if (empty($serviceOfferingId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "serviceOfferingId"), MISSING_ARGUMENT);
}
if (empty($templateId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "templateId"), MISSING_ARGUMENT);
}
if (empty($zoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "zoneId"), MISSING_ARGUMENT);
}
return $this->request("deployVirtualMachine", array(
'serviceofferingid' => $serviceOfferingId,
'templateid' => $templateId,
'zoneid' => $zoneId,
'account' => $account,
'diskofferingid' => $diskOfferingId,
'displayname' => $displayName,
'domainid' => $domainId,
'group' => $group,
'hostid' => $hostId,
'hypervisor' => $hypervisor,
'keypair' => $keyPair,
'name' => $name,
'networkids' => $networkIds,
'securitygroupids' => $securityGroupIds,
'securitygroupnames' => $securityGroupNames,
'size' => $size,
'userdata' => $userData,
));
}
/**
* Destroys a virtual machine. Once destroyed, only the administrator can recover it.
*
* @param string $id The ID of the virtual machine
*/
public function destroyVirtualMachine($id) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("destroyVirtualMachine", array(
'id' => $id,
));
}
/**
* Reboots a virtual machine.
*
* @param string $id The ID of the virtual machine
*/
public function rebootVirtualMachine($id) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("rebootVirtualMachine", array(
'id' => $id,
));
}
/**
* Starts a virtual machine.
*
* @param string $id The ID of the virtual machine
*/
public function startVirtualMachine($id) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("startVirtualMachine", array(
'id' => $id,
));
}
/**
* Stops a virtual machine.
*
* @param string $id The ID of the virtual machine
* @param string $forced Force stop the VM. The caller knows the VM is stopped.
*/
public function stopVirtualMachine($id, $forced = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("stopVirtualMachine", array(
'id' => $id,
'forced' => $forced,
));
}
/**
* Resets the password for virtual machine. The virtual machine must be in a "Stopped" state and the template must already support this feature for this command to take effect. [async]
*
* @param string $id The ID of the virtual machine
*/
public function resetPasswordForVirtualMachine($id) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("resetPasswordForVirtualMachine", array(
'id' => $id,
));
}
/**
* Changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect.
*
* @param string $id The ID of the virtual machine
* @param string $serviceOfferingId the service offering ID to apply to the virtual
* machine
*/
public function changeServiceForVirtualMachine($id, $serviceOfferingId) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($serviceOfferingId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "serviceOfferingId"), MISSING_ARGUMENT);
}
return $this->request("changeServiceForVirtualMachine", array(
'id' => $id,
'serviceofferingid' => $serviceOfferingId,
));
}
/**
* Updates parameters of a virtual machine.
*
* @param string $id The ID of the virtual machine
* @param string $displayName user generated name
* @param string $group group of the virtual machine
* @param string $haEnable true if high-availability is enabled for the virtual mac
* hine, false otherwise
* @param string $osTypeId the ID of the OS type that best represents this VM.
*/
public function updateVirtualMachine($id, $displayName = "", $group = "", $haEnable = "", $osTypeId = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("updateVirtualMachine", array(
'id' => $id,
'displayname' => $displayName,
'group' => $group,
'haenable' => $haEnable,
'ostypeid' => $osTypeId,
));
}
/**
* List the virtual machines owned by the account.
*
* @param string $account account. Must be used with the domainId parameter.
* @param string $domainId the domain ID. If used with the account parameter, lists
* virtual machines for the specified account in this domain.
* @param string $forVirtualNetwork list by network type; true if need to list vms
* using Virtual Network, false otherwise
* @param string $groupId the group ID
* @param string $hostId the host ID
* @param string $hypervisor the target hypervisor for the template
* @param string $id the ID of the virtual machine
* @param string $isRecursive Must be used with domainId parameter. Defaults to fal
* se, but if true, lists all vms from the parent specified by the domain id till l
* eaves.
* @param string $keyword List by keyword
* @param string $name name of the virtual machine
* @param string $networkId list by network id
* @param string $page
* @param string $pageSize
* @param string $podId the pod ID
* @param string $state state of the virtual machine
* @param string $storageId the storage ID where vm's volumes belong to
* @param string $zoneId the availability zone ID
* @param string $page Pagination
*/
public function listVirtualMachines($account = "", $domainId = "", $forVirtualNetwork = "", $groupId = "", $hostId = "", $hypervisor = "", $id = "", $isRecursive = "", $keyword = "", $name = "", $networkId = "", $page = "", $pageSize = "", $podId = "", $state = "", $storageId = "", $zoneId = "", $page = "") {
return $this->request("listVirtualMachines", array(
'account' => $account,
'domainid' => $domainId,
'forvirtualnetwork' => $forVirtualNetwork,
'groupid' => $groupId,
'hostid' => $hostId,
'hypervisor' => $hypervisor,
'id' => $id,
'isrecursive' => $isRecursive,
'keyword' => $keyword,
'name' => $name,
'networkid' => $networkId,
'page' => $page,
'pagesize' => $pageSize,
'podid' => $podId,
'state' => $state,
'storageid' => $storageId,
'zoneid' => $zoneId,
'page' => $page,
));
}
/**
* Returns an encrypted password for the VM
*
* @param string $id The ID of the virtual machine
*/
public function getVMPassword($id) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("getVMPassword", array(
'id' => $id,
));
}
/**
* Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it.
*
* @param string $displayText the display text of the template. This is usually use
* d for display purposes.
* @param string $name the name of the template
* @param string $osTypeId the ID of the OS Type that best represents the OS of thi
* s template.
* @param string $bits 32 or 64 bit
* @param string $isFeatured true if this template is a featured template, false ot
* herwise
* @param string $isPublic true if this template is a public template, false otherw
* ise
* @param string $passwordEnabled true if the template supports the password reset
* feature; default is false
* @param string $requireShvm true if the template requres HVM, false otherwise
* @param string $snapshotId the ID of the snapshot the template is being created f
* rom
* @param string $volumeId the ID of the disk volume the template is being created
* from
*/
public function createTemplate($displayText, $name, $osTypeId, $bits = "", $isFeatured = "", $isPublic = "", $passwordEnabled = "", $requireShvm = "", $snapshotId = "", $volumeId = "") {
if (empty($displayText)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "displayText"), MISSING_ARGUMENT);
}
if (empty($name)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "name"), MISSING_ARGUMENT);
}
if (empty($osTypeId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "osTypeId"), MISSING_ARGUMENT);
}
return $this->request("createTemplate", array(
'displaytext' => $displayText,
'name' => $name,
'ostypeid' => $osTypeId,
'bits' => $bits,
'isfeatured' => $isFeatured,
'ispublic' => $isPublic,
'passwordenabled' => $passwordEnabled,
'requireshvm' => $requireShvm,
'snapshotid' => $snapshotId,
'volumeid' => $volumeId,
));
}
/**
* Registers an existing template into the Cloud.com cloud.
*
* @param string $displayText the display text of the template. This is usually use
* d for display purposes.
* @param string $format the format for the template. Possible values include QCOW2
* , RAW, and VHD.
* @param string $hypervisor the target hypervisor for the template
* @param string $name the name of the template
* @param string $osTypeId the ID of the OS Type that best represents the OS of thi
* s template.
* @param string $url the URL of where the template is hosted. Possible URL include
* http:// and https://
* @param string $zoneId the ID of the zone the template is to be hosted on
* @param string $account an optional accountName. Must be used with domainId.
* @param string $bits 32 or 64 bits support. 64 by default
* @param string $checksum the MD5 checksum value of this template
* @param string $domainId an optional domainId. If the account parameter is used,
* domainId must also be used.
* @param string $isExtractable true if the template or its derivatives are extract
* able; default is false
* @param string $isFeatured true if this template is a featured template, false ot
* herwise
* @param string $isPublic true if the template is available to all accounts; defau
* lt is true
* @param string $passwordEnabled true if the template supports the password reset
* feature; default is false
* @param string $requireShvm true if this template requires HVM
*/
public function registerTemplate($displayText, $format, $hypervisor, $name, $osTypeId, $url, $zoneId, $account = "", $bits = "", $checksum = "", $domainId = "", $isExtractable = "", $isFeatured = "", $isPublic = "", $passwordEnabled = "", $requireShvm = "") {
if (empty($displayText)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "displayText"), MISSING_ARGUMENT);
}
if (empty($format)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "format"), MISSING_ARGUMENT);
}
if (empty($hypervisor)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "hypervisor"), MISSING_ARGUMENT);
}
if (empty($name)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "name"), MISSING_ARGUMENT);
}
if (empty($osTypeId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "osTypeId"), MISSING_ARGUMENT);
}
if (empty($url)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "url"), MISSING_ARGUMENT);
}
if (empty($zoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "zoneId"), MISSING_ARGUMENT);
}
return $this->request("registerTemplate", array(
'displaytext' => $displayText,
'format' => $format,
'hypervisor' => $hypervisor,
'name' => $name,
'ostypeid' => $osTypeId,
'url' => $url,
'zoneid' => $zoneId,
'account' => $account,
'bits' => $bits,
'checksum' => $checksum,
'domainid' => $domainId,
'isextractable' => $isExtractable,
'isfeatured' => $isFeatured,
'ispublic' => $isPublic,
'passwordenabled' => $passwordEnabled,
'requireshvm' => $requireShvm,
));
}
/**
* Updates attributes of a template.
*
* @param string $id the ID of the image file
* @param string $bootable true if image is bootable, false otherwise
* @param string $displayText the display text of the image
* @param string $format the format for the image
* @param string $name the name of the image file
* @param string $osTypeId the ID of the OS type that best represents the OS of thi
* s image.
* @param string $passwordEnabled true if the image supports the password reset fea
* ture; default is false
*/
public function updateTemplate($id, $bootable = "", $displayText = "", $format = "", $name = "", $osTypeId = "", $passwordEnabled = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("updateTemplate", array(
'id' => $id,
'bootable' => $bootable,
'displaytext' => $displayText,
'format' => $format,
'name' => $name,
'ostypeid' => $osTypeId,
'passwordenabled' => $passwordEnabled,
));
}
/**
* Copies a template from one zone to another.
*
* @param string $id Template ID.
* @param string $destzoneId ID of the zone the template is being copied to.
* @param string $sourceZoneId ID of the zone the template is currently hosted on.
*/
public function copyTemplate($id, $destzoneId, $sourceZoneId) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($destzoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "destzoneId"), MISSING_ARGUMENT);
}
if (empty($sourceZoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "sourceZoneId"), MISSING_ARGUMENT);
}
return $this->request("copyTemplate", array(
'id' => $id,
'destzoneid' => $destzoneId,
'sourcezoneid' => $sourceZoneId,
));
}
/**
* Deletes a template from the system. All virtual machines using the deleted template will not be affected.
*
* @param string $id the ID of the template
* @param string $zoneId the ID of zone of the template
*/
public function deleteTemplate($id, $zoneId = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("deleteTemplate", array(
'id' => $id,
'zoneid' => $zoneId,
));
}
/**
* List all public, private, and privileged templates.
*
* @param string $templateFilter possible values are "featured", "se
* lf", "self-executable", "executable", and "communi
* ty".* featured-templates that are featured and are public* self-templates t
* hat have been registered/created by the owner* selfexecutable-templates that hav
* e been registered/created by the owner that can be used to deploy a new VM* exec
* utable-all templates that can be used to deploy a new VM* community-templates th
* at are public.
* @param string $account list template by account. Must be used with the domainId
* parameter.
* @param string $domainId list all templates in specified domain. If used with the
* account parameter, lists all templates for an account in the specified domain.
* @param string $hypervisor the hypervisor for which to restrict the search
* @param string $id the template ID
* @param string $keyword List by keyword
* @param string $name the template name
* @param string $page
* @param string $pageSize
* @param string $zoneId list templates by zoneId
* @param string $page Pagination
*/
public function listTemplates($templateFilter, $account = "", $domainId = "", $hypervisor = "", $id = "", $keyword = "", $name = "", $page = "", $pageSize = "", $zoneId = "", $page = "") {
if (empty($templateFilter)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "templateFilter"), MISSING_ARGUMENT);
}
return $this->request("listTemplates", array(
'templatefilter' => $templateFilter,
'account' => $account,
'domainid' => $domainId,
'hypervisor' => $hypervisor,
'id' => $id,
'keyword' => $keyword,
'name' => $name,
'page' => $page,
'pagesize' => $pageSize,
'zoneid' => $zoneId,
'page' => $page,
));
}
/**
* Updates a template visibility permissions. A public template is visible to all accounts within the same domain. A private template is visible only to the owner of the template. A priviledged template is a private template with account permissions added. Only accounts specified under the template permissions are visible to them.
*
* @param string $id the template ID
* @param string $accounts a comma delimited list of accounts
* @param string $isFeatured true for featured templates/isos, false otherwise
* @param string $isPublic true for public templates/isos, false for private templa
* tes/isos
* @param string $op permission operator (add, remove, reset)
*/
public function updateTemplatePermissions($id, $accounts = "", $isFeatured = "", $isPublic = "", $op = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("updateTemplatePermissions", array(
'id' => $id,
'accounts' => $accounts,
'isfeatured' => $isFeatured,
'ispublic' => $isPublic,
'op' => $op,
));
}
/**
* List template visibility and all accounts that have permissions to view this template.
*
* @param string $id the template ID
* @param string $account List template visibility and permissions for the specifie
* d account. Must be used with the domainId parameter.
* @param string $domainId List template visibility and permissions by domain. If u
* sed with the account parameter, specifies in which domain the specified account
* exists.
* @param string $page Pagination
*/
public function listTemplatePermissions($id, $account = "", $domainId = "", $page = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("listTemplatePermissions", array(
'id' => $id,
'account' => $account,
'domainid' => $domainId,
'page' => $page,
));
}
/**
* Extracts a template
*
* @param string $id the ID of the template
* @param string $mode the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD
* @param string $zoneId the ID of the zone where the ISO is originally located
* @param string $url the url to which the ISO would be extracted
*/
public function extractTemplate($id, $mode, $zoneId, $url = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($mode)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "mode"), MISSING_ARGUMENT);
}
if (empty($zoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "zoneId"), MISSING_ARGUMENT);
}
return $this->request("extractTemplate", array(
'id' => $id,
'mode' => $mode,
'zoneid' => $zoneId,
'url' => $url,
));
}
/**
* Attaches an ISO to a virtual machine.
*
* @param string $id the ID of the ISO file
* @param string $virtualMachineId the ID of the virtual machine
*/
public function attachIso($id, $virtualMachineId) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($virtualMachineId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "virtualMachineId"), MISSING_ARGUMENT);
}
return $this->request("attachIso", array(
'id' => $id,
'virtualmachineid' => $virtualMachineId,
));
}
/**
* Detaches any ISO file (if any) currently attached to a virtual machine.
*
* @param string $virtualMachineId The ID of the virtual machine
*/
public function detachIso($virtualMachineId) {
if (empty($virtualMachineId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "virtualMachineId"), MISSING_ARGUMENT);
}
return $this->request("detachIso", array(
'virtualmachineid' => $virtualMachineId,
));
}
/**
* Lists all available ISO files.
*
* @param string $account the account of the ISO file. Must be used with the domain
* Id parameter.
* @param string $bootable true if the ISO is bootable, false otherwise
* @param string $domainId lists all available ISO files by ID of a domain. If used
* with the account parameter, lists all available ISO files for the account in th
* e ID of a domain.
* @param string $hypervisor the hypervisor for which to restrict the search
* @param string $id list all isos by id
* @param string $isoFilter possible values are "featured", "self&qu
* ot;, "self-executable","executable", and "community&quo
* t;. * featured-ISOs that are featured and are publicself-ISOs that have been reg
* istered/created by the owner. * selfexecutable-ISOs that have been registered/cr
* eated by the owner that can be used to deploy a new VM. * executable-all ISOs th
* at can be used to deploy a new VM * community-ISOs that are public.
* @param string $isPublic true if the ISO is publicly available to all users, fals
* e otherwise.
* @param string $isReady true if this ISO is ready to be deployed
* @param string $keyword List by keyword
* @param string $name list all isos by name
* @param string $page
* @param string $pageSize
* @param string $zoneId the ID of the zone
* @param string $page Pagination
*/
public function listIsos($account = "", $bootable = "", $domainId = "", $hypervisor = "", $id = "", $isoFilter = "", $isPublic = "", $isReady = "", $keyword = "", $name = "", $page = "", $pageSize = "", $zoneId = "", $page = "") {
return $this->request("listIsos", array(
'account' => $account,
'bootable' => $bootable,
'domainid' => $domainId,
'hypervisor' => $hypervisor,
'id' => $id,
'isofilter' => $isoFilter,
'ispublic' => $isPublic,
'isready' => $isReady,
'keyword' => $keyword,
'name' => $name,
'page' => $page,
'pagesize' => $pageSize,
'zoneid' => $zoneId,
'page' => $page,
));
}
/**
* Registers an existing ISO into the Cloud.com Cloud.
*
* @param string $displayText the display text of the ISO. This is usually used for
* display purposes.
* @param string $name the name of the ISO
* @param string $url the URL to where the ISO is currently being hosted
* @param string $zoneId the ID of the zone you wish to register the ISO to.
* @param string $account an optional account name. Must be used with domainId.
* @param string $bootable true if this ISO is bootable
* @param string $domainId an optional domainId. If the account parameter is used,
* domainId must also be used.
* @param string $isFeatured true if you want this ISO to be featured
* @param string $isPublic true if you want to register the ISO to be publicly avai
* lable to all users, false otherwise.
* @param string $osTypeId the ID of the OS Type that best represents the OS of thi
* s ISO
*/
public function registerIso($displayText, $name, $url, $zoneId, $account = "", $bootable = "", $domainId = "", $isFeatured = "", $isPublic = "", $osTypeId = "") {
if (empty($displayText)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "displayText"), MISSING_ARGUMENT);
}
if (empty($name)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "name"), MISSING_ARGUMENT);
}
if (empty($url)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "url"), MISSING_ARGUMENT);
}
if (empty($zoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "zoneId"), MISSING_ARGUMENT);
}
return $this->request("registerIso", array(
'displaytext' => $displayText,
'name' => $name,
'url' => $url,
'zoneid' => $zoneId,
'account' => $account,
'bootable' => $bootable,
'domainid' => $domainId,
'isfeatured' => $isFeatured,
'ispublic' => $isPublic,
'ostypeid' => $osTypeId,
));
}
/**
* Updates an ISO file.
*
* @param string $id the ID of the image file
* @param string $bootable true if image is bootable, false otherwise
* @param string $displayText the display text of the image
* @param string $format the format for the image
* @param string $name the name of the image file
* @param string $osTypeId the ID of the OS type that best represents the OS of thi
* s image.
* @param string $passwordEnabled true if the image supports the password reset fea
* ture; default is false
*/
public function updateIso($id, $bootable = "", $displayText = "", $format = "", $name = "", $osTypeId = "", $passwordEnabled = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("updateIso", array(
'id' => $id,
'bootable' => $bootable,
'displaytext' => $displayText,
'format' => $format,
'name' => $name,
'ostypeid' => $osTypeId,
'passwordenabled' => $passwordEnabled,
));
}
/**
* Deletes an ISO file.
*
* @param string $id the ID of the ISO file
* @param string $zoneId the ID of the zone of the ISO file. If not specified, the
* ISO will be deleted from all the zones
*/
public function deleteIso($id, $zoneId = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("deleteIso", array(
'id' => $id,
'zoneid' => $zoneId,
));
}
/**
* Copies an ISO file.
*
* @param string $id the ID of the ISO file
* @param string $destzoneId the ID of the destination zone to which the ISO file w
* ill be copied
* @param string $sourceZoneId the ID of the source zone from which the ISO file wi
* ll be copied
*/
public function copyIso($id, $destzoneId, $sourceZoneId) {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($destzoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "destzoneId"), MISSING_ARGUMENT);
}
if (empty($sourceZoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "sourceZoneId"), MISSING_ARGUMENT);
}
return $this->request("copyIso", array(
'id' => $id,
'destzoneid' => $destzoneId,
'sourcezoneid' => $sourceZoneId,
));
}
/**
* Updates iso permissions
*
* @param string $id the template ID
* @param string $accounts a comma delimited list of accounts
* @param string $isFeatured true for featured templates/isos, false otherwise
* @param string $isPublic true for public templates/isos, false for private templa
* tes/isos
* @param string $op permission operator (add, remove, reset)
*/
public function updateIsoPermissions($id, $accounts = "", $isFeatured = "", $isPublic = "", $op = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("updateIsoPermissions", array(
'id' => $id,
'accounts' => $accounts,
'isfeatured' => $isFeatured,
'ispublic' => $isPublic,
'op' => $op,
));
}
/**
* List template visibility and all accounts that have permissions to view this template.
*
* @param string $id the template ID
* @param string $account List template visibility and permissions for the specifie
* d account. Must be used with the domainId parameter.
* @param string $domainId List template visibility and permissions by domain. If u
* sed with the account parameter, specifies in which domain the specified account
* exists.
* @param string $page Pagination
*/
public function listIsoPermissions($id, $account = "", $domainId = "", $page = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
return $this->request("listIsoPermissions", array(
'id' => $id,
'account' => $account,
'domainid' => $domainId,
'page' => $page,
));
}
/**
* Extracts an ISO
*
* @param string $id the ID of the ISO file
* @param string $mode the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD
* @param string $zoneId the ID of the zone where the ISO is originally located
* @param string $url the url to which the ISO would be extracted
*/
public function extractIso($id, $mode, $zoneId, $url = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($mode)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "mode"), MISSING_ARGUMENT);
}
if (empty($zoneId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "zoneId"), MISSING_ARGUMENT);
}
return $this->request("extractIso", array(
'id' => $id,
'mode' => $mode,
'zoneid' => $zoneId,
'url' => $url,
));
}
/**
* Attaches a disk volume to a virtual machine.
*
* @param string $id the ID of the disk volume
* @param string $virtualMachineId the ID of the virtual machine
* @param string $deviceId the ID of the device to map the volume to within the gue
* st OS. If no deviceId is passed in, the next available deviceId will be chosen.
* Possible values for a Linux OS are:* 1 - /dev/xvdb* 2 - /dev/xvdc* 4 - /dev/xvde
* * 5 - /dev/xvdf* 6 - /dev/xvdg* 7 - /dev/xvdh* 8 - /dev/xvdi* 9 - /dev/xvdj
*/
public function attachVolume($id, $virtualMachineId, $deviceId = "") {
if (empty($id)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "id"), MISSING_ARGUMENT);
}
if (empty($virtualMachineId)) {
throw new CloudStackClientException(sprintf(MISSING_ARGUMENT_MSG, "virtualMachineId"), MISSING_ARGUMENT);
}
return $this->request("attachVolume", array(
'id' => $id,
'virtualmachineid' => $virtualMachineId,
'deviceid' => $deviceId,
));
}
/**
* Detaches a disk volume from a virtual machine.
*
* @param string $deviceId the device ID on the virtual machine where volume is det
* ached from
* @param string $id the ID of the disk volume
* @param string $virtualMachineId the ID of the virtual machine where the volume i
* s detached from
*/
public function detachVolume($deviceId = "", $id = "", $virtualMachineId = "") {
return $this->request("detachVolume", array(
'deviceid' => $deviceId,
'id' => $id,
'virtualmachineid' => $virtualMachineId,
));
}
/**
* Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.
*
* @param string $name the name of the disk volume
* @param string $account the account associated with the disk volume. Must be used
* with the domainId parameter.
* @param string $diskOfferingId the ID of the disk offering. Either diskOfferingId
* or snapshotId must be passed in.
* @param string $domainId the domain ID associated with the disk offering. If used
* with the account parameter returns the disk volume associated with the account
* for the specified domain.
* @param string $size Arbitrary volume size. Mutually exclusive with diskOfferingI
* d