Example #1
0
    def test_get(self):
        """Test that we can get public and private IP addresses."""

        # Grab the server's addresses...
        addrs = self.server.addresses

        # Make sure the public and private lists are present
        dtutil.assert_true('public' in addrs)
        dtutil.assert_true('private' in addrs)
Example #2
0
def mk_instance(os, *args, **kwargs):
    """Create an instance.

    The os parameter specifies an OpenStack instance to use; may be
    None, in which case one will be set up.  If the provided instance
    is not wrapped by OpenStackWrapped, it will be so wrapped, to
    provide statistics information.  The required creation arguments,
    if not present, will default to appropriate values.  The creation
    time required is tracked in the create_time statistics tracker.

    Returns the created instance, or raises an exception (possibly
    AssertionError) if creation is unsuccessful.
    """

    # Make sure we have an openstack handle
    if not os:
        os = OpenStackWrapped.getOpenStack()

    # Make sure it's wrapped
    if not isinstance(os, OpenStackWrapped):
        os = OpenStackWrapped(os)

    # Also ensure the instance has a name...
    if len(args) < 1 and 'name' not in kwargs:
        kwargs['name'] = base.BaseIntegrationTest.randName()

    # ...an image ID...
    if len(args) < 2 and 'image' not in kwargs:
        kwargs['image'] = FLAGS.image

    # ...and a flavor ID
    if len(args) < 3 and 'flavor' not in kwargs:
        kwargs['flavor'] = FLAGS.flavor

    # We now have the arguments for the create call, but we need to
    # follow it through the required states
    states = utils.StatusTracker('active', 'build', 'active')

    # Now, kick off the create...
    start = time.time()
    new_server = os.servers.create(*args, **kwargs)

    # And wait for it to finish
    dtutil.assert_true(states.waitForState(os.servers.get, 'status',
                                           new_server))
    end = time.time()

    # Store the create time data in our create_time statistics
    # container
    create_time.append((end - start) * 1000.0)

    # Return the new server
    return new_server
Example #3
0
    def test_list(self):
        """Test that images can be listed."""

        # See if we can retrieve the list of images
        images = self.os.images.list()

        # Do we have a list?
        dtutil.assert_not_equal(len(images), 0)

        # Let's see if our test image is in the list
        foundimg = False
        for img in images:
            if img.id == self._image_id:
                dtutil.assert_equal(img.name, self._image_name)
                dtutil.assert_equal(img.status, 'ACTIVE')
                foundimg = True

        # Did we actually find the image we were looking for?
        dtutil.assert_true(foundimg)