info('Saving credentials in %s', CACHEFILE); $rackspace->Authenticate(); $cred = $rackspace->ExportCredentials(); $fp = @fopen(CACHEFILE, 'w'); if (!$fp) { die(sprintf("Cannot open cache file %s for writing\n", CACHEFILE)); } fwrite($fp, serialize($cred)); fclose($fp); } else { // load cached credentials info('Loading credentials from %s', CACHEFILE); $str = fread($fp, 99999); // read it all fclose($fp); $rackspace->ImportCredentials(unserialize($str)); } /** * Cloud DNS */ step('Connect to Cloud DNS'); $dns = $rackspace->DNS(); step('Try to add a domain %s', TESTDOMAIN); $domain = $dns->Domain(); $aresp = $domain->Create(array('name' => TESTDOMAIN, 'emailAddress' => '*****@*****.**', 'ttl' => 3600)); $aresp->WaitFor('COMPLETED', 300, 'dotter', 1); if ($aresp->Status() == 'ERROR') { info('Error condition (this may be valid if the domain exists'); info('[%d] %s - %s', $aresp->error->code, $aresp->error->message, $aresp->error->details); } step("Adding a CNAME record www.%s", TESTDOMAIN);