1+ <?php
2+ // (c)2012 Rackspace Hosting
3+ // See COPYING for licensing information
4+
5+ require_once "php-opencloud.php " ;
6+
7+ // set this to the name of the domain to export
8+ define ('EXPORT_DOMAIN ' , 'fipplefippleraxdrg.info ' );
9+
10+ define ('AUTHURL ' , RACKSPACE_US );
11+ define ('USERNAME ' , $ _ENV ['OS_USERNAME ' ]);
12+ define ('TENANT ' , $ _ENV ['OS_TENANT_NAME ' ]);
13+ define ('APIKEY ' , $ _ENV ['NOVA_API_KEY ' ]);
14+
15+ // establish our credentials
16+ $ cloud = new \OpenCloud \Rackspace (AUTHURL ,
17+ array ( 'username ' => USERNAME ,
18+ 'apiKey ' => APIKEY ));
19+
20+ // uncomment to turn on debugging
21+ //setDebug(TRUE);
22+
23+ $ dns = $ cloud ->DNS ();
24+ $ dlist = $ dns ->DomainList (array ('name ' =>EXPORT_DOMAIN ));
25+ while ($ domain = $ dlist ->Next ()) {
26+ printf ("Cloning %s \n" , $ domain ->Name ());
27+ //setDebug(TRUE);
28+ $ resp = $ domain ->CloneDomain ('NEWDOMAIN.IO ' );
29+ //setDebug(FALSE);
30+ $ resp ->WaitFor ('COMPLETED ' , 300 , 'ShowStatus ' , 1 );
31+ // check result
32+ if ($ resp ->Status () == 'ERROR ' )
33+ printf ("Error code [%d] message [%s] \nDetails: [%s] \n" ,
34+ $ resp ->error ->code , $ resp ->error ->message , $ resp ->error ->details );
35+ else if ($ resp ->Status () != 'COMPLETED ' )
36+ printf ("Unable to wait longer. Sorry. \n" );
37+ exit ;
38+ }
39+
40+ exit ;
41+
42+ // callback function for WaitFor
43+ function ShowStatus ($ obj ) {
44+ printf ("%s - %s \n" , $ obj ->Name (), $ obj ->Status ());
45+ }
0 commit comments