€cdocutils.nodes
document
q)q}q(U	nametypesq}q(X   getting startedqNX"   1. instantiate a rackspace client.qNX%   2. create a database server instance.qNX5   3. create a database on the database server instance.q	NX[   5. optional step: create a load balancer to allow access to the database from the internet.q
NX	   databasesqNX7   4. create database user and give it access to database.qNuUsubstitution_defsq}qUparse_messagesq]qUcurrent_sourceqNU
decorationqNUautofootnote_startqKUnameidsq}q(hUgetting-startedqhUinstantiate-a-rackspace-clientqhU!create-a-database-server-instanceqh	U1create-a-database-on-the-database-server-instanceqh
UVoptional-step-create-a-load-balancer-to-allow-access-to-the-database-from-the-internetqhU	databasesqhU3create-database-user-and-give-it-access-to-databasequUchildrenq]qcdocutils.nodes
section
q)q }q!(U	rawsourceq"U Uparentq#hUsourceq$XK   /Users/jamie/projects/php/php-opencloud/doc/services/database/README.md.rstq%Utagnameq&Usectionq'U
attributesq(}q)(Udupnamesq*]Uclassesq+]Ubackrefsq,]Uidsq-]q.haUnamesq/]q0hauUlineq1KUdocumentq2hh]q3(cdocutils.nodes
title
q4)q5}q6(h"X	   Databasesq7h#h h$h%h&Utitleq8h(}q9(h*]h+]h,]h-]h/]uh1Kh2hh]q:cdocutils.nodes
Text
q;X	   Databasesq<…q=}q>(h"h7h#h5ubaubcdocutils.nodes
paragraph
q?)q@}qA(h"XÕ   A **cloud database** is a MySQL relational database service that allows
customers to programatically provision database instances of varying
virtual resource sizes without the need to maintain and/or update MySQL.h#h h$h%h&U	paragraphqBh(}qC(h*]h+]h,]h-]h/]uh1Kh2hh]qD(h;X   A qE…qF}qG(h"X   A h#h@ubcdocutils.nodes
strong
qH)qI}qJ(h"X   **cloud database**h(}qK(h*]h+]h,]h-]h/]uh#h@h]qLh;X   cloud databaseqM…qN}qO(h"U h#hIubah&UstrongqPubh;XÁ    is a MySQL relational database service that allows
customers to programatically provision database instances of varying
virtual resource sizes without the need to maintain and/or update MySQL.qQ…qR}qS(h"XÁ    is a MySQL relational database service that allows
customers to programatically provision database instances of varying
virtual resource sizes without the need to maintain and/or update MySQL.h#h@ubeubh)qT}qU(h"U h#h h$h%h&h'h(}qV(h*]h+]h,]h-]qWhah/]qXhauh1K	h2hh]qY(h4)qZ}q[(h"X   Getting startedq\h#hTh$h%h&h8h(}q](h*]h+]h,]h-]h/]uh1K	h2hh]q^h;X   Getting startedq_…q`}qa(h"h\h#hZubaubh)qb}qc(h"U h#hTh$h%h&h'h(}qd(h*]h+]h,]h-]qehah/]qfhauh1Kh2hh]qg(h4)qh}qi(h"X"   1. Instantiate a Rackspace client.qjh#hbh$h%h&h8h(}qk(h*]h+]h,]h-]h/]uh1Kh2hh]qlh;X"   1. Instantiate a Rackspace client.qm…qn}qo(h"hjh#hhubaubcdocutils.nodes
literal_block
qp)qq}qr(h"Xû   use OpenCloud\Rackspace;
use OpenCloud\Common\Constants\State;

$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
    'username' => '<YOUR RACKSPACE CLOUD ACCOUNT USERNAME>',
    'apiKey'   => '<YOUR RACKSPACE CLOUD ACCOUNT API KEY>'
));h#hbh$h%h&Uliteral_blockqsh(}qt(U	xml:spacequUpreserveqvh-]h,]h*]h+]qw(UcodeqxX   phpqyeh/]uh1Kh2hh]qzcdocutils.nodes
inline
q{)q|}q}(h"Xû   use OpenCloud\Rackspace;
use OpenCloud\Common\Constants\State;

$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
    'username' => '<YOUR RACKSPACE CLOUD ACCOUNT USERNAME>',
    'apiKey'   => '<YOUR RACKSPACE CLOUD ACCOUNT API KEY>'
));h(}q~(h*]h+]qUotherq€ah,]h-]h/]uh#hqh]qh;Xû   use OpenCloud\Rackspace;
use OpenCloud\Common\Constants\State;

$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
    'username' => '<YOUR RACKSPACE CLOUD ACCOUNT USERNAME>',
    'apiKey'   => '<YOUR RACKSPACE CLOUD ACCOUNT API KEY>'
));q‚…qƒ}q„(h"U h#h|ubah&Uinlineq…ubaubeubh)q†}q‡(h"U h#hTh$h%h&h'h(}qˆ(h*]h+]h,]h-]q‰hah/]qŠhauh1Kh2hh]q‹(h4)qŒ}q(h"X%   2. Create a database server instance.qŽh#h†h$h%h&h8h(}q(h*]h+]h,]h-]h/]uh1Kh2hh]qh;X%   2. Create a database server instance.q‘…q’}q“(h"hŽh#hŒubaubhp)q”}q•(h"Xç  $databaseService = $client->databaseService('cloudDatabases', 'DFW');

$twoGbFlavor = $databaseService->flavor(3);

$dbInstance = $databaseService->instance();
$dbInstance->name = 'Demo database instance';
$dbInstance->volume = new stdClass();
$dbInstance->volume->size = 20; // GB
$dbInstance->flavor = $twoGbFlavor;
$dbInstance->create();

$dbInstance->waitFor(State::ACTIVE, null, function ($dbInstance) {

    printf("Database instance build status: %s\n", $dbInstance->status);

});h#h†h$h%h&hsh(}q–(huhvh-]h,]h*]h+]q—(hxX   phpq˜eh/]uh1K-h2hh]q™h{)qš}q›(h"Xç  $databaseService = $client->databaseService('cloudDatabases', 'DFW');

$twoGbFlavor = $databaseService->flavor(3);

$dbInstance = $databaseService->instance();
$dbInstance->name = 'Demo database instance';
$dbInstance->volume = new stdClass();
$dbInstance->volume->size = 20; // GB
$dbInstance->flavor = $twoGbFlavor;
$dbInstance->create();

$dbInstance->waitFor(State::ACTIVE, null, function ($dbInstance) {

    printf("Database instance build status: %s\n", $dbInstance->status);

});h(}qœ(h*]h+]qUotherqžah,]h-]h/]uh#h”h]qŸh;Xç  $databaseService = $client->databaseService('cloudDatabases', 'DFW');

$twoGbFlavor = $databaseService->flavor(3);

$dbInstance = $databaseService->instance();
$dbInstance->name = 'Demo database instance';
$dbInstance->volume = new stdClass();
$dbInstance->volume->size = 20; // GB
$dbInstance->flavor = $twoGbFlavor;
$dbInstance->create();

$dbInstance->waitFor(State::ACTIVE, null, function ($dbInstance) {

    printf("Database instance build status: %s\n", $dbInstance->status);

});q …q¡}q¢(h"U h#hšubah&h…ubaubh?)q£}q¤(h"Xƒ   The example above creates a database server instance with 20GB of disk
space and 2GB of memory, then waits for it to become ACTIVE.q¥h#h†h$h%h&hBh(}q¦(h*]h+]h,]h-]h/]uh1K.h2hh]q§h;Xƒ   The example above creates a database server instance with 20GB of disk
space and 2GB of memory, then waits for it to become ACTIVE.q¨…q©}qª(h"h¥h#h£ubaubeubh)q«}q¬(h"U h#hTh$h%h&h'h(}q­(h*]h+]h,]h-]q®hah/]q¯h	auh1K2h2hh]q°(h4)q±}q²(h"X5   3. Create a database on the database server instance.q³h#h«h$h%h&h8h(}q´(h*]h+]h,]h-]h/]uh1K2h2hh]qµh;X5   3. Create a database on the database server instance.q¶…q·}q¸(h"h³h#h±ubaubhp)q¹}qº(h"XE   $db = $dbInstance->database();
$db->name = 'demo_db';

$db->create();h#h«h$h%h&hsh(}q»(huhvh-]h,]h*]h+]q¼(hxX   phpq½eh/]uh1K:h2hh]q¾h{)q¿}qÀ(h"XE   $db = $dbInstance->database();
$db->name = 'demo_db';

$db->create();h(}qÁ(h*]h+]qÂUotherqÃah,]h-]h/]uh#h¹h]qÄh;XE   $db = $dbInstance->database();
$db->name = 'demo_db';

$db->create();qÅ…qÆ}qÇ(h"U h#h¿ubah&h…ubaubh?)qÈ}qÉ(h"Xt   The example above creates a database named ``demo_db`` on the database
server instance created in the previous step.h#h«h$h%h&hBh(}qÊ(h*]h+]h,]h-]h/]uh1K;h2hh]qË(h;X+   The example above creates a database named qÌ…qÍ}qÎ(h"X+   The example above creates a database named h#hÈubcdocutils.nodes
literal
qÏ)qÐ}qÑ(h"X   ``demo_db``h(}qÒ(h*]h+]h,]h-]h/]uh#hÈh]qÓh;X   demo_dbqÔ…qÕ}qÖ(h"U h#hÐubah&Uliteralq×ubh;X>    on the database
server instance created in the previous step.qØ…qÙ}qÚ(h"X>    on the database
server instance created in the previous step.h#hÈubeubeubh)qÛ}qÜ(h"U h#hTh$h%h&h'h(}qÝ(h*]h+]h,]h-]qÞhah/]qßhauh1K?h2hh]qà(h4)qá}qâ(h"X7   4. Create database user and give it access to database.qãh#hÛh$h%h&h8h(}qä(h*]h+]h,]h-]h/]uh1K?h2hh]qåh;X7   4. Create database user and give it access to database.qæ…qç}qè(h"hãh#háubaubhp)qé}qê(h"XŠ   $user = $dbInstance->user();
$user->name = 'demo_user';
$user->password = 'h@X0r!';
$user->databases = array('demo_db');

$user->create();h#hÛh$h%h&hsh(}që(huhvh-]h,]h*]h+]qì(hxX   phpqíeh/]uh1KIh2hh]qîh{)qï}qð(h"XŠ   $user = $dbInstance->user();
$user->name = 'demo_user';
$user->password = 'h@X0r!';
$user->databases = array('demo_db');

$user->create();h(}qñ(h*]h+]qòUotherqóah,]h-]h/]uh#héh]qôh;XŠ   $user = $dbInstance->user();
$user->name = 'demo_user';
$user->password = 'h@X0r!';
$user->databases = array('demo_db');

$user->create();qõ…qö}q÷(h"U h#hïubah&h…ubaubh?)qø}qù(h"Xž   The example above creates a database user named ``demo_user``, sets its
password and gives it access to the ``demo_db`` database created in the
previous step.h#hÛh$h%h&hBh(}qú(h*]h+]h,]h-]h/]uh1KJh2hh]qû(h;X0   The example above creates a database user named qü…qý}qþ(h"X0   The example above creates a database user named h#høubhÏ)qÿ}r   (h"X   ``demo_user``h(}r  (h*]h+]h,]h-]h/]uh#høh]r  h;X	   demo_userr  …r  }r  (h"U h#hÿubah&h×ubh;X/   , sets its
password and gives it access to the r  …r  }r  (h"X/   , sets its
password and gives it access to the h#høubhÏ)r	  }r
  (h"X   ``demo_db``h(}r  (h*]h+]h,]h-]h/]uh#høh]r  h;X   demo_dbr  …r  }r  (h"U h#j	  ubah&h×ubh;X'    database created in the
previous step.r  …r  }r  (h"X'    database created in the
previous step.h#høubeubeubh)r  }r  (h"U h#hTh$h%h&h'h(}r  (h*]h+]h,]h-]r  hah/]r  h
auh1KOh2hh]r  (h4)r  }r  (h"X[   5. Optional step: Create a load balancer to allow access to the database from the Internet.r  h#j  h$h%h&h8h(}r  (h*]h+]h,]h-]h/]uh1KOh2hh]r  h;X[   5. Optional step: Create a load balancer to allow access to the database from the Internet.r  …r  }r   (h"j  h#j  ubaubh?)r!  }r"  (h"X  The database created in the previous step can only be accessed from the
Rackspace private network (aka ``SERVICENET``). If you have a cloud
server instance in the same region as the database server instance, you
will be able to connect to the database from that cloud server instance.h#j  h$h%h&hBh(}r#  (h*]h+]h,]h-]h/]uh1KQh2hh]r$  (h;Xg   The database created in the previous step can only be accessed from the
Rackspace private network (aka r%  …r&  }r'  (h"Xg   The database created in the previous step can only be accessed from the
Rackspace private network (aka h#j!  ubhÏ)r(  }r)  (h"X   ``SERVICENET``h(}r*  (h*]h+]h,]h-]h/]uh#j!  h]r+  h;X
   SERVICENETr,  …r-  }r.  (h"U h#j(  ubah&h×ubh;X§   ). If you have a cloud
server instance in the same region as the database server instance, you
will be able to connect to the database from that cloud server instance.r/  …r0  }r1  (h"X§   ). If you have a cloud
server instance in the same region as the database server instance, you
will be able to connect to the database from that cloud server instance.h#j!  ubeubh?)r2  }r3  (h"Xõ   If, however, you would like to access the database from the Internet,
you will need to create a load balancer with an IP address that is
routable from the Internet and attach the database server instance as a
back-end node of this load balancer.r4  h#j  h$h%h&hBh(}r5  (h*]h+]h,]h-]h/]uh1KVh2hh]r6  h;Xõ   If, however, you would like to access the database from the Internet,
you will need to create a load balancer with an IP address that is
routable from the Internet and attach the database server instance as a
back-end node of this load balancer.r7  …r8  }r9  (h"j4  h#j2  ubaubhp)r:  }r;  (h"X›  $loadBalancerService = $client->loadBalancerService('cloudLoadBalancers', 'DFW');

$loadBalancer = $loadBalancerService->loadBalancer();

$loadBalancer->name = 'Load balancer - DB';
$loadBalancer->addNode($dbInstance->hostname, 3306);
$loadBalancer->port = 3306;
$loadBalancer->protocol = 'MYSQL';
$loadBalancer->addVirtualIp('PUBLIC');

$loadBalancer->create();

$loadBalancer->waitFor(State::ACTIVE, null, function ($lb) {
    printf("Load balancer build status: %s\n", $lb->status);
});

foreach ($loadBalancer->virtualIps as $vip) {
    if ($vip->type == 'PUBLIC') {
        printf("Load balancer public %s address: %s\n", $vip->ipVersion, $vip->address);
    }
}h#j  h$h%h&hsh(}r<  (huhvh-]h,]h*]h+]r=  (hxX   phpr>  eh/]uh1Krh2hh]r?  h{)r@  }rA  (h"X›  $loadBalancerService = $client->loadBalancerService('cloudLoadBalancers', 'DFW');

$loadBalancer = $loadBalancerService->loadBalancer();

$loadBalancer->name = 'Load balancer - DB';
$loadBalancer->addNode($dbInstance->hostname, 3306);
$loadBalancer->port = 3306;
$loadBalancer->protocol = 'MYSQL';
$loadBalancer->addVirtualIp('PUBLIC');

$loadBalancer->create();

$loadBalancer->waitFor(State::ACTIVE, null, function ($lb) {
    printf("Load balancer build status: %s\n", $lb->status);
});

foreach ($loadBalancer->virtualIps as $vip) {
    if ($vip->type == 'PUBLIC') {
        printf("Load balancer public %s address: %s\n", $vip->ipVersion, $vip->address);
    }
}h(}rB  (h*]h+]rC  UotherrD  ah,]h-]h/]uh#j:  h]rE  h;X›  $loadBalancerService = $client->loadBalancerService('cloudLoadBalancers', 'DFW');

$loadBalancer = $loadBalancerService->loadBalancer();

$loadBalancer->name = 'Load balancer - DB';
$loadBalancer->addNode($dbInstance->hostname, 3306);
$loadBalancer->port = 3306;
$loadBalancer->protocol = 'MYSQL';
$loadBalancer->addVirtualIp('PUBLIC');

$loadBalancer->create();

$loadBalancer->waitFor(State::ACTIVE, null, function ($lb) {
    printf("Load balancer build status: %s\n", $lb->status);
});

foreach ($loadBalancer->virtualIps as $vip) {
    if ($vip->type == 'PUBLIC') {
        printf("Load balancer public %s address: %s\n", $vip->ipVersion, $vip->address);
    }
}rF  …rG  }rH  (h"U h#j@  ubah&h…ubaubh?)rI  }rJ  (h"Xd  In the example above, a load balancer is created with the database
server instance as its only back-end node. Further, this load balancer
is configured to listen for MySQL connections on port 3306. Finally a
virtual IP address (VIP) is configured in the ``PUBLIC`` network address
space so that this load balancer may receive connections from the
Internet.h#j  h$h%h&hBh(}rK  (h*]h+]h,]h-]h/]uh1Ksh2hh]rL  (h;Xþ   In the example above, a load balancer is created with the database
server instance as its only back-end node. Further, this load balancer
is configured to listen for MySQL connections on port 3306. Finally a
virtual IP address (VIP) is configured in the rM  …rN  }rO  (h"Xþ   In the example above, a load balancer is created with the database
server instance as its only back-end node. Further, this load balancer
is configured to listen for MySQL connections on port 3306. Finally a
virtual IP address (VIP) is configured in the h#jI  ubhÏ)rP  }rQ  (h"X
   ``PUBLIC``h(}rR  (h*]h+]h,]h-]h/]uh#jI  h]rS  h;X   PUBLICrT  …rU  }rV  (h"U h#jP  ubah&h×ubh;X\    network address
space so that this load balancer may receive connections from the
Internet.rW  …rX  }rY  (h"X\    network address
space so that this load balancer may receive connections from the
Internet.h#jI  ubeubh?)rZ  }r[  (h"Xü   Once the load balancer is created and becomes ``ACTIVE``, it's
Internet-accessible IP addresses are printed out. If you connect to any
of these IP addresses on port 3306 using the MySQL protocol, you will be
connected to the database created in step 3.h#j  h$h%h&hBh(}r\  (h*]h+]h,]h-]h/]uh1Kzh2hh]r]  (h;X.   Once the load balancer is created and becomes r^  …r_  }r`  (h"X.   Once the load balancer is created and becomes h#jZ  ubhÏ)ra  }rb  (h"X
   ``ACTIVE``h(}rc  (h*]h+]h,]h-]h/]uh#jZ  h]rd  h;X   ACTIVEre  …rf  }rg  (h"U h#ja  ubah&h×ubh;XÄ   , it's
Internet-accessible IP addresses are printed out. If you connect to any
of these IP addresses on port 3306 using the MySQL protocol, you will be
connected to the database created in step 3.rh  …ri  }rj  (h"XÄ   , it's
Internet-accessible IP addresses are printed out. If you connect to any
of these IP addresses on port 3306 using the MySQL protocol, you will be
connected to the database created in step 3.h#jZ  ubeubeubeubeubah"U Utransformerrk  NUfootnote_refsrl  }rm  Urefnamesrn  }ro  Usymbol_footnotesrp  ]rq  Uautofootnote_refsrr  ]rs  Usymbol_footnote_refsrt  ]ru  U	citationsrv  ]rw  h2hUcurrent_linerx  NUtransform_messagesry  ]rz  Ureporterr{  NUid_startr|  KUautofootnotesr}  ]r~  Ucitation_refsr  }r€  Uindirect_targetsr  ]r‚  Usettingsrƒ  (cdocutils.frontend
Values
r„  or…  }r†  (Ufootnote_backlinksr‡  KUrecord_dependenciesrˆ  NUrfc_base_urlr‰  Uhttp://tools.ietf.org/html/rŠ  U	tracebackr‹  ˆUpep_referencesrŒ  NUstrip_commentsr  NUtoc_backlinksrŽ  Uentryr  Ulanguage_coder  Uenr‘  U	datestampr’  NUreport_levelr“  KU_destinationr”  NU
halt_levelr•  KUstrip_classesr–  Nh8NUerror_encoding_error_handlerr—  Ubackslashreplacer˜  Udebugr™  NUembed_stylesheetrš  ‰Uoutput_encoding_error_handlerr›  Ustrictrœ  Usectnum_xformr  KUdump_transformsrž  NUdocinfo_xformrŸ  KUwarning_streamr   NUpep_file_url_templater¡  Upep-%04dr¢  Uexit_status_levelr£  KUconfigr¤  NUstrict_visitorr¥  NUcloak_email_addressesr¦  ˆUtrim_footnote_reference_spacer§  ‰Uenvr¨  NUdump_pseudo_xmlr©  NUexpose_internalsrª  NUsectsubtitle_xformr«  ‰Usource_linkr¬  NUrfc_referencesr­  NUoutput_encodingr®  Uutf-8r¯  U
source_urlr°  NUinput_encodingr±  U	utf-8-sigr²  U_disable_configr³  NU	id_prefixr´  U U	tab_widthrµ  KUerror_encodingr¶  UUTF-8r·  U_sourcer¸  h%Ugettext_compactr¹  ˆU	generatorrº  NUdump_internalsr»  NUsmart_quotesr¼  ‰Upep_base_urlr½  Uhttp://www.python.org/dev/peps/r¾  Usyntax_highlightr¿  UlongrÀ  Uinput_encoding_error_handlerrÁ  jœ  Uauto_id_prefixrÂ  UidrÃ  Udoctitle_xformrÄ  ‰Ustrip_elements_with_classesrÅ  NU_config_filesrÆ  ]Ufile_insertion_enabledrÇ  ˆUraw_enabledrÈ  KUdump_settingsrÉ  NubUsymbol_footnote_startrÊ  K UidsrË  }rÌ  (hhThh hhÛhj  hh†hh«hhbuUsubstitution_namesrÍ  }rÎ  h&h2h(}rÏ  (h*]h-]h,]Usourceh%h+]h/]uU	footnotesrÐ  ]rÑ  UrefidsrÒ  }rÓ  ub.