File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
samples/compute/v2/hypervisors Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use OpenStack \Compute \v2 \Models \Hypervisor ;
4
+
5
+ require 'vendor/autoload.php ' ;
6
+
7
+ $ openstack = new OpenStack \OpenStack ([
8
+ 'authUrl ' => '{authUrl} ' ,
9
+ 'region ' => '{region} ' ,
10
+ 'user ' => [
11
+ 'id ' => '{userId} ' ,
12
+ 'password ' => '{password} '
13
+ ],
14
+ 'scope ' => ['project ' => ['id ' => '{projectId} ' ]]
15
+ ]);
16
+
17
+ $ compute = $ openstack ->computeV2 (['region ' => '{region} ' ]);
18
+
19
+ $ hypervisor = $ compute ->getHypervisor (['id ' => '{hypervisorId} ' ]);
20
+
21
+ // By default, this will return an empty Server object and NOT hit the API.
22
+ // This is convenient for when you want to use the object for operations
23
+ // that do not require an initial GET request. To retrieve the server's details,
24
+ // run the following, which *will* call the API with a GET request:
25
+
26
+ $ hypervisor ->retrieve ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use OpenStack \Compute \v2 \Models \Hypervisor ;
4
+
5
+ require 'vendor/autoload.php ' ;
6
+
7
+ $ openstack = new OpenStack \OpenStack ([
8
+ 'authUrl ' => '{authUrl} ' ,
9
+ 'region ' => '{region} ' ,
10
+ 'user ' => [
11
+ 'id ' => '{userId} ' ,
12
+ 'password ' => '{password} '
13
+ ],
14
+ 'scope ' => ['project ' => ['id ' => '{projectId} ' ]]
15
+ ]);
16
+
17
+ $ compute = $ openstack ->computeV2 (['region ' => '{region} ' ]);
18
+
19
+ $ hypervisors = $ compute ->listHypervisors ();
20
+
21
+ foreach ($ hypervisors as $ hypervisor ) {
22
+ /**@var Hypervisor $hypervisor*/
23
+ }
You can’t perform that action at this time.
0 commit comments