Example #1
0
    def _create_snapshot(self, volume_id, force=False, **kwargs):
        """Create one snapshot.

        Returns when the snapshot is actually created and is in the "Available"
        state.

        :param volume_id: volume uuid for creating snapshot
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created snapshot object
        """
        kwargs["force"] = force

        client = cinder_wrapper.wrap(self._clients.cinder, self)
        snapshot = client.create_snapshot(volume_id, **kwargs)

        self.sleep_between(CONF.benchmark.cinder_volume_create_prepoll_delay)
        snapshot = bench_utils.wait_for(
            snapshot,
            ready_statuses=["available"],
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval)
        return snapshot
Example #2
0
    def _create_volume(self, size, **kwargs):
        """Create one volume.

        Returns when the volume is actually created and is in the "Available"
        state.

        :param size: int be size of volume in GB, or
                     dictionary, must contain two values:
                         min - minimum size volumes will be created as;
                         max - maximum size volumes will be created as.
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created volume object
        """
        if isinstance(size, dict):
            size = random.randint(size["min"], size["max"])

        client = cinder_wrapper.wrap(self._clients.cinder, self)
        volume = client.create_volume(size, **kwargs)

        # NOTE(msdubov): It is reasonable to wait 5 secs before starting to
        #                check whether the volume is ready => less API calls.
        self.sleep_between(CONF.benchmark.cinder_volume_create_prepoll_delay)

        volume = bench_utils.wait_for(
            volume,
            ready_statuses=["available"],
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval)
        return volume
Example #3
0
    def _create_volume(self, size, **kwargs):
        """Create one volume.

        Returns when the volume is actually created and is in the "Available"
        state.

        :param size: int be size of volume in GB, or
                     dictionary, must contain two values:
                         min - minimum size volumes will be created as;
                         max - maximum size volumes will be created as.
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created volume object
        """
        if isinstance(size, dict):
            size = random.randint(size["min"], size["max"])

        client = cinder_wrapper.wrap(self._clients.cinder, self)
        volume = client.create_volume(size, **kwargs)

        # NOTE(msdubov): It is reasonable to wait 5 secs before starting to
        #                check whether the volume is ready => less API calls.
        self.sleep_between(CONF.openstack.cinder_volume_create_prepoll_delay)

        volume = bench_utils.wait_for_status(
            volume,
            ready_statuses=["available"],
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.openstack.cinder_volume_create_timeout,
            check_interval=CONF.openstack.cinder_volume_create_poll_interval
        )
        return volume
Example #4
0
    def _create_snapshot(self, volume_id, force=False, **kwargs):
        """Create one snapshot.

        Returns when the snapshot is actually created and is in the "Available"
        state.

        :param volume_id: volume uuid for creating snapshot
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created snapshot object
        """
        kwargs["force"] = force

        client = cinder_wrapper.wrap(self._clients.cinder, self)
        snapshot = client.create_snapshot(volume_id, **kwargs)

        self.sleep_between(CONF.openstack.cinder_volume_create_prepoll_delay)
        snapshot = bench_utils.wait_for_status(
            snapshot,
            ready_statuses=["available"],
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.openstack.cinder_volume_create_timeout,
            check_interval=CONF.openstack.cinder_volume_create_poll_interval
        )
        return snapshot
Example #5
0
    def _update_volume(self, volume, **update_volume_args):
        """Update name and description for this volume

        This atomic function updates volume information. The volume
        display name is always changed, and additional update
        arguments may also be specified.

        :param volume: volume object
        :param update_volume_args: dict, contains values to be updated.
        """
        client = cinder_wrapper.wrap(self._clients.cinder, self)
        client.update_volume(volume, **update_volume_args)
Example #6
0
    def _update_volume(self, volume, **update_volume_args):
        """Update name and description for this volume

        This atomic function updates volume information. The volume
        display name is always changed, and additional update
        arguments may also be specified.

        :param volume: volume object
        :param update_volume_args: dict, contains values to be updated.
        """
        client = cinder_wrapper.wrap(self._clients.cinder, self)
        client.update_volume(volume, **update_volume_args)
Example #7
0
 def setUp(self):
     super(CinderV2WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.choose_version.return_value = "2"
     self.owner = mock.Mock()
     self.wrapped_client = cinder_wrapper.wrap(self.client, self.owner)
Example #8
0
 def test_wrap(self, version, expected_class):
     client = mock.MagicMock()
     client.choose_version.return_value = version
     self.assertIsInstance(cinder_wrapper.wrap(client, mock.Mock()),
                           expected_class)
Example #9
0
 def setUp(self):
     super(CinderV2WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.choose_version.return_value = "2"
     self.owner = mock.Mock()
     self.wrapped_client = cinder_wrapper.wrap(self.client, self.owner)
Example #10
0
 def test_wrap(self, version, expected_class):
     client = mock.MagicMock()
     client.choose_version.return_value = version
     self.assertIsInstance(cinder_wrapper.wrap(client, mock.Mock()),
                           expected_class)