diff --git a/firstapp/samples/pkgcloud/getting_started.js b/firstapp/samples/pkgcloud/getting_started.js new file mode 100644 index 000000000..90142ec2a --- /dev/null +++ b/firstapp/samples/pkgcloud/getting_started.js @@ -0,0 +1,182 @@ +// step-1 + +auth_username = 'your_auth_username'; +auth_password = 'your_auth_password'; +auth_url = 'http://controller:5000'; +project_name = 'your_project_name_or_id'; +region_name = 'your_region_name'; + + +var conn = require('pkgcloud').compute.createClient({ + provider: 'openstack', + username: auth_username, + password: auth_password, + authUrl:auth_url, + region: region_name +}); + + +// step-2 +conn.getImages(function(err, images) { + for (i =0; i`_. -Future versions of this guide will show you how to use the OpenStack SDK and -languages such as Java and Ruby to complete these tasks. If you're a developer -for another toolkit that you would like this guide to include, feel free to -submit code snippets. You can also contact OpenStack Documentation team -members. +Other versions of this guide show you how to use the other SDKs and +languages to complete these tasks. If you're a developer for another toolkit +that you would like this guide to include, feel free to submit code snippets. +You can contact `OpenStack Documentation team `_ +members for more information. What you need ------------- @@ -118,14 +117,12 @@ To interact with the cloud, you must also have `libcloud 0.15.1 or higher installed `_. -.. only:: node +.. only:: pkgcloud - `a recent version of pkgcloud installed + `pkgcloud 1.2 or higher installed `_. - .. warning:: - - This document has not yet been completed for the pkgcloud SDK. + .. highlight:: javascript .. only:: openstacksdk @@ -173,8 +170,8 @@ How you'll interact with OpenStack ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In this tutorial, you interact with your OpenStack cloud through one of the -SDKs listed in "Choose your OpenStack SDK." The code snippets in this -initial version of the guide assume that you're using Libcloud. +SDKs you have chosen in "Choose your OpenStack SDK." This guide assumes you +are familiar with running code snippets in your language of choice. .. only:: fog @@ -200,8 +197,17 @@ initial version of the guide assume that you're using Libcloud. user_name="your_auth_username", password="your_auth_password", ...) +.. only:: pkgcloud -.. note:: Because the tutorial uses the :code:`conn` object, + To try it, add the following code to a script (or use an + interactive nodejs shell) by calling :code:`node`. + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-1 + :end-before: step-2 + + +.. note:: Because the tutorial reuses the :code:`conn` object, make sure that you always have one handy. .. only:: libcloud @@ -247,6 +253,30 @@ To list the images that are available in your cloud, run some API calls: +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-2 + :end-before: step-3 + + You should see a result something like: + + .. code-block:: none + + id: 6c7f5627-ca40-4781-ac34-4d9af53d4b29 + name: Fedora 22 - Updated + created: 2015-08-17T03:53:17Z + updated: 2015-08-17T04:53:12Z + status: ACTIVE + + ... + id: 2cccbea0-cea9-4f86-a3ed-065c652adda5 + name: Ubuntu 14.04 + created: 2015-08-13T02:25:10Z + updated: 2015-08-13T02:43:38Z + status: ACTIVE + + You can also get information about available flavors: .. only:: fog @@ -271,6 +301,28 @@ You can also get information about available flavors: +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-3 + :end-before: step-4 + + This code produces output like: + + .. code-block:: none + + id: c46104de-d5fd-4567-ab0b-3dcfd117bd99 + name: m2.xlarge + ram: 49152 + disk: 30 + vcpus: 12 + + ... + id: cba9ea52-8e90-468b-b8c2-777a94d81ed3 + name: m1.small + ram: 2048 + disk: 20 + vcpus: 1 Your images and flavors will be different, of course. @@ -309,7 +361,24 @@ image that you picked in the previous section: -Next, tell the script which flavor you want to use: +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-4 + :end-before: step-5 + + You should see output something like this: + + .. code-block:: none + + id: 2cccbea0-cea9-4f86-a3ed-065c652adda5 + name: Ubuntu 14.04 + created: 2015-08-13T02:25:10Z + updated: 2015-08-13T02:43:38Z + status: ACTIVE + + +Next, choose which flavor you want to use: .. only:: fog @@ -329,6 +398,24 @@ Next, tell the script which flavor you want to use: +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-5 + :end-before: step-6 + + You should see output something like this: + + .. code-block:: none + + + id: 3 + name: m1.small + ram: 2048 + disk: 20 + vcpus: 1 + + Now, you're ready to launch the instance. Launch an instance @@ -336,14 +423,12 @@ Launch an instance Use your selected image and flavor to create an instance. -.. only:: libcloud - - .. note:: The following instance creation example assumes that you have a - single-tenant network. If you receive the 'Exception: 400 Bad - Request Multiple possible networks found, use a Network ID to be - more specific' error, you have multiple-tenant networks. You - must add a `networks` parameter to the `create_node` call. See - :doc:`/appendix` for details. +.. note:: The following instance creation example assumes that you have a + single-tenant network. If you receive the 'Exception: 400 Bad + Request Multiple possible networks found, use a Network ID to be + more specific' error, you have multiple-tenant networks. You + must add a `networks` parameter to the call that creates the + server. See :doc:`/appendix` for details. Create the instance. @@ -378,6 +463,19 @@ Create the instance. } instance = conn.compute.create_server(**args) +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-6 + :end-before: step-7 + + You should see output something like: + + .. code-block:: none + + 0d7968dc-4bf4-4e01-b822-43c9c1080d77 + + If you list existing instances: .. only:: fog @@ -392,6 +490,12 @@ If you list existing instances: :start-after: step-7 :end-before: step-8 +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-7 + :end-before: step-8 + The new instance appears. .. only:: libcloud @@ -408,6 +512,27 @@ The new instance appears. for instance in instances: print(instance) +.. only:: pkgcloud + + .. code-block:: none + + ... + id: '0d7968dc-4bf4-4e01-b822-43c9c1080d77', + name: 'testing', + status: 'PROVISIONING', + progress: 0, + imageId: '2cccbea0-cea9-4f86-a3ed-065c652adda5', + adminPass: undefined, + addresses: {}, + metadata: {}, + flavorId: '3', + hostId: 'b6ee757ed678e8c6589ae8cce405eeded89ac914daec73e45a5c50b8', + created: '2015-06-30T08:17:39Z', + updated: '2015-06-30T08:17:44Z', + ... + + + Before you move on, you must do one more thing. Destroy an instance @@ -428,6 +553,13 @@ money. Destroy cloud resources to avoid unexpected expenses. :start-after: step-8 :end-before: step-9 +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-8 + :end-before: step-9 + + If you list the instances again, the instance disappears. @@ -475,6 +607,15 @@ instance: +.. only:: pkgcloud + + In the following example, :code:`pub_key_file` should be set to + the location of your public SSH key file. + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-9 + :end-before: step-10 + * Network access. By default, OpenStack filters all traffic. You must create a security group and apply it to your instance. The security group allows HTTP and SSH access. We'll go into more detail in :doc:`/introduction`. @@ -491,6 +632,12 @@ instance: :start-after: step-10 :end-before: step-11 +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-10 + :end-before: step-11 + * Userdata. During instance creation, you can provide userdata to OpenStack to configure instances after they boot. The cloud-init service applies the userdata to an instance. You must pre-install the cloud-init service on your @@ -506,6 +653,12 @@ instance: :start-after: step-11 :end-before: step-12 +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-11 + :end-before: step-12 + Now, you can boot and configure the instance. Boot and configure an instance @@ -524,6 +677,13 @@ request the instance, wait for it to build. :start-after: step-12 :end-before: step-13 +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-12 + :end-before: step-13 + + When the instance boots, the `ex_userdata` variable value instructs the instance to deploy the Fractals application. @@ -568,6 +728,30 @@ address to your instance. :start-after: step-14 :end-before: step-15 + +.. only:: pkgcloud + + Use :code:`getFloatingIps` to check for unused addresses, selecting the + first one if available, otherwise use :code:`allocateNewFloatingIp` to + allocate a new Floating IP to your project from the default address pool. + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-13 + :end-before: step-14 + + You should see the floating IP output to the command line: + + :: + + 203.0.113.101 + + You can then attach it to the instance: + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-14 + :end-before: step-15 + + Run the script to start the deployment. Access the application @@ -583,6 +767,11 @@ using your preferred browser. .. literalinclude:: ../samples/libcloud/getting_started.py :start-after: step-15 +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :start-after: step-15 + .. note:: If you do not use floating IPs, substitute another IP address as appropriate .. figure:: images/screenshot_webinterface.png @@ -623,3 +812,8 @@ information, the flavor ID, and image ID. .. literalinclude:: ../samples/libcloud/getting_started.py :language: python + +.. only:: pkgcloud + + .. literalinclude:: ../samples/pkgcloud/getting_started.js + :language: javascript diff --git a/firstapp/source/introduction.rst b/firstapp/source/introduction.rst index 3556267fe..88f4f9f93 100644 --- a/firstapp/source/introduction.rst +++ b/firstapp/source/introduction.rst @@ -20,7 +20,7 @@ particular. It also describes some commands in the previous section. .. warning:: This section has not yet been completed for the jclouds SDK. -.. only:: node +.. only:: pkgcloud .. warning:: This section has not yet been completed for the pkgcloud SDK. diff --git a/firstapp/source/networking.rst b/firstapp/source/networking.rst index b2c86da7f..b30d58c93 100644 --- a/firstapp/source/networking.rst +++ b/firstapp/source/networking.rst @@ -46,7 +46,7 @@ the database, webserver, file storage, and worker components. .. warning:: Libcloud does not support the OpenStack Networking API. -.. only:: node +.. only:: pkgcloud .. warning:: Pkgcloud supports the OpenStack Networking API, but this section has not been completed. diff --git a/firstapp/source/orchestration.rst b/firstapp/source/orchestration.rst index 513f77d72..ae6c301fc 100644 --- a/firstapp/source/orchestration.rst +++ b/firstapp/source/orchestration.rst @@ -69,7 +69,7 @@ http://docs.openstack.org/cli-reference/content/cli_openrc.html .. warning:: libcloud does not currently support OpenStack Orchestration. -.. only:: node +.. only:: pkgcloud .. note:: Pkgcloud supports OpenStack Orchestration :D:D:D but this section is `not written yet `_ diff --git a/tox.ini b/tox.ini index 7b51b5473..30cf109e2 100644 --- a/tox.ini +++ b/tox.ini @@ -100,8 +100,8 @@ commands = sphinx-build -E -W -t fog firstapp/source firstapp/build-fog/html [testenv:firstapp-dotnet] commands = sphinx-build -E -W -t dotnet firstapp/source firstapp/build-dotnet/html -[testenv:firstapp-node] -commands = sphinx-build -E -W -t node firstapp/source firstapp/build-node/html +[testenv:firstapp-pkgcloud] +commands = sphinx-build -E -W -t pkgcloud firstapp/source firstapp/build-pkgcloud/html [testenv:firstapp-openstacksdk] commands = sphinx-build -E -W -t openstacksdk firstapp/source firstapp/build-openstacksdk/html