Пример #1
0
    def test_vsa_generate_user_data(self):

        FLAGS.vsa_multi_vol_creation = False
        param = {
            'display_name': 'VSA name test',
            'display_description': 'VSA desc test',
            'vc_count': 2,
            'storage': [{
                'drive_name': 'SATA_500_7200',
                'num_drives': 3
            }]
        }
        vsa_ref = self.vsa_api.create(self.context, **param)
        volumes = self.vsa_api.get_all_vsa_drives(self.context, vsa_ref['id'])

        user_data = vsa_utils.generate_user_data(vsa_ref, volumes)
        user_data = base64.b64decode(user_data)

        LOG.debug(_("Test: user_data = %s"), user_data)

        elem = ElementTree.fromstring(user_data)
        self.assertEqual(elem.findtext('name'), param['display_name'])
        self.assertEqual(elem.findtext('description'),
                         param['display_description'])
        self.assertEqual(elem.findtext('vc_count'), str(param['vc_count']))

        self.vsa_api.delete(self.context, vsa_ref['id'])
Пример #2
0
    def _start_vcs(self, context, vsa, drives=[]):
        """Start VCs for VSA """

        vsa_id = vsa['id']
        if vsa['status'] == VsaState.CREATING:
            self.vsa_api.update_vsa_status(context, vsa_id, VsaState.LAUNCHING)
        else:
            return

        # in _separate_ loop go over all volumes and mark as "attached"
        has_failed_volumes = False
        for drive in drives:
            vol_name = drive['name']
            vol_disp_name = drive['display_name']
            status = drive['status']
            LOG.info(_("VSA ID %(vsa_id)d: Drive %(vol_name)s "\
                        "(%(vol_disp_name)s) is in %(status)s state"),
                        locals())
            if status == 'available':
                try:
                    # self.volume_api.update(context, volume['id'],
                    #                   dict(attach_status="attached"))
                    pass
                except Exception as ex:
                    msg = _("Failed to update attach status for volume "
                            "%(vol_name)s. %(ex)s") % locals()
                    LOG.exception(msg)
            else:
                has_failed_volumes = True

        if has_failed_volumes:
            LOG.info(_("VSA ID %(vsa_id)d: Delete all BE volumes"), locals())
            self.vsa_api.delete_vsa_volumes(context, vsa_id, "BE", True)
            self.vsa_api.update_vsa_status(context, vsa_id, VsaState.FAILED)
            return

        # create user-data record for VC
        storage_data = vsa_utils.generate_user_data(vsa, drives)

        instance_type = instance_types.get_instance_type(
            vsa['instance_type_id'])

        # now start the VC instance

        vc_count = vsa['vc_count']
        LOG.info(_("VSA ID %(vsa_id)d: Start %(vc_count)d instances"),
                 locals())
        vc_instances = self.compute_api.create(
            context,
            instance_type,  # vsa['vsa_instance_type'],
            vsa['image_ref'],
            min_count=1,
            max_count=vc_count,
            display_name='vc-' + vsa['display_name'],
            display_description='VC for VSA ' + vsa['display_name'],
            availability_zone=vsa['availability_zone'],
            user_data=storage_data,
            metadata=dict(vsa_id=str(vsa_id)))

        self.vsa_api.update_vsa_status(context, vsa_id, VsaState.CREATED)
Пример #3
0
    def _start_vcs(self, context, vsa, drives=[]):
        """Start VCs for VSA """

        vsa_id = vsa['id']
        if vsa['status'] == VsaState.CREATING:
            self.vsa_api.update_vsa_status(context, vsa_id,
                                           VsaState.LAUNCHING)
        else:
            return

        # in _separate_ loop go over all volumes and mark as "attached"
        has_failed_volumes = False
        for drive in drives:
            vol_name = drive['name']
            vol_disp_name = drive['display_name']
            status = drive['status']
            LOG.info(_("VSA ID %(vsa_id)d: Drive %(vol_name)s "\
                        "(%(vol_disp_name)s) is in %(status)s state"),
                        locals())
            if status == 'available':
                try:
                    # self.volume_api.update(context, volume['id'],
                    #                   dict(attach_status="attached"))
                    pass
                except Exception as ex:
                    msg = _("Failed to update attach status for volume "
                            "%(vol_name)s. %(ex)s") % locals()
                    LOG.exception(msg)
            else:
                has_failed_volumes = True

        if has_failed_volumes:
            LOG.info(_("VSA ID %(vsa_id)d: Delete all BE volumes"), locals())
            self.vsa_api.delete_vsa_volumes(context, vsa_id, "BE", True)
            self.vsa_api.update_vsa_status(context, vsa_id,
                                           VsaState.FAILED)
            return

        # create user-data record for VC
        storage_data = vsa_utils.generate_user_data(vsa, drives)

        instance_type = instance_types.get_instance_type(
                                            vsa['instance_type_id'])

        # now start the VC instance

        vc_count = vsa['vc_count']
        LOG.info(_("VSA ID %(vsa_id)d: Start %(vc_count)d instances"),
                    locals())
        vc_instances = self.compute_api.create(context,
                instance_type,      # vsa['vsa_instance_type'],
                vsa['image_ref'],
                min_count=1,
                max_count=vc_count,
                display_name='vc-' + vsa['display_name'],
                display_description='VC for VSA ' + vsa['display_name'],
                availability_zone=vsa['availability_zone'],
                user_data=storage_data,
                metadata=dict(vsa_id=str(vsa_id)))

        self.vsa_api.update_vsa_status(context, vsa_id,
                                       VsaState.CREATED)