Beispiel #1
0
    def create_pvdc(cls):
        """Creates a pvdc by the name specified in the config file.

        Skips creating one, if such a pvdc already exists. Also stores the
        href and name of the provider vdc as class variables for future use.
        """
        cls._basic_check()
        pvdc_name = cls._config['vcd']['default_pvdc_name']

        system = System(
            cls._sys_admin_client,
            admin_resource=cls._sys_admin_client.get_admin())

        pvdc_refs = system.list_provider_vdcs()
        if pvdc_name is not '*':
            for pvdc_ref in pvdc_refs:
                if pvdc_ref.get('name').lower() == pvdc_name.lower():
                    cls._logger.debug('Reusing existing ' + pvdc_name)
                    cls._pvdc_href = pvdc_ref.get('href')
                    cls._pvdc_name = pvdc_name
                    return
            cls._logger.debug('Creating new pvdc' + pvdc_name)
            # TODO(VCDA-603) : use create pvdc code
        else:
            if len(pvdc_refs) > 0:
                cls._logger.debug('Defaulting to first pvdc in the system : ' +
                                  pvdc_refs[0].get('name'))
                cls._pvdc_href = pvdc_refs[0].get('href')
                cls._pvdc_name = pvdc_refs[0].get('name')
            else:
                cls._logger.debug('No usable pVDC found. Aborting test.')
                raise Exception('Test Aborted. No usable pVDC.')
Beispiel #2
0
    def create_pvdc(cls):
        """Creates a pvdc by the name specified in the config file, skips
            creating one, if such a pvdc already exists. Also stores the
            href and name of the pvdc as class variables for future use.

        :return: Nothing
        """
        cls._basic_check()
        pvdc_name = cls._config['vcd']['default_pvdc_name']

        system = System(cls._sys_admin_client,
                        admin_resource=cls._sys_admin_client.get_admin())

        pvdc_refs = system.list_provider_vdcs()
        if pvdc_name is not '*':
            for pvdc_ref in pvdc_refs:
                if pvdc_ref.get('name').lower() == pvdc_name.lower():
                    print('Reusing existing ' + pvdc_name)
                    cls._pvdc_href = pvdc_ref.get('href')
                    cls._pvdc_name = pvdc_name
                    return
            print('Creating new pvdc' + pvdc_name)
            # TODO : use create pvdc code - see VCDA-603

        print('Defaulting to first pvdc in the system viz.' +
              pvdc_refs[0].get('name'))
        cls._pvdc_href = pvdc_refs[0].get('href')
        cls._pvdc_name = pvdc_refs[0].get('name')
Beispiel #3
0
def list_pvdc(ctx):
    try:
        client = ctx.obj['client']
        sys_admin_resource = client.get_admin()
        system = System(client, admin_resource=sys_admin_resource)
        result = []
        for pvdc in system.list_provider_vdcs():
            result.append({'name': pvdc.get('name')})
        stdout(result, ctx)
    except Exception as e:
        stderr(e, ctx)
Beispiel #4
0
def list_pvdc(ctx):
    try:
        restore_session(ctx)
        client = ctx.obj['client']
        sys_admin_resource = client.get_admin()
        system = System(client, admin_resource=sys_admin_resource)
        result = []
        for pvdc in system.list_provider_vdcs():
            result.append({'name': pvdc.get('name')})
        stdout(result, ctx)
    except Exception as e:
        stderr(e, ctx)
Beispiel #5
0
def _fill_in_pvdc_default(client, vdc_kwargs):
    """Convert '*' value to a default pvcd name"""
    pvdc_name = vdc_kwargs['provider_vdc_name']
    if pvdc_name == '*':
        system = System(client, admin_resource=client.get_admin())
        pvdc_refs = system.list_provider_vdcs()
        for pvdc_ref in pvdc_refs:
            pvdc_name = pvdc_ref.get('name')
            print("Defaulting to first pvdc: {0}".format(pvdc_name))
            vdc_kwargs['provider_vdc_name'] = pvdc_name
            break

        if vdc_kwargs['provider_vdc_name'] == '*':
            raise Exception("Unable to find default provider VDC")
Beispiel #6
0
def _fill_in_pvdc_default(client, vdc_kwargs):
    """Convert '*' value to a default pvcd name"""
    pvdc_name = vdc_kwargs['provider_vdc_name']
    if pvdc_name == '*':
        system = System(client, admin_resource=client.get_admin())
        pvdc_refs = system.list_provider_vdcs()
        for pvdc_ref in pvdc_refs:
            pvdc_name = pvdc_ref.get('name')
            print("Defaulting to first pvdc: {0}".format(pvdc_name))
            vdc_kwargs['provider_vdc_name'] = pvdc_name
            break

        if vdc_kwargs['provider_vdc_name'] == '*':
            raise Exception("Unable to find default provider VDC")