예제 #1
0
    def create(self,
               size,
               name=None,
               create_from_image=False,
               timeout=LONG_TIMEOUT):
        if name is None:
            name = "KarborFullstack-Volume-{id}".format(
                id=self.__class__._name_id)
            self.__class__._name_id += 1

        self._name = name
        image = None
        if create_from_image:
            images = self.glance_client.images.list()
            for image_iter in images:
                if image_iter['disk_format'] not in ('aki', 'ari') and (
                        image_iter['name'].startswith('cirros')):
                    image = image_iter['id']
                    break
            assert image
        volume = self.cinder_client.volumes.create(size,
                                                   name=name,
                                                   imageRef=image)
        self.id = volume.id
        utils.wait_until_true(partial(self._volume_status, 'available'),
                              timeout=timeout,
                              sleep=MEDIUM_SLEEP)
        return self.id
    def test_scheduled_operations_create_and_scheduled(self):
        freq = 2
        eventlet_grace = 20
        pattern = "BEGIN:VEVENT\nRRULE:FREQ=MINUTELY;INTERVAL=2;\nEND:VEVENT"
        cur_property = {'pattern': pattern, 'format': 'calendar'}

        operation = self.store(self._create_for_volume(cur_property))
        start_time = datetime.now().replace(microsecond=0)
        sleep_time = self._wait_timestamp(pattern, start_time, freq)
        sleep_time += eventlet_grace
        self.assertNotEqual(0, sleep_time)
        eventlet.sleep(sleep_time)

        items = self.karbor_client.checkpoints.list(self.provider_id)
        operation_item = self.karbor_client.scheduled_operations.get(
            operation.id)
        plan_id = operation_item.operation_definition["plan_id"]
        cps = filter(lambda x: x.protection_plan["id"] == plan_id, items)
        self.assertEqual(freq, len(cps))

        for cp in cps:
            utils.wait_until_true(partial(
                self._checkpoint_status, cp.id,
                constants.CHECKPOINT_STATUS_AVAILABLE),
                                  timeout=objects.LONG_TIMEOUT,
                                  sleep=objects.LONG_SLEEP)
            checkpoint = self.store(objects.Checkpoint())
            checkpoint._provider_id = self.provider_id
            checkpoint.id = cp.id
예제 #3
0
 def close(self, timeout=LONG_TIMEOUT):
     try:
         self.karbor_client.checkpoints.delete(self._provider_id, self.id)
     except Exception:
         return
     utils.wait_until_true(partial(self._checkpoint_status,
                                   constants.CHECKPOINT_STATUS_DELETED),
                           timeout=timeout, sleep=LONG_SLEEP)
예제 #4
0
 def close(self, timeout=LONG_TIMEOUT):
     try:
         self.karbor_client.checkpoints.delete(self._provider_id, self.id)
     except Exception:
         return
     utils.wait_until_true(partial(self._checkpoint_status,
                                   constants.CHECKPOINT_STATUS_DELETED),
                           timeout=timeout, sleep=LONG_SLEEP)
예제 #5
0
 def create(self, provider_id, plan_id, timeout=LONG_TIMEOUT):
     self._provider_id = provider_id
     checkpoint = self.karbor_client.checkpoints.create(provider_id,
                                                        plan_id)
     self.id = checkpoint.id
     utils.wait_until_true(partial(self._checkpoint_status,
                                   constants.CHECKPOINT_STATUS_AVAILABLE),
                           timeout=timeout, sleep=LONG_SLEEP)
     return self.id
예제 #6
0
 def create(self, provider_id, plan_id, timeout=LONG_TIMEOUT):
     self._provider_id = provider_id
     checkpoint = self.karbor_client.checkpoints.create(provider_id,
                                                        plan_id)
     self.id = checkpoint.id
     utils.wait_until_true(partial(self._checkpoint_status,
                                   constants.CHECKPOINT_STATUS_AVAILABLE),
                           timeout=timeout, sleep=LONG_SLEEP)
     return self.id
예제 #7
0
 def create(self, provider_id, checkpoint_id, target, parameters,
            restore_auth, timeout=LONG_TIMEOUT):
     restore = self.karbor_client.restores.create(provider_id,
                                                  checkpoint_id,
                                                  target,
                                                  parameters,
                                                  restore_auth)
     self.id = restore.id
     utils.wait_until_true(partial(self._restore_status, 'success'),
                           timeout=timeout, sleep=LONG_SLEEP)
     return self.id
예제 #8
0
    def create(self, size, name=None, timeout=MEDIUM_TIMEOUT):
        if name is None:
            name = "KarborFullstack-Volume-{id}".format(id=self._name_id)
            self._name_id += 1

        self._name = name
        volume = self.cinder_client.volumes.create(size, name=name)
        self.id = volume.id
        utils.wait_until_true(partial(self._volume_status, 'available'),
                              timeout=timeout, sleep=MEDIUM_SLEEP)
        return self.id
예제 #9
0
 def create(self, provider_id, checkpoint_id, target, parameters,
            restore_auth, timeout=LONG_TIMEOUT):
     restore = self.karbor_client.restores.create(provider_id,
                                                  checkpoint_id,
                                                  target,
                                                  parameters,
                                                  restore_auth)
     self.id = restore.id
     utils.wait_until_true(partial(self._restore_status, 'success'),
                           timeout=timeout, sleep=LONG_SLEEP)
     return self.id
예제 #10
0
    def create(self, size, name=None, timeout=MEDIUM_TIMEOUT):
        if name is None:
            name = "KarborFullstack-Volume-{id}".format(id=self._name_id)
            self._name_id += 1

        self._name = name
        volume = self.cinder_client.volumes.create(size, name=name)
        self.id = volume.id
        utils.wait_until_true(partial(self._volume_status, 'available'),
                              timeout=timeout, sleep=MEDIUM_SLEEP)
        return self.id
예제 #11
0
    def create(self, share_proto, size, name=None, timeout=LONG_TIMEOUT):
        if name is None:
            name = "KarborFullstack-Share-{id}".format(id=self._name_id)
            self._name_id += 1

        self._name = name
        share = self.manila_client.shares.create(share_proto, size, name=name)
        self.id = share.id
        utils.wait_until_true(partial(self._share_status, 'available'),
                              timeout=timeout,
                              sleep=MEDIUM_SLEEP)
        return self.id
예제 #12
0
    def create(self,
               name=None,
               image=None,
               volume=None,
               flavor=DEFAULT_FLAVOR,
               network=DEFAULT_NETWORK,
               timeout=LONG_TIMEOUT):
        block_device_mapping_v2 = None
        if volume:
            block_device_mapping_v2 = [{
                'uuid': volume,
                'source_type': 'volume',
                'destination_type': 'volume',
                'boot_index': 0,
                'delete_on_termination': False
            }]
        else:
            if not image:
                images = self.glance_client.images.list()
                for image_iter in images:
                    if image_iter['disk_format'] not in ('aki', 'ari') and (
                            image_iter['name'].startswith('cirros')):
                        image = image_iter['id']
                        break
            assert image
        flavor = self.nova_client.flavors.find(name=flavor)
        if name is None:
            name = "KarborFullstack-Server-{id}".format(
                id=self.__class__._name_id)
            self.__class__._name_id += 1
            self._name = name

        networks = self.neutron_client.list_networks(name=network)
        assert len(networks['networks']) > 0
        network_id = networks['networks'][0]['id']

        server = self.nova_client.servers.create(
            name=name,
            image=image,
            block_device_mapping_v2=block_device_mapping_v2,
            flavor=flavor,
            nics=[{
                "net-id": network_id
            }],
        )
        self.id = server.id

        utils.wait_until_true(partial(self._server_status, 'ACTIVE'),
                              timeout=timeout,
                              sleep=MEDIUM_SLEEP)
        return self.id
예제 #13
0
    def create(self, timeout=MEDIUM_TIMEOUT):
        network = {'name': self._name, 'admin_state_up': True}
        self.neutron_client.create_network({'network': network})

        networks = self.neutron_client.list_networks(name=self._name)
        assert len(networks['networks']) > 0
        network_id = networks['networks'][0]['id']
        self.id = network_id
        self.project_id = networks['networks'][0]['tenant_id']

        utils.wait_until_true(partial(self._network_status, 'ACTIVE'),
                              timeout=timeout,
                              sleep=MEDIUM_SLEEP)

        return self.id
예제 #14
0
    def create(self, name=None, image=DEFAULT_IMAGE, flavor=DEFAULT_FLAVOR,
               timeout=MEDIUM_TIMEOUT):
        image = self.nova_client.images.find(name=image)
        flavor = self.nova_client.flavors.find(name=flavor)
        if name is None:
            name = "KarborFullstack-Server-{id}".format(id=self._name_id)
            self._name_id += 1
            self._name = name

        server = self.nova_client.servers.create(name=name, image=image,
                                                 flavor=flavor)
        self.id = server.id

        utils.wait_until_true(partial(self._server_status, 'ACTIVE'),
                              timeout=timeout, sleep=MEDIUM_SLEEP)
        return self.id
예제 #15
0
    def create(self, name=None, image=DEFAULT_IMAGE, flavor=DEFAULT_FLAVOR,
               timeout=MEDIUM_TIMEOUT):
        image = self.nova_client.images.find(name=image)
        flavor = self.nova_client.flavors.find(name=flavor)
        if name is None:
            name = "KarborFullstack-Server-{id}".format(id=self._name_id)
            self._name_id += 1
            self._name = name

        server = self.nova_client.servers.create(name=name, image=image,
                                                 flavor=flavor)
        self.id = server.id

        utils.wait_until_true(partial(self._server_status, 'ACTIVE'),
                              timeout=timeout, sleep=MEDIUM_SLEEP)
        return self.id
예제 #16
0
 def attach_volume(self, volume_id, timeout=MEDIUM_TIMEOUT):
     self.nova_client.volumes.create_server_volume(self.id, volume_id)
     utils.wait_until_true(partial(self._volume_attached, volume_id),
                           timeout=timeout, sleep=MEDIUM_SLEEP)
예제 #17
0
 def detach_volume(self, volume_id, timeout=MEDIUM_TIMEOUT):
     self.nova_client.volumes.delete_server_volume(self.id, volume_id)
     utils.wait_until_true(partial(self._volume_detached, volume_id),
                           timeout=timeout, sleep=MEDIUM_SLEEP)
예제 #18
0
 def detach_volume(self, volume_id, timeout=MEDIUM_TIMEOUT):
     self.nova_client.volumes.delete_server_volume(self.id, volume_id)
     utils.wait_until_true(partial(self._volume_detached, volume_id),
                           timeout=timeout,
                           sleep=SHORT_SLEEP)