forked from icanhazdevops/DevOps-Challenges-Cycle1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevops_include.php
More file actions
44 lines (36 loc) · 1.51 KB
/
devops_include.php
File metadata and controls
44 lines (36 loc) · 1.51 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
<?php
require 'vendor/autoload.php';
use OpenCloud\Rackspace;
use OpenCloud\Compute\Constants\Network;
use OpenCloud\Compute\Constants\ServerState;
// Get credentials and configuration from ~/.rackspace_cloud_credentials
// $_SERVER['HOME'] does not exist in Windows, but it does in linux
// the equivalent in windows that i could see was USERPROFILE
$inifile = (array_key_exists('HOME', $_SERVER)?$_SERVER['HOME']: $_SERVER['USERPROFILE']). "/.rackspace_cloud_credentials";
$ini = parse_ini_file($inifile,TRUE);
if (!$ini) {
printf("Unable to load .ini file [%s]\n", INIFILE);
exit;
}
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, $ini['Rackspace_Auth']);
$compute = $client->computeService('cloudServersOpenStack', $ini['Server_Info']['dc']);
$dns = $client->dnsService();
$cbs = $client->VolumeService();
$cloudFiles = $client->objectStoreService('cloudFiles', $ini['Server_Info']['dc']);
$dbService = $client->DatabaseService('CloudDatabases', $ini['Server_Info']['dc']);
$monitorService = $client->cloudMonitoringService('cloudMonitoring', $ini['Server_Info']['dc']);
$loadBalancerService = $client->loadBalancerService('cloudLoadBalancers', $ini['Server_Info']['dc']);
$server_callback = function($server) {
if (!empty($server->error)) {
var_dump($server->error);
exit;
} else {
echo sprintf(
"Waiting on %s/%-12s %4s \n",
$server->name(),
$server->status(),
isset($server->progress) ? $server->progress."%" : ""
);
}
};
?>