예제 #1
0
 * numbers each step
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3));
}
define('TIMEFORMAT', 'r');
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
step('Connect to the VolumeService');
$cbs = $rackspace->VolumeService('cloudBlockStorage', 'DFW');
step('Snapshotting volumes');
$list = $cbs->VolumeList();
while ($vol = $list->Next()) {
    info('Volume: %s [%s] size=%d', $vol->display_name, $vol->display_description, $vol->size);
    $snap = $cbs->Snapshot();
    // empty snapshot object
    info('  Creating snapshot');
    //setDebug(TRUE);
    $snap->Create(array('display_name' => $vol->Name() . 'Snapshot-' . time(), 'volume_id' => $vol->id, 'force' => TRUE));
    setDebug(FALSE);
}
step('DONE');
exit;
// callback for WaitFor
function dot($server)
예제 #2
0
파일: cleanup.php 프로젝트: omusico/home365
        info('Deleting %s', $server->Name());
        $server->Delete();
    }
}
step('Deleting the test network(s)');
$list = $cloudservers->NetworkList();
while ($network = $list->Next()) {
    info('Deleting: %s %s', $network->id, $network->label);
    try {
        $network->Delete();
    } catch (OpenCloud\Common\Exceptions\DeleteError $e) {
        info('---Cannot delete');
    }
}
step('Connect to CBS');
$cbs = $rackspace->VolumeService('cloudBlockStorage', MYREGION);
step('Connect to Cloud Files');
$files = $rackspace->ObjectStore('cloudFiles', MYREGION);
step('Connect to Cloud Load Balancers');
$lbservice = $rackspace->LoadBalancerService('cloudLoadBalancers', MYREGION);
step('Deleting snapshots');
$list = $cbs->SnapshotList();
while ($snap = $list->Next()) {
    if ($snap->Status() == 'error' || $snap->Status() == 'available') {
        info('Deleting snapshot [%s] %s', $snap->id, $snap->Name());
        $snap->Delete();
    } else {
        info('[%s] %s status is %s', $snap->id, $snap->Name(), $snap->Status());
    }
}
step('Deleting objects');