예제 #1
0
 def test_delete_nonexistent(self):
     vs1_2 = rest.ApiNode('virtualservice', name='doesnt_exist')
     try:
         status_code, data = vs1_2.delete()
     except FailError:
         logger.info('As expected, failed to delete vs that does not exist')
     status_code, resp = vs1_2.delete(check_status_code=False)
     assert status_code == 404
예제 #2
0
 def test_get_before_create(self):
     vs2 = rest.ApiNode('virtualservice', name='doesnt_exist')
     try:
         status_code, data = vs2.get()
     except FailError:
         logger.info('As expected, failed to get vs that does not exist')
     status_code, data = vs2.get(check_status_code=False)
     assert status_code == 404
예제 #3
0
def del_ipam_and_dns_from_cloud(ipam_name=None, dns_name=None, **kwargs):
    cloud_name = kwargs.get('cloud', infra_utils.get_mode()['cloud'])
    cloud_obj = rest.ApiNode('cloud', name=cloud_name)
    status_code, json_data = cloud_obj.get()

    if ipam_name:
        json_data.pop('ipam_provider_ref', None)
    if dns_name:
        json_data.pop('dns_provider_ref', None)
    cloud_obj.put(data=json.dumps(json_data))
예제 #4
0
def add_ipam_and_dns_to_cloud(ipam_name=None, dns_name=None, **kwargs):
    cloud_name = kwargs.get('cloud', infra_utils.get_mode()['cloud'])
    cloud_obj = rest.ApiNode('cloud', name=cloud_name)
    status_code, json_data = cloud_obj.get()

    if ipam_name:
        json_data[
            'ipam_provider_ref'] = '/api/ipamdnsproviderprofile?name=%s' % ipam_name
    if dns_name:
        json_data[
            'dns_provider_ref'] = '/api/ipamdnsproviderprofile?name=%s' % dns_name
    logger.trace('JSON data: %s' % json_data)
    cloud_obj.put(data=json.dumps(json_data))
예제 #5
0
def del_ipam_from_cloud(ipam_name=None, **kwargs):
    """

    :param ipam_name:
    :param kwargs:
    :return:
    """
    cloud_name = kwargs.get('cloud', infra_utils.get_mode()['cloud'])
    cloud_obj = rest.ApiNode('cloud', name=cloud_name)
    status_code, json_data = cloud_obj.get()

    if ipam_name:
        json_data.pop('ipam_provider_ref', None)

    cloud_obj.put(data=json.dumps(json_data))
예제 #6
0
def create_ipamdns_profile(name,
                           ipam_type,
                           usable_network=None,
                           check_status_code=True,
                           service_domain=None):
    ''' basic version of ipam create '''
    # if ipam_type not in IpamDnsType.keys():
    #    logger_utils.fail('ipam_type %s not in one of %s' % (ipam_type, IpamDnsType.keys()))

    ipam_data = {}
    ipam_data['name'] = name
    ipam_data['type'] = ipam_type
    if ipam_type in ['IPAMDNS_TYPE_INTERNAL', 'IPAMDNS_TYPE_INTERNAL_DNS']:
        ipam_data['internal_profile'] = {}
        if usable_network:
            usable_networks = []
            if type(usable_network) == list:
                for network in usable_network:
                    usable_networks.append('/api/network/?name=%s' % network)
            else:
                usable_networks.append('/api/network/?name=%s' %
                                       usable_network)
            ipam_data['internal_profile'][
                'usable_network_refs'] = usable_networks
        if service_domain:
            dns_service_domain = []
            obj = {
                "num_dns_ip": 1,
                "domain_name": service_domain,
                "pass_through": True
            }
            dns_service_domain.append(obj)
            ipam_data['internal_profile'][
                'dns_service_domain'] = dns_service_domain

            # TODO handle svc_domain_name, svc_domain_list
    # TODO: handle other ipam types

    ipamprofile = rest.ApiNode('ipamdnsproviderprofile')
    return ipamprofile.post(data=json.dumps(ipam_data),
                            check_status_code=check_status_code)
예제 #7
0
 def test_get_systemconfig(self):
     systemconfig = rest.ApiNode('systemconfiguration')
     status, resp = systemconfig.get()
     logger.info('response = %s' % resp)
예제 #8
0
 def vs1(self):
     vs1 = rest.ApiNode('virtualservice', name='vs1')
     return vs1