示例#1
0
def test_ip_max_valid_character_validation(request):
    """Test to validate max character for ip address field with valid ip address"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=fauxfactory.gen_alphanumeric(5),
                             ip_address=fauxfactory.gen_ipaddr(prefix=[10]))

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
示例#2
0
def test_ip_max_invalid_character_validation(request):
    """Test to validate max character for ip address field using random string"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=fauxfactory.gen_alphanumeric(5),
                             ip_address=fauxfactory.gen_alphanumeric(15))

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
示例#3
0
def test_api_port_max_character_validation(request):
    """Test to validate max character for api port field"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=fauxfactory.gen_alphanumeric(5),
                             ip_address=fauxfactory.gen_ipaddr(prefix=[10]),
                             api_port=fauxfactory.gen_alphanumeric(15))

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
示例#4
0
def test_ip_address_required_validation(request):
    """Test to validate the ip address while adding a provider"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=fauxfactory.gen_alphanumeric(5),
                             ip_address=None)

    request.addfinalizer(prov.delete_if_exists)
    with error.expected("IP Address can't be blank"):
        prov.create()
示例#5
0
def test_api_port_blank_validation(request):
    """Test to validate blank api port while adding a provider"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=fauxfactory.gen_alphanumeric(5),
                             ip_address=fauxfactory.gen_ipaddr(prefix=[10]),
                             api_port='')

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
def test_ip_max_invalid_character_validation(request):
    """Test to validate max character for ip address field using random string"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5),
        hostname=fauxfactory.gen_alphanumeric(5),
        ip_address=fauxfactory.gen_alphanumeric(15))

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
示例#7
0
def test_host_name_required_validation(request):
    """Test to validate the hostname while adding a provider"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=None,
                             ip_address=fauxfactory.gen_ipaddr(prefix=[10]))

    request.addfinalizer(prov.delete_if_exists)
    with error.expected("Host Name can't be blank"):
        prov.create()
def test_ip_max_valid_character_validation(request):
    """Test to validate max character for ip address field with valid ip address"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5),
        hostname=fauxfactory.gen_alphanumeric(5),
        ip_address=fauxfactory.gen_ipaddr(prefix=[10]))

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
def test_ip_address_required_validation(request):
    """Test to validate the ip address while adding a provider"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5), hostname=fauxfactory.gen_alphanumeric(5), ip_address=None
    )

    request.addfinalizer(prov.delete_if_exists)
    with error.expected("IP Address can't be blank"):
        prov.create()
示例#10
0
def test_host_name_required_validation(request):
    """Test to validate the hostname while adding a provider"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5), hostname=None, ip_address=fauxfactory.gen_ipaddr(prefix=[10])
    )

    request.addfinalizer(prov.delete_if_exists)
    with error.expected("Host Name can't be blank"):
        prov.create()
def test_api_port_max_character_validation(request):
    """Test to validate max character for api port field"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5),
        hostname=fauxfactory.gen_alphanumeric(5),
        ip_address=fauxfactory.gen_ipaddr(prefix=[10]),
        api_port=fauxfactory.gen_alphanumeric(15))

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
示例#12
0
def test_api_port_blank_validation(request):
    """Test to validate blank api port while adding a provider"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5),
        hostname=fauxfactory.gen_alphanumeric(5),
        ip_address=fauxfactory.gen_ipaddr(prefix=[10]),
        api_port="",
    )

    request.addfinalizer(prov.delete_if_exists)
    prov.create()
def test_api_port_blank_validation(request):
    """Test to validate blank api port while adding a provider"""
    prov = OpenStackProvider(
        name=fauxfactory.gen_alphanumeric(5),
        hostname=fauxfactory.gen_alphanumeric(5),
        ip_address=fauxfactory.gen_ipaddr(prefix=[10]),
        api_port='')

    request.addfinalizer(prov.delete_if_exists)
    if version.current_version() < "5.5":
        prov.create()
    else:
        # It must raise an exception because it keeps on the form
        with error.expected(FlashMessageException):
            prov.create()
        assert prov.properties_form.api_port.angular_help_block == "Required"
示例#14
0
def test_api_port_blank_validation(request):
    """Test to validate blank api port while adding a provider"""
    prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5),
                             hostname=fauxfactory.gen_alphanumeric(5),
                             ip_address=fauxfactory.gen_ipaddr(prefix=[10]),
                             api_port='')

    request.addfinalizer(prov.delete_if_exists)
    if version.current_version() < "5.5":
        prov.create()
    else:
        # It must raise an exception because it keeps on the form
        with error.expected(FlashMessageException):
            prov.create()
        assert properties_form.api_port.angular_help_block == "Required"
示例#15
0
def get_crud(provider_config_name):
    """
    Creates a Provider object given a yaml entry in cfme_data.

    Usage:
        get_crud('ec2east')

    Returns: A Provider object that has methods that operate on CFME
    """

    prov_config = conf.cfme_data.get('management_systems', {})[provider_config_name]
    credentials_key = prov_config['credentials']
    credentials = process_credential_yaml_key(credentials_key)
    prov_type = prov_config.get('type')

    if prov_type != 'ec2':
        if prov_config.get('discovery_range', None):
            start_ip = prov_config['discovery_range']['start']
            end_ip = prov_config['discovery_range']['end']
        else:
            start_ip = end_ip = prov_config.get('ipaddress')

    if prov_type == 'ec2':
        from cfme.cloud.provider import EC2Provider
        return EC2Provider(name=prov_config['name'],
            region=prov_config['region'],
            credentials={'default': credentials},
            zone=prov_config['server_zone'],
            key=provider_config_name)
    if prov_type == 'gce':
        from cfme.cloud.provider import GCEProvider
        ser_acc_creds = get_credentials_from_config(
            prov_config['credentials'], cred_type='service_account')
        return GCEProvider(name=prov_config['name'],
            project=prov_config['project'],
            zone=prov_config['zone'],
            region=prov_config['region'],
            credentials={'default': ser_acc_creds},
            key=provider_config_name)
    elif prov_type == 'azure':
        from cfme.cloud.provider import AzureProvider
        return AzureProvider(name=prov_config['name'],
            region=prov_config['region'],
            tenant_id=prov_config['tenant_id'],
            credentials={'default': credentials},
            key=provider_config_name)
    elif prov_type == 'openstack':
        from cfme.cloud.provider import OpenStackProvider
        if 'amqp_credentials' in prov_config:
            amqp_credentials = process_credential_yaml_key(
                prov_config['amqp_credentials'], cred_type='amqp')
        return OpenStackProvider(name=prov_config['name'],
            hostname=prov_config['hostname'],
            ip_address=prov_config['ipaddress'],
            api_port=prov_config['port'],
            credentials={
                'default': credentials,
                'amqp': amqp_credentials},
            zone=prov_config['server_zone'],
            key=provider_config_name,
            sec_protocol=prov_config.get('sec_protocol', "Non-SSL"),
            infra_provider=prov_config.get('infra_provider'))
    elif prov_type == 'virtualcenter':
        return VMwareProvider(name=prov_config['name'],
            hostname=prov_config['hostname'],
            ip_address=prov_config['ipaddress'],
            credentials={'default': credentials},
            zone=prov_config['server_zone'],
            key=provider_config_name,
            start_ip=start_ip,
            end_ip=end_ip)
    elif prov_type == 'scvmm':
        return SCVMMProvider(
            name=prov_config['name'],
            hostname=prov_config['hostname'],
            ip_address=prov_config['ipaddress'],
            credentials={'default': credentials},
            key=provider_config_name,
            start_ip=start_ip,
            end_ip=end_ip,
            sec_protocol=prov_config['sec_protocol'],
            sec_realm=prov_config['sec_realm'])
    elif prov_type == 'rhevm':
        credential_dict = {'default': credentials}
        if prov_config.get('candu_credentials', None):
            credential_dict['candu'] = process_credential_yaml_key(
                prov_config['candu_credentials'], cred_type='candu')
        return RHEVMProvider(name=prov_config['name'],
            hostname=prov_config['hostname'],
            ip_address=prov_config['ipaddress'],
            api_port='',
            credentials=credential_dict,
            zone=prov_config['server_zone'],
            key=provider_config_name,
            start_ip=start_ip,
            end_ip=end_ip)
    elif prov_type == "openstack-infra":
        credential_dict = {'default': credentials}
        if 'ssh_credentials' in prov_config:
            credential_dict['ssh'] = process_credential_yaml_key(
                prov_config['ssh_credentials'], cred_type='ssh')
        if 'amqp_credentials' in prov_config:
            credential_dict['amqp'] = process_credential_yaml_key(
                prov_config['amqp_credentials'], cred_type='amqp')
        return OpenstackInfraProvider(
            name=prov_config['name'],
            sec_protocol=prov_config.get('sec_protocol', "Non-SSL"),
            hostname=prov_config['hostname'],
            ip_address=prov_config['ipaddress'],
            credentials=credential_dict,
            key=provider_config_name,
            start_ip=start_ip,
            end_ip=end_ip)
    elif prov_type == 'kubernetes':
        token_creds = process_credential_yaml_key(prov_config['credentials'], cred_type='token')
        return KubernetesProvider(
            name=prov_config['name'],
            credentials={'token': token_creds},
            key=provider_config_name,
            zone=prov_config['server_zone'],
            hostname=prov_config.get('hostname', None) or prov_config['ip_address'],
            port=prov_config['port'],
            provider_data=prov_config)
    elif prov_type == 'openshift':
        token_creds = process_credential_yaml_key(prov_config['credentials'], cred_type='token')
        return OpenshiftProvider(
            name=prov_config['name'],
            credentials={'token': token_creds},
            key=provider_config_name,
            zone=prov_config['server_zone'],
            hostname=prov_config.get('hostname', None) or prov_config['ip_address'],
            port=prov_config['port'],
            provider_data=prov_config)
    elif prov_type == 'hawkular':
        return HawkularProvider(
            name=prov_config['name'],
            key=provider_config_name,
            hostname=prov_config['hostname'],
            port=prov_config['port'],
            credentials={'default': credentials})
    else:
        raise UnknownProviderType('{} is not a known provider type'.format(prov_type))
示例#16
0
def get_crud(provider_config_name):
    """
    Creates a Provider object given a yaml entry in cfme_data.

    Usage:
        get_crud('ec2east')

    Returns: A Provider object that has methods that operate on CFME
    """

    prov_config = conf.cfme_data.get('management_systems',
                                     {})[provider_config_name]
    credentials = get_credentials_from_config(prov_config['credentials'])
    prov_type = prov_config.get('type')

    if prov_type != 'ec2':
        if prov_config.get('discovery_range', None):
            start_ip = prov_config['discovery_range']['start']
            end_ip = prov_config['discovery_range']['end']
        else:
            start_ip = end_ip = prov_config.get('ipaddress')

    if prov_type == 'ec2':
        return EC2Provider(name=prov_config['name'],
                           region=prov_config['region'],
                           credentials={'default': credentials},
                           zone=prov_config['server_zone'],
                           key=provider_config_name)
    elif prov_type == 'openstack':
        return OpenStackProvider(name=prov_config['name'],
                                 hostname=prov_config['hostname'],
                                 ip_address=prov_config['ipaddress'],
                                 api_port=prov_config['port'],
                                 credentials={'default': credentials},
                                 zone=prov_config['server_zone'],
                                 key=provider_config_name)
    elif prov_type == 'virtualcenter':
        return VMwareProvider(name=prov_config['name'],
                              hostname=prov_config['hostname'],
                              ip_address=prov_config['ipaddress'],
                              credentials={'default': credentials},
                              zone=prov_config['server_zone'],
                              key=provider_config_name,
                              start_ip=start_ip,
                              end_ip=end_ip)
    elif prov_type == 'scvmm':
        return SCVMMProvider(name=prov_config['name'],
                             hostname=prov_config['hostname'],
                             ip_address=prov_config['ipaddress'],
                             credentials={'default': credentials},
                             key=provider_config_name,
                             start_ip=start_ip,
                             end_ip=end_ip,
                             sec_protocol=prov_config['sec_protocol'],
                             sec_realm=prov_config['sec_realm'])
    elif prov_type == 'rhevm':
        if prov_config.get('candu_credentials', None):
            candu_credentials = get_credentials_from_config(
                prov_config['candu_credentials'])
            candu_credentials.candu = True
        else:
            candu_credentials = None
        return RHEVMProvider(name=prov_config['name'],
                             hostname=prov_config['hostname'],
                             ip_address=prov_config['ipaddress'],
                             api_port='',
                             credentials={
                                 'default': credentials,
                                 'candu': candu_credentials
                             },
                             zone=prov_config['server_zone'],
                             key=provider_config_name,
                             start_ip=start_ip,
                             end_ip=end_ip)
    else:
        raise UnknownProviderType(
            '{} is not a known infra provider type'.format(prov_type))