Sfoglia il codice sorgente

Added docs on block device mappings. Rolled back glance images to nova.

Nuwan Goonasekera 10 anni fa
parent
commit
18d4a2b87e

+ 15 - 16
cloudbridge/cloud/providers/openstack/impl.py

@@ -6,7 +6,6 @@ compatible clouds.
 import os
 
 from cinderclient import client as cinder_client
-from glanceclient import client as glance_client
 from keystoneclient import client as keystone_client
 from keystoneclient import session
 from keystoneclient.auth.identity import Password
@@ -66,11 +65,11 @@ class OpenStackCloudProvider(BaseCloudProvider):
             self._keystone = self._connect_keystone()
         return self._keystone
 
-    @property
-    def glance(self):
-        if not self._glance:
-            self._glance = self._connect_glance()
-        return self._glance
+#     @property
+#     def glance(self):
+#         if not self._glance:
+#             self._glance = self._connect_glance()
+#         return self._glance
 
     @property
     def cinder(self):
@@ -158,16 +157,16 @@ class OpenStackCloudProvider(BaseCloudProvider):
             api_version, username=self.username, api_key=self.password,
             project_id=self.tenant_name, auth_url=self.auth_url)
 
-    def _connect_glance(self):
-        """
-        Get an openstack glance client object for the given cloud.
-        """
-        api_version = self._get_config_value(
-            'os_image_api_version',
-            os.environ.get('OS_IMAGE_API_VERSION', 1))
-
-        return glance_client.Client(version=api_version,
-                                    session=self.keystone.session)
+#     def _connect_glance(self):
+#         """
+#         Get an openstack glance client object for the given cloud.
+#         """
+#         api_version = self._get_config_value(
+#             'os_image_api_version',
+#             os.environ.get('OS_IMAGE_API_VERSION', 1))
+#
+#         return glance_client.Client(version=api_version,
+#                                     session=self.keystone.session)
 
     def _connect_swift(self):
         """

+ 6 - 6
cloudbridge/cloud/providers/openstack/resources.py

@@ -29,12 +29,12 @@ class OpenStackMachineImage(BaseMachineImage):
 
     # ref: http://docs.openstack.org/developer/glance/statuses.html
     IMAGE_STATE_MAP = {
-        'queued': MachineImageState.PENDING,
-        'saving': MachineImageState.PENDING,
-        'active': MachineImageState.AVAILABLE,
-        'killed': MachineImageState.ERROR,
-        'deleted': MachineImageState.ERROR,
-        'pending_delete': MachineImageState.ERROR
+        'QUEUED': MachineImageState.PENDING,
+        'SAVING': MachineImageState.PENDING,
+        'ACTIVE': MachineImageState.AVAILABLE,
+        'KILLED': MachineImageState.ERROR,
+        'DELETED': MachineImageState.ERROR,
+        'PENDING_DELETE': MachineImageState.ERROR
     }
 
     def __init__(self, provider, os_image):

+ 4 - 5
cloudbridge/cloud/providers/openstack/services.py

@@ -5,7 +5,6 @@ import fnmatch
 import re
 
 from cinderclient.exceptions import NotFound as CinderNotFound
-from glanceclient.exc import HTTPNotFound
 from novaclient.exceptions import NotFound as NovaNotFound
 
 from cloudbridge.cloud.base import BaseBlockStoreService
@@ -215,8 +214,8 @@ class OpenStackImageService(BaseImageService):
         """
         try:
             return OpenStackMachineImage(
-                self.provider, self.provider.glance.images.get(image_id))
-        except HTTPNotFound:
+                self.provider, self.provider.nova.images.get(image_id))
+        except NovaNotFound:
             return None
 
     def find(self, name, limit=None, marker=None):
@@ -236,10 +235,10 @@ class OpenStackImageService(BaseImageService):
         List all images.
         """
         if marker is None:
-            os_images = self.provider.glance.images.list(
+            os_images = self.provider.nova.images.list(
                 limit=oshelpers.os_result_limit(self.provider, limit))
         else:
-            os_images = self.provider.glance.images.list(
+            os_images = self.provider.nova.images.list(
                 limit=oshelpers.os_result_limit(self.provider, limit),
                 marker=marker)
 

+ 1 - 1
docs/concepts.rst

@@ -33,7 +33,7 @@ between services.
 
 .. raw:: html
 
-   <object data="_static/object_relationships_detailed.svg" type="image/svg+xml"></object>
+   <object data="_images/object_relationships_detailed.svg" type="image/svg+xml"></object>
 
 Some services are nested. For example, to access the instance service, you can
 use `provider.compute.instances`. Similarly, to get a list of all instances,

+ 1 - 1
docs/conf.py

@@ -151,7 +151,7 @@ html_static_path = ['_static']
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
 # directly to the root of the documentation.
-#html_extra_path = []
+html_extra_path = ['extras']
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.

File diff suppressed because it is too large
+ 75 - 0
docs/extras/_images/object_relationships_detailed.svg


+ 1 - 1
docs/index.rst

@@ -34,7 +34,7 @@ that they return. Click on any object to drill down into its details.
 
 .. raw:: html
 
-   <object data="_static/object_relationships_detailed.svg" type="image/svg+xml"></object>
+   <object data="_images/object_relationships_detailed.svg" type="image/svg+xml"></object>
 
 Installation
 ------------

+ 2 - 2
docs/topics/install.rst

@@ -15,7 +15,7 @@ Installation
 
     pip install cloudbridge[dev]
 
-This will install additional libraries required by cloudbridge contributors, such as tox.
+This will install additional libraries required by CloudBridge contributors, such as tox.
 
-**Prerequisites**: Cloudbridge runs on Python 2.7 and higher. Python 3 is recommended.
+**Prerequisites**: CloudBridge runs on Python 2.7 and higher. Python 3 is recommended.
 

+ 22 - 3
docs/topics/launch.rst

@@ -15,7 +15,7 @@ AWS so feel free to change it as desired.
 .. code-block:: python
 
     img = provider.compute.images.get('ami-d85e75b0')
-    inst_type = provider.compute.instance_types.find(name='m1.small')
+    inst_type = provider.compute.instance_types.find(name='m1.small')[0]
 
 When launching an instance, you can also specify several optional arguments
 such as the security group, a key pair, or instance user data. To allow you to
@@ -61,9 +61,28 @@ For OpenStack, the process is the same and you only need to specify the
 appropriate network interface ID (e.g.,
 ``lc.add_network_interface('5820c766-75fe-4fc6-96ef-798f67623238')``).
 
-------------
+Block Device Mapping
+--------------------
+Optionally, you may want to provide a block device mapping at launch,
+specifying volume or ephemeral storage mappings for the instance. While volumes
+can also be attached and mapped after instance boot using the volume service,
+specifying block device mappings at launch time is especially useful when it is
+necessary to resize the root volume.
 
-After an instance has launched, you can access it's properties:
+The code below demonstrates how to resize the root volume. For more information,
+refer to :class:`.LaunchConfig`.
+
+.. code-block:: python
+
+    lc = provider.compute.instances.create_launch_config()
+    lc.add_volume_device(source=img, size=11, is_root=True)
+    inst = provider.compute.instances.create(
+        name='Cloudbridge-BDM', image=img,  instance_type=inst_type,
+        launch_config=lc, keypair=kp, security_groups=[sg])
+
+where img is the :class:`.Image` object to use for the root volume.
+
+After an instance has launched, you can access its properties:
 
 .. code-block:: python
 

Some files were not shown because too many files changed in this diff