Ejemplo n.º 1
0
    def create_db_tenant(self, msa_customer_id=0):

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_tenant = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_TENANT)

        # Create
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['IaaS_region_id'] = JOB_INPUT['IaaS_region_id']
        params['IaaS_tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        tenant_info = [{
            "description": "",
            "enabled": True,
            "id": JOB_INPUT['nal_tenant_id'],
            "msa_customer_id": msa_customer_id,
            "msa_customer_name": "",
            "name": JOB_INPUT['IaaS_tenant_name'],
            "pod_id": JOB_INPUT['pod_id']
        }]
        params['tenant_info'] = json.dumps(tenant_info)
        db_create.set_context(db_endpoint_tenant, params)
        db_create.execute()
Ejemplo n.º 2
0
    def setUp(self):
        # Establish a clean test environment.
        super(TestTenatAPI, self).setUp()

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_tenant = base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_TENANT)

        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['IaaS_region_id'] = JOB_INPUT['IaaS_region_id']
        params['IaaS_tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        tenant_info = [
            {
                "description": "",
                "enabled": True,
                "id": "ef5d2e187b9636f9a4811318069137a6",
                "msa_customer_id": 0,
                "msa_customer_name": "",
                "name": JOB_INPUT['IaaS_tenant_name'],
                "pod_id": JOB_INPUT['pod_id']
            }
        ]
        params['tenant_info'] = json.dumps(tenant_info)
        db_create.set_context(db_endpoint_tenant, params)
        db_create.execute()
Ejemplo n.º 3
0
    def __create_nal_tenant_name(self, job_input):

        # Get JOB Input Parameters
        iaas_tenant_id = job_input['IaaS_tenant_id']
        iaas_region_id = job_input['IaaS_region_id']
        operation_id = job_input['operation_id']

        # Set UUID
        tenant_name = iaas_tenant_id

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)

        # Get Endpoint(DB Client)
        db_endpoint_tenant = self.get_db_endpoint(
            self.job_config.REST_URI_TENANT)

        # Create NAL_TENANT_MNG(DB Client)
        params = {}
        params['create_id'] = operation_id
        params['update_id'] = operation_id
        params['delete_flg'] = 0
        params['IaaS_region_id'] = iaas_region_id
        params['IaaS_tenant_id'] = iaas_tenant_id
        params['tenant_name'] = tenant_name
        json_wk = []
        params['tenant_info'] = json.dumps(json_wk)
        db_create_instance.set_context(db_endpoint_tenant, params)
        db_create_instance.execute()

        return tenant_name
Ejemplo n.º 4
0
    def create_db_license(self,
                          h_type,
                          device_type,
                          status=0,
                          tenant_name='',
                          node_id='',
                          update_date=''):

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_license = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_LICENSE)

        # Create NAL_LICENSE_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['license'] = 'license' + str(h_type) + str(device_type)
        params['type'] = h_type
        params['device_type'] = device_type
        params['status'] = status
        if len(tenant_name) > 0:
            params['tenant_name'] = tenant_name
        if len(node_id) > 0:
            params['node_id'] = node_id
        if len(update_date) > 0:
            params['update_date'] = update_date

        db_create.set_context(db_endpoint_license, params)
        db_create.execute()
Ejemplo n.º 5
0
    def initialize_create_vnf(self, job_input):

        function_name = inspect.currentframe().f_code.co_name

        # Output Log(Job Input)
        self.output_log_job_params(self.LOG_TYPE_INPUT, __name__,
                                   function_name, job_input)

        # Get JOB Input Parameters
        operation_id = job_input['operation_id']
        apl_type = job_input['apl_type']
        hard_type = job_input['type']
        device_type = job_input['device_type']
        tenant_name = job_input['tenant_name']
        host_name = job_input['host_name']
        description = job_input.get('description', '')

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)

        # Get Endpoint(DB Client)
        db_endpoint_apl = self.get_db_endpoint(self.job_config.REST_URI_APL)

        # Create NAL_VNF_MNG(DB Client)
        params = {}
        params['create_id'] = operation_id
        params['update_id'] = operation_id
        params['delete_flg'] = 0
        params['node_id'] = ''
        params['apl_type'] = apl_type
        params['type'] = hard_type
        params['device_type'] = device_type
        params['tenant_name'] = tenant_name
        params['node_name'] = host_name
        params['description'] = description
        params['task_status'] = 0
        params['err_info'] = json.dumps([])

        db_create_instance.set_context(db_endpoint_apl, params)
        db_create_instance.execute()
        apl_table_data = db_create_instance.get_return_param()

        job_output = {'apl_table_rec_id': apl_table_data['ID']}

        # Output Log(Job Output)
        self.output_log_job_params(self.LOG_TYPE_OUTPUT, __name__,
                                   function_name, job_output)

        return job_output
Ejemplo n.º 6
0
    def create_db_apl(self,
                      apl_type,
                      nf_type=1,
                      device_type=1,
                      redundant_configuration_flg=1):

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_apl = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_APL)

        node_id = ''.join([
            random.choice(string.digits + string.ascii_letters)
            for i in range(10)
        ])

        # Create
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['node_id'] = node_id
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        params['apl_type'] = apl_type
        params['type'] = nf_type
        params['device_type'] = device_type
        params['task_status'] = 0

        params['actsby_flag_master'] = 'act'
        params['device_name_master'] = 'wn0fwxtf01'
        params['device_detail_master'] = '{}'
        params['master_ip_address'] = '100.99.0.5'
        params['redundant_configuration_flg'] = redundant_configuration_flg
        params['MSA_device_id'] = ''
        params['status'] = 0
        params['nic_MSA'] = 'mport'
        params['nic_public'] = 'pport'
        params['nic_external'] = 'eport'
        params['nic_tenant'] = 'tport'

        db_create.set_context(db_endpoint_apl, params)
        db_create.execute()

        return node_id
Ejemplo n.º 7
0
    def create_db_apl(self, nf_type, device_type=1):

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())
        db_list = list.ListClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_apl = base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_APL)

        # Create
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['node_id'] = JOB_INPUT['node_id']
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        params['apl_type'] = 1
        params['type'] = nf_type
        params['device_type'] = device_type
        params['task_status'] = 0

        params['actsby_flag_master'] = 'act'
        params['device_name_master'] = 'wn0fwxtf01'
        params['device_detail_master'] = '{}'
        params['master_ip_address'] = '100.99.0.5'
        params['redundant_configuration_flg'] = 0
        params['MSA_device_id'] = ''
        params['status'] = 0
        params['nic_MSA'] = 'mport'
        params['nic_public'] = 'pport'
        params['nic_external'] = 'eport'
        params['nic_tenant'] = 'tport'

        db_create.set_context(db_endpoint_apl, params)
        db_create.execute()

        # List NAL_APL_MNG
        params = {}
        params['node_id'] = JOB_INPUT['node_id']
        params['delete_flg'] = 0
        db_list.set_context(db_endpoint_apl, params)
        db_list.execute()
        apl_list = db_list.get_return_param()

        return apl_list[0]['ID']
Ejemplo n.º 8
0
    def create_db_apl(self, redundant_configuration_flg=0):

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_apl = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_APL)

        # Create
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['node_id'] = JOB_INPUT['node_id']
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['tenant_id'] = JOB_INPUT['tenant_id']
        params['apl_type'] = 2
        params['type'] = 2
        params['device_type'] = 1
        params['task_status'] = 0
        params['actsby_flag_master'] = 'act'
        params['device_name_master'] = 'wn0fwxtf01'
        params['device_detail_master'] = '{}'
        params['device_detail_slave'] = '{}'
        params['master_ip_address'] = '100.99.0.5'
        params['redundant_configuration_flg'] = redundant_configuration_flg
        params['MSA_device_id'] = ''
        params['status'] = 0
        params['nic_MSA'] = 'mport'
        params['nic_public'] = 'pport'
        params['nic_external'] = 'eport'
        params['nic_tenant'] = 'tport'
        params['device_user_name'] = json.dumps({
            'partition_id':
            JOB_INPUT['partition_id'],
            'route_domain_id':
            JOB_INPUT['route_domain_id'],
        })
        db_create.set_context(db_endpoint_apl, params)
        db_create.execute()

        params['actsby_flag_master'] = 'sby'
        db_create.set_context(db_endpoint_apl, params)
        db_create.execute()
Ejemplo n.º 9
0
    def __login_vlan(self, job_input):

        # Get JOB Input Parameters
        iaas_region_id = job_input['IaaS_region_id']
        iaas_tenant_id = job_input['IaaS_tenant_id']
        iaas_network_id = job_input['IaaS_network_id']
        iaas_network_type = job_input['IaaS_network_type']
        iaas_segmentation_id = job_input['IaaS_segmentation_id']
        operation_id = job_input['operation_id']
        tenant_name = job_input['tenant_name']
        nal_tenant_id = job_input['nal_tenant_id']
        pod_id = job_input['pod_id']

        # Get Endpoint(DB Client)
        db_endpoint_vlan = self.get_db_endpoint(self.job_config.REST_URI_VLAN)

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)
        rule_id = ''

        # Create NAL_VIRTUAL_LAN_MNG(DB Client)
        params = {}
        params['create_id'] = operation_id
        params['update_id'] = operation_id
        params['delete_flg'] = 0
        params['tenant_name'] = tenant_name
        params['pod_id'] = pod_id
        params['tenant_id'] = nal_tenant_id
        params['IaaS_region_id'] = iaas_region_id
        params['IaaS_tenant_id'] = iaas_tenant_id
        params['IaaS_network_id'] = iaas_network_id
        params['IaaS_network_type'] = iaas_network_type
        params['IaaS_segmentation_id'] = iaas_segmentation_id
        params['vlan_id'] = iaas_segmentation_id
        params['network_id'] = iaas_network_id
        params['rule_id'] = rule_id
        params['nal_vlan_info'] = {}
        db_create_instance.set_context(db_endpoint_vlan, params)
        db_create_instance.execute()

        return {
            'IaaS_network_id': iaas_network_id,
            'vlan_id': iaas_segmentation_id
        }
Ejemplo n.º 10
0
    def create_db_apl(self, node_name):

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())
        db_list = list.ListClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_apl = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_APL)

        node_id = ''.join([
            random.choice(string.digits + string.ascii_letters)
            for i in range(10)
        ])

        # Create
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['node_id'] = node_id
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        params['apl_type'] = 1
        params['device_type'] = 1
        params['task_status'] = 0
        params['node_name'] = node_name
        db_create.set_context(db_endpoint_apl, params)
        db_create.execute()

        # List
        params = {}
        params['node_id'] = node_id
        db_list.set_context(db_endpoint_apl, params)
        db_list.execute()
        apl_list = db_list.get_return_param()

        return apl_list[0]['ID']
Ejemplo n.º 11
0
    def __insert_db_port(self, operation_id, tenant_name, pod_id, tenant_id,
                         apl_type, network_id, network_type,
                         network_type_detail, port_id, ip_address, port_info,
                         subnet_mask, apl_table_rec_id):

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)

        # Get Endpoint(DB Client)
        db_endpoint_port = self.get_db_endpoint(self.job_config.REST_URI_PORT)

        params = {}
        params['create_id'] = operation_id
        params['update_id'] = operation_id
        params['delete_flg'] = 0
        params['port_id'] = port_id
        params['tenant_name'] = tenant_name
        params['pod_id'] = pod_id
        params['tenant_id'] = tenant_id
        params['network_id'] = network_id
        params['network_type'] = network_type
        params['network_type_detail'] = network_type_detail
        params['apl_type'] = apl_type
        params['node_id'] = ''
        params['apl_table_rec_id'] = apl_table_rec_id
        params['IaaS_region_id'] = ' '
        params['IaaS_tenant_id'] = ' '
        params['IaaS_network_id'] = ' '
        params['IaaS_port_id'] = ' '
        params['nic'] = ''
        params['ip_address'] = ip_address
        params['netmask'] = subnet_mask
        params['port_info'] = json.dumps(port_info)
        params['msa_info'] = json.dumps({})

        db_create_instance.set_context(db_endpoint_port, params)
        db_create_instance.execute()
Ejemplo n.º 12
0
from job.conf import config
from job.lib.db import create

end_point = 'http://localhost:80/index.py/pnfs'
params = {
    'delete_flg': 0,
    'type': 1,
    'device_type': 2,
    'status': 1,
    'device_id': 'dev0001',
    'redundant_configuration_flg': 1,
    'device_name_master': 'master001',
    'actsby_flag_master': 'act001',
    'device_detail_master': 'detail001',
    'master_ip_address': '10.0.0.1'
}

client = create.CreateClient(config.JobConfig())
client.set_context(end_point, params)
client.execute()
result = client.get_return_param()

print(type(result))
print(result)
Ejemplo n.º 13
0
    def setUp(self):
        # Establish a clean test environment.
        super(TestSetupDeviceBigIpApi, self).setUp()

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_vlan = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_VLAN)
        db_endpoint_port = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_PORT)

        # Create NAL_VLAN_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['tenant_id'] = JOB_INPUT['tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['network_id'] = JOB_INPUT['network_id']
        params['IaaS_network_id'] = JOB_INPUT['IaaS_network_id']
        params['IaaS_network_type'] = 'VLAN'
        params['IaaS_region_id'] = JOB_INPUT['IaaS_region_id']
        params['vlan_id'] = '2016'
        db_create.set_context(db_endpoint_vlan, params)
        db_create.execute()

        # Create NAL_PORT_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['tenant_id'] = JOB_INPUT['tenant_id']
        params['node_id'] = JOB_INPUT['node_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['port_id'] = JOB_INPUT['port_id']
        params['network_id'] = JOB_INPUT['network_id']
        params['apl_type'] = 1
        params['network_type'] = 1
        params['network_type_detail'] = 1
        params['ip_address'] = '10.0.0.1'
        params['netmask'] = 16
        params['IaaS_region_id'] = JOB_INPUT['IaaS_region_id']
        params['IaaS_tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        params['IaaS_network_id'] = JOB_INPUT['IaaS_network_id']
        params['IaaS_port_id'] = JOB_INPUT['IaaS_port_id']
        params['port_info'] = json.dumps({
            'IaaS_port_info': {
                'vip': {
                    'ip_address': '10.0.0.1',
                    'netmask': 16
                },
                'act': {
                    'ip_address': '10.0.0.2',
                    'netmask': 24
                },
                'sby': {
                    'ip_address': '10.0.0.3',
                    'netmask': 25
                },
            },
        })
        params['msa_info'] = '{}'
        db_create.set_context(db_endpoint_port, params)
        db_create.execute()
Ejemplo n.º 14
0
    def setUp(self):
        # Establish a clean test environment.
        super(TestAutoPlbThrough, self).setUp()

        vim_iaas_with_flg = self.get_vim_iaas_with_flg_for_test()
        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_apl = \
            base.JobAutoBase().get_db_endpoint(config.JobConfig().REST_URI_APL)
        db_endpoint_pod = \
            base.JobAutoBase().get_db_endpoint(config.JobConfig().REST_URI_POD)
        db_endpoint_tenant = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_TENANT)
        db_endpoint_msa_vlan = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_MSA_VLAN)
        db_endpoint_pnf_vlan = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_PNF_VLAN)
        db_endpoint_vlan = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_VLAN)
        db_endpoint_port = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_PORT)

        partition_id_seq = 0
        for device_type in ('1', '2', '3', '4'):
            # Create test data to NAL_APL_MNG
            params = {}
            params['create_id'] = 'test_nw_automation_user_001'
            params['update_id'] = 'test_nw_automation_user_001'
            params['delete_flg'] = 0
            params['apl_type'] = 2
            params['type'] = 2
            params['device_type'] = device_type
            params['node_id'] = 'node_id_001' + device_type
            params['actsby_flag_master'] = 'act'
            params['device_name_master'] = 'wn0fwxtf01' + device_type
            params['device_detail_master'] = '{}'
            params['master_ip_address'] = '100.99.0.5'
            params['pod_id'] = 'pod_unit_test1'
            params['redundant_configuration_flg'] = '0'
            params['tenant_name'] = ''
            params['MSA_device_id'] = ''
            params['status'] = 0
            params['task_status'] = 1
            params['nic_MSA'] = 'mport'
            params['nic_public'] = 'pport'
            params['nic_external'] = 'eport'
            params['nic_tenant'] = 'tport'

            if device_type in ('2', '4'):
                partition_id_seq += 1
                params['partition_id_seq'] = str(partition_id_seq)

            db_create.set_context(db_endpoint_apl, params)
            db_create.execute()

            params = {}
            params['create_id'] = 'test_nw_automation_user_001'
            params['update_id'] = 'test_nw_automation_user_001'
            params['delete_flg'] = 0
            params['apl_type'] = 2
            params['type'] = 2
            params['device_type'] = device_type
            params['node_id'] = 'node_id_002' + device_type
            params['actsby_flag_master'] = 'act'
            params['device_name_master'] = 'wn0fwxtf01'
            params['device_detail_master'] = '{}'
            params['master_ip_address'] = '100.99.0.5'
            params['pod_id'] = 'pod_unit_test1'
            params['redundant_configuration_flg'] = '1'
            params['tenant_name'] = ''
            params['MSA_device_id'] = ''
            params['status'] = 0
            params['task_status'] = 1
            params['nic_MSA'] = 'mport'
            params['nic_public'] = 'pubport'
            params['nic_external'] = 'extport'
            params['nic_tenant'] = 'tport'

            if device_type in ('2', '4'):
                partition_id_seq += 1
                params['partition_id_seq'] = str(partition_id_seq)

            db_create.set_context(db_endpoint_apl, params)
            db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['pod_id'] = 'pod_unit_test2'
        params['use_type'] = 1
        params['ops_version'] = 1
        params['weight'] = '50'
        db_create.set_context(db_endpoint_pod, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['pod_id'] = 'pod_unit_test1'
        params['use_type'] = 1
        params['ops_version'] = 1
        params['weight'] = '60'
        db_create.set_context(db_endpoint_pod, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['status'] = 0
        params['network_address'] = '10.20.0.0'
        params['netmask'] = '24'
        params['vlan_id'] = 'vlan_id_0000_1111_2222'
        db_create.set_context(db_endpoint_msa_vlan, params)
        db_create.execute()

        for vlan_num in range(1, 4):
            params = {}
            params['create_id'] = 'test_nw_automation_user_001'
            params['update_id'] = 'test_nw_automation_user_001'
            params['delete_flg'] = 0
            params['status'] = 0
            params['network_address'] = '10.21.' + str(vlan_num) + '.0'
            params['netmask'] = '24'
            params['vlan_id'] = '200' + str(vlan_num)
            db_create.set_context(db_endpoint_pnf_vlan, params)
            db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0

        if vim_iaas_with_flg == 0:
            params['network_id'] = '094049539a7ba2548268d74cd5874ebc'
        else:
            params['network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'

        params['tenant_name'] = 'IaaS_tenant_id_001'
        params['pod_id'] = 'pod_unit_test1'
        params['tenant_id'] = 'ef5d2e187b9636f9a4811318069137a6'
        params['IaaS_network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'
        params['IaaS_network_type'] = 'VLAN'
        params['IaaS_region_id'] = 'region_unit_test1'
        params['vlan_id'] = '2016'
        db_create.set_context(db_endpoint_vlan, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0

        if vim_iaas_with_flg == 0:
            params['network_id'] = '094049539a7ba2548268d74cd5874ebc'
        else:
            params['network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'

        params['tenant_name'] = 'IaaS_tenant_id_001'
        params['pod_id'] = 'pod_unit_test1'
        params['tenant_id'] = 'ef5d2e187b9636f9a4811318069137a6'
        params['IaaS_network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'
        params['IaaS_network_type'] = 'VXLAN'
        params['IaaS_region_id'] = 'region_unit_test1'
        params['vlan_id'] = '2016'
        db_create.set_context(db_endpoint_vlan, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['port_id'] = 'port_id_00001'

        if vim_iaas_with_flg == 0:
            params['network_id'] = '094049539a7ba2548268d74cd5874ebc'
        else:
            params['network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'

        params['tenant_name'] = 'IaaS_tenant_id_001'
        params['pod_id'] = 'pod_unit_test1'
        params['tenant_id'] = 'ef5d2e187b9636f9a4811318069137a6'
        params['network_type'] = '1'
        params['network_type_detail'] = '1'
        db_create.set_context(db_endpoint_port, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['tenant_name'] = 'IaaS_tenant_id_001'
        params['IaaS_region_id'] = 'region_unit_test1'
        params['IaaS_tenant_id'] = 'IaaS_tenant_id_001'
        tenant_info = [{
            "description": "",
            "enabled": True,
            "id": "ef5d2e187b9636f9a4811318069137a6",
            "msa_customer_id": 0,
            "msa_customer_name": "",
            "name": "IaaS_tenant_name_AAA",
            "pod_id": "pod_unit_test1"
        }]
        params['tenant_info'] = json.dumps(tenant_info)
        db_create.set_context(db_endpoint_tenant, params)
        db_create.execute()
Ejemplo n.º 15
0
    def setUp(self):

        # Establish a clean test environment.
        super(TestAutoDcCreateAPI, self).setUp()

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_pod = \
            base.JobAutoBase()\
            .get_db_endpoint(config.JobConfig().REST_URI_POD)
        db_endpoint_msa_vlan = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_MSA_VLAN)
        db_endpoint_global_ip = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_GLOBAL_IP)
        db_endpoint_license = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_LICENSE)
        db_endpoint_dc_segment = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_WIM_DC_SEGMENT_MNG)

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['pod_id'] = 'pod0002'
        params['use_type'] = 2
        params['ops_version'] = 1
        params['weight'] = '50'
        db_create.set_context(db_endpoint_pod, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['pod_id'] = 'pod_unit_test1'
        params['use_type'] = 3
        params['ops_version'] = 1
        params['weight'] = '60'
        db_create.set_context(db_endpoint_pod, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['status'] = 0
        params['network_address'] = '10.20.0.0'
        params['netmask'] = '24'
        params['vlan_id'] = 'vlan_id_0000_1111_2222'
        db_create.set_context(db_endpoint_msa_vlan, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['global_ip'] = '192.168.80.245'
        params['status'] = 0
        db_create.set_context(db_endpoint_global_ip, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_firefly_001'
        params['type'] = 3
        params['device_type'] = 1
        params['type_detail'] = ""
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_001'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_002'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_003'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_004'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_tunnel_esp_001'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_tunnel_esp_002'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_tunnel_ah_001'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['license'] = 'test_license_cisco_tunnel_ah_002'
        params['type'] = 3
        params['device_type'] = 2
        params['type_detail'] = 1
        params['status'] = 0
        db_create.set_context(db_endpoint_license, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['dc_id'] = 'dc01'
        params['group_id'] = ''
        params['ce01_ip_address'] = '100.112.0.1'
        params['ce02_ip_address'] = '100.112.0.2'
        params['network_address'] = '100.112.0.0'
        params['netmask'] = 16
        params['next_hop'] = '100.107.1.254'
        params['status'] = 0
        db_create.set_context(db_endpoint_dc_segment, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['dc_id'] = 'dc02'
        params['group_id'] = ''
        params['ce01_ip_address'] = '100.113.0.1'
        params['ce02_ip_address'] = '100.113.0.2'
        params['network_address'] = '100.113.0.0'
        params['netmask'] = 16
        params['next_hop'] = '100.107.2.254'
        params['status'] = 0
        db_create.set_context(db_endpoint_dc_segment, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'TestAutoDcUser'
        params['update_id'] = 'TestAutoDcUser'
        params['delete_flg'] = 0
        params['dc_id'] = 'dc03'
        params['group_id'] = ''
        params['ce01_ip_address'] = '100.114.0.1'
        params['ce02_ip_address'] = '100.114.0.2'
        params['network_address'] = '100.114.0.0'
        params['netmask'] = 16
        params['next_hop'] = '100.107.3.254'
        params['status'] = 0
        db_create.set_context(db_endpoint_dc_segment, params)
        db_create.execute()
Ejemplo n.º 16
0
    def __create_vlan(self, job_input):

        # Get JOB Input Parameters
        iaas_region_id = job_input['IaaS_region_id']
        iaas_tenant_id = job_input['IaaS_tenant_id']
        iaas_network_id = job_input['IaaS_network_id']
        iaas_network_type = job_input['IaaS_network_type']
        iaas_segmentation_id = job_input['IaaS_segmentation_id']
        network_name = job_input['network_name']
        operation_id = job_input['operation_id']
        tenant_name = job_input['tenant_name']
        nal_tenant_id = job_input['nal_tenant_id']
        pod_id = job_input['pod_id']
        dc_id = job_input['dc_id']

        # Get Endpoint(OpenStack:VIM)
        os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id,
                                                   dc_id)

        # Get Endpoint(DB Client)
        db_endpoint_vlan = self.get_db_endpoint(self.job_config.REST_URI_VLAN)

        # Create Instance(OpenStack Client)
        osc_networks = networks.OscQuantumNetworks(self.job_config)

        # Create Instance(VXLAN-GW)
        vxlangw_pod_instance = routingpod.RoutingPod()
        vxlangw_instance = vxlangw.VxlanGwClient(self.job_config)

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)

        vxlangw_pod_id = ''
        rule_id = ''
        os_cre_network_vim = {}
        if iaas_network_type.upper() == self.job_config.NW_TYPE_VXLAN:

            vxlangw_endpoint = self.get_os_endpoint_vxlangw(iaas_region_id)

            # Create Network(OpenStack:VIM)
            os_cre_network_vim = osc_networks.create_network(
                os_endpoint_vim, network_name)

            vxlangw_pod_id = vxlangw_pod_instance.\
                                routing_vxlangw_pod(job_input)

            params = [
                vxlangw_endpoint['endpoint'],
                vxlangw_endpoint['user_id'],
                vxlangw_endpoint['user_password'],
                os_cre_network_vim['network']['provider:segmentation_id'],
                vxlangw_pod_id,
                iaas_network_id,
                vxlangw_endpoint['timeout'],
            ]
            vxlan_gw_res = vxlangw_instance.create_vxlan_gw(params)

            pattern = re.compile('\|\s+id\s+\|\s+(.*)\s+\|')
            for vxlan_gw in vxlan_gw_res:
                matchOB = pattern.match(vxlan_gw)
                if matchOB:
                    rule_id = matchOB.group(1)
                    break

        elif iaas_network_type.upper() == self.job_config.NW_TYPE_VLAN:

            vim_iaas_with_flg = self.get_vim_iaas_with_flg(job_input)
            if vim_iaas_with_flg == 0:
                physical_network_name = None
            else:
                physical_network_name = self.get_os_physical_network_name()
            # Create Network(OpenStack:VIM)
            os_cre_network_vim = osc_networks.create_network(
                os_endpoint_vim, network_name, True, False,
                iaas_segmentation_id, physical_network_name)

        # Get Network Data(id)
        network_id = os_cre_network_vim['network']['id']
        vlan_id = os_cre_network_vim['network']['provider:segmentation_id']

        # Create NAL_VIRTUAL_LAN_MNG(DB Client)
        params = {}
        params['create_id'] = operation_id
        params['update_id'] = operation_id
        params['delete_flg'] = 0
        params['tenant_name'] = tenant_name
        params['pod_id'] = pod_id
        params['tenant_id'] = nal_tenant_id
        params['IaaS_region_id'] = iaas_region_id
        params['IaaS_tenant_id'] = iaas_tenant_id
        params['IaaS_network_id'] = iaas_network_id
        params['IaaS_network_type'] = iaas_network_type
        params['IaaS_segmentation_id'] = iaas_segmentation_id
        params['vlan_id'] = vlan_id
        params['network_id'] = network_id
        params['rule_id'] = rule_id
        params['nal_vlan_info'] = json.dumps(os_cre_network_vim['network'])
        db_create_instance.set_context(db_endpoint_vlan, params)
        db_create_instance.execute()

        return {'network_id': network_id, 'vlan_id': vlan_id}
Ejemplo n.º 17
0
    def __create_port_tenant_iaas(self,
                                  job_input,
                                  network_id,
                                  vlan_id,
                                  mac_address=''):

        # Get JOB Input Parameters
        operation_id = job_input['operation_id']
        iaas_region_id = job_input['IaaS_region_id']
        iaas_tenant_id = job_input['IaaS_tenant_id']
        iaas_network_id = job_input['IaaS_network_id']
        iaas_subnet_id = job_input['IaaS_subnet_id']
        #         network_name = job_input['network_name']
        tenant_name = job_input['tenant_name']
        pod_id = job_input['pod_id']
        nal_tenant_id = job_input['nal_tenant_id']
        apl_type = job_input['apl_type']

        # Get Endpoint(OpenStack:VIM)
        os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id)

        # Get Endpoint(DB Client)
        db_endpoint_port = self.get_db_endpoint(self.job_config.REST_URI_PORT)

        # Create Instance(OpenStack Client)
        os_ports_instance = ports.OscQuantumPorts(self.job_config)

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)
        db_list_instance = list.ListClient(self.job_config)

        iaas_port_create_count = 0
        while iaas_port_create_count <= \
                            self.job_config.OS_PORT_CREATE_RETRY_COUNT:

            # Get Free IpAddress(IaaS)
            free_ip_iaas = self.get_free_ip_max(job_input, iaas_subnet_id)

            # Create Port(OpenStack:IaaS)
            try:
                os_cre_port_iaas = os_ports_instance.create_port(
                    os_endpoint_vim, iaas_network_id, self.IAAS_PORT_NAME,
                    True, free_ip_iaas['id'], free_ip_iaas['ip'], mac_address)

            except Exception as e:

                if str(e) == self.job_config.OS_ERR_MSG_PORT_DUPLICATED:

                    if iaas_port_create_count \
                                == self.job_config.OS_PORT_CREATE_RETRY_COUNT:
                        raise SystemError(
                            'Exceeded Limit Count: OpenStack Port Create(IaaS).'
                        )

                    time.sleep(self.job_config.OS_PORT_CREATE_WAIT_TIME)
                    iaas_port_create_count += 1
                    continue

                raise

            break

        iaas_port_id = os_cre_port_iaas['port']['id']

        # Get Port Info
        port_info = os_cre_port_iaas['port']
        port_id = port_info['id']
        ip_address = port_info['fixed_ips'][0]['ip_address']

        # Create NAL_PORT_MNG(DB)
        params = {}
        params['create_id'] = operation_id
        params['update_id'] = operation_id
        params['delete_flg'] = 0
        params['port_id'] = port_id
        params['tenant_name'] = tenant_name
        params['pod_id'] = pod_id
        params['tenant_id'] = nal_tenant_id
        params['network_id'] = network_id
        params['network_type'] = self.job_config.NW_TYPE_IN
        params['network_type_detail'] = self.job_config.NW_TYPE_TENANT
        params['apl_type'] = apl_type
        params['node_id'] = ''
        params['IaaS_region_id'] = iaas_region_id
        params['IaaS_tenant_id'] = iaas_tenant_id
        params['IaaS_network_id'] = iaas_network_id
        params['IaaS_subnet_id'] = iaas_subnet_id
        params['IaaS_port_id'] = iaas_port_id
        params['nic'] = ''
        params['ip_address'] = ip_address
        params['netmask'] = free_ip_iaas['netmask']
        params['port_info'] = json.dumps(port_info)
        params['msa_info'] = json.dumps({})

        db_create_instance.set_context(db_endpoint_port, params)
        db_create_instance.execute()

        # List NAL_PORT_MNG(DB)
        params = {}
        params['port_id'] = port_id
        params['delete_flg'] = 0
        db_list_instance.set_context(db_endpoint_port, params)
        db_list_instance.execute()
        port_list = db_list_instance.get_return_param()

        # Set Output Parameters
        output = {}
        output['network_id'] = port_list[0]['network_id']
        output['port_id'] = port_list[0]['port_id']
        output['ip_address'] = port_list[0]['ip_address']
        output['netmask'] = port_list[0]['netmask']
        output['rec_id'] = port_list[0]['ID']
        output['subnet_ip_address'] = free_ip_iaas['subnet_ip']
        output['IaaS_subnet_id'] = free_ip_iaas['id']
        output['vlan_id'] = vlan_id

        return output
Ejemplo n.º 18
0
    def setUp(self):
        # Establish a clean test environment.
        super(TestAutoVlbThrough, self).setUp()

        vim_iaas_with_flg = self.get_vim_iaas_with_flg_for_test()

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_pod = \
            base.JobAutoBase().get_db_endpoint(config.JobConfig().REST_URI_POD)
        db_endpoint_tenant = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_TENANT)
        db_endpoint_msa_vlan = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_MSA_VLAN)
        db_endpoint_vlan = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_VLAN)
        db_endpoint_port = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_PORT)
        db_endpoint_license = \
            base.JobAutoBase().get_db_endpoint(
                config.JobConfig().REST_URI_LICENSE)

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['pod_id'] = 'pod_unit_test2'
        params['use_type'] = 1
        params['ops_version'] = 1
        params['weight'] = '50'
        db_create.set_context(db_endpoint_pod, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['pod_id'] = 'pod_unit_test1'
        params['use_type'] = 1
        params['ops_version'] = 1
        params['weight'] = '60'
        db_create.set_context(db_endpoint_pod, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['status'] = 0
        params['network_address'] = '10.20.0.0'
        params['netmask'] = '24'
        params['vlan_id'] = 'vlan_id_0000_1111_2222'
        db_create.set_context(db_endpoint_msa_vlan, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0

        if vim_iaas_with_flg == 0:
            params['network_id'] = '094049539a7ba2548268d74cd5874ebc'
        else:
            params['network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'

        params['tenant_name'] = '1de3cf1741674a0dadd15affdb2ffae2'
        params['pod_id'] = 'pod_unit_test1'
        params['tenant_id'] = ''
        params['IaaS_network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'
        params['IaaS_network_type'] = 'VLAN'
        params['IaaS_region_id'] = 'region_unit_test1'
        params['vlan_id'] = '2016'
        db_create.set_context(db_endpoint_vlan, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0

        if vim_iaas_with_flg == 0:
            params['network_id'] = '094049539a7ba2548268d74cd5874ebc'
        else:
            params['network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'

        params['tenant_name'] = '1de3cf1741674a0dadd15affdb2ffae2'
        params['pod_id'] = 'pod_unit_test1'
        params['tenant_id'] = ''
        params['IaaS_network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'
        params['IaaS_network_type'] = 'VXLAN'
        params['IaaS_region_id'] = 'region_unit_test1'
        params['vlan_id'] = '2017'
        db_create.set_context(db_endpoint_vlan, params)
        db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['port_id'] = 'port_id_00001'

        if vim_iaas_with_flg == 0:
            params['network_id'] = '094049539a7ba2548268d74cd5874ebc'
        else:
            params['network_id'] = 'd6680829-59a5-484b-98c2-36c8849ec8bc'

        params['tenant_name'] = '1de3cf1741674a0dadd15affdb2ffae2'
        params['pod_id'] = 'pod_unit_test1'
        params['tenant_id'] = ''
        params['network_type'] = '1'
        params['network_type_detail'] = '1'
        db_create.set_context(db_endpoint_port, params)
        db_create.execute()

        for device_type in ('1', '2', '3', '4'):
            params = {}
            params['create_id'] = 'test_nw_automation_user_001'
            params['update_id'] = 'test_nw_automation_user_001'
            params['delete_flg'] = 0
            params['license'] = 'test_license_001'
            params['type'] = 2
            params['device_type'] = device_type
            params['status'] = 0
            db_create.set_context(db_endpoint_license, params)
            db_create.execute()

        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['update_id'] = 'test_nw_automation_user_001'
        params['delete_flg'] = 0
        params['tenant_name'] = '1de3cf1741674a0dadd15affdb2ffae2'
        params['IaaS_region_id'] = 'region_unit_test1'
        params['IaaS_tenant_id'] = '1de3cf1741674a0dadd15affdb2ffae2'
        tenant_info = [{
            "description": "",
            "enabled": True,
            "id": "f81f98e26fd934a0544632420e43a8fa",
            "msa_customer_id": 0,
            "msa_customer_name": "",
            "name": "nal_tenant_test",
            "pod_id": "pod_unit_test1"
        }]
        params['tenant_info'] = json.dumps(tenant_info)
        db_create.set_context(db_endpoint_tenant, params)
        db_create.execute()
Ejemplo n.º 19
0
    def setUp(self):
        # Establish a clean test environment.
        super(TestLicenseAPI, self).setUp()

        # Create Instance(DB Client)
        db_create = create.CreateClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_msa_vlan = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_MSA_VLAN)
        db_endpoint_port = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_PORT)

        # Create NAL_MSA_VLAN_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['status'] = 0
        params['network_address'] = '10.20.0.0'
        params['netmask'] = '24'
        params['vlan_id'] = 'vlan_id_0000_1111_2222'
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        db_create.set_context(db_endpoint_msa_vlan, params)
        db_create.execute()

        # Create NAL_PORT_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']
        params['update_id'] = JOB_INPUT['operation_id']
        params['delete_flg'] = 0
        params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
        params['tenant_id'] = JOB_INPUT['tenant_id']
        params['pod_id'] = JOB_INPUT['pod_id']
        params['port_id'] = 'port11'
        params['apl_type'] = 1
        params['network_type'] = 1
        params['network_type_detail'] = 1
        params['ip_address'] = '10.0.0.1'
        params['netmask'] = 16
        params['IaaS_region_id'] = JOB_INPUT['IaaS_region_id']
        params['IaaS_tenant_id'] = JOB_INPUT['IaaS_tenant_id']
        params['IaaS_network_id'] = JOB_INPUT['IaaS_network_id']
        params['IaaS_port_id'] = JOB_INPUT['IaaS_port_id']
        params['network_id'] = ''.join([
            random.choice(string.digits + string.ascii_letters)
            for i in range(10)
        ])
        db_create.set_context(db_endpoint_port, params)
        db_create.execute()

        for network_type_detail in ('2', '3', '4', '5'):
            params = {}
            params['create_id'] = JOB_INPUT['operation_id']
            params['update_id'] = JOB_INPUT['operation_id']
            params['delete_flg'] = 0
            params['tenant_name'] = JOB_INPUT['IaaS_tenant_id']
            params['tenant_id'] = JOB_INPUT['tenant_id']
            params['pod_id'] = JOB_INPUT['pod_id']
            params['port_id'] = 'port2' + network_type_detail
            params['apl_type'] = 1
            params['network_type'] = 2
            params['network_type_detail'] = network_type_detail
            params['ip_address'] = '10.0.0.' + network_type_detail
            params['netmask'] = 16
            params['IaaS_region_id'] = JOB_INPUT['IaaS_region_id']
            params['IaaS_tenant_id'] = JOB_INPUT['IaaS_tenant_id']
            params['IaaS_network_id'] = JOB_INPUT['IaaS_network_id']
            params['IaaS_port_id'] = JOB_INPUT['IaaS_port_id']
            params['network_id'] = ''.join([
                random.choice(string.digits + string.ascii_letters)
                for i in range(10)
            ])
            db_create.set_context(db_endpoint_port, params)
            db_create.execute()
Ejemplo n.º 20
0
    def finalize_dc_connect_vm(self, job_input):

        function_name = inspect.currentframe().f_code.co_name

        # Output Log(Job Input)
        self.output_log_job_params(self.LOG_TYPE_INPUT, __name__,
                                   function_name, job_input)

        # Get JOB Input Parameters
        virtual_apl_list = job_input['data']['virtual_apl_list']
        virtual_lan_list = job_input['data']['virtual_lan_list']
        apl_port_list = job_input['data']['apl_port_list']
        update_apl_port_list = job_input['data']['update_apl_port_list']
        license_list = job_input['data'].get('license_list', [])
        update_apl_wan_port_list = job_input['data'].get(
            'update_apl_wan_port_list', [])

        # Get Endpoint(DB Client)
        db_endpoint_apl = self.get_db_endpoint(self.job_config.REST_URI_APL)
        db_endpoint_vlan = self.get_db_endpoint(self.job_config.REST_URI_VLAN)
        db_endpoint_port = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_endpoint_license = \
            self.get_db_endpoint(self.job_config.REST_URI_LICENSE)

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)
        db_update_instance = update.UpdateClient(self.job_config)

        # Create NAL_APL_MNG(DB Client)
        for virtual_apl_data in virtual_apl_list:
            params = {}
            params['create_id'] = virtual_apl_data['create_id']
            params['update_id'] = virtual_apl_data['update_id']
            params['delete_flg'] = virtual_apl_data['delete_flg']
            params['tenant_name'] = virtual_apl_data['tenant_name']
            params['apl_type'] = virtual_apl_data['apl_type']
            params['type'] = virtual_apl_data['type']
            params['device_type'] = virtual_apl_data['device_type']
            params['tenant_id'] = virtual_apl_data['tenant_id']
            params['pod_id'] = virtual_apl_data['pod_id']
            params['node_id'] = virtual_apl_data['node_id']
            params['node_name'] = virtual_apl_data['node_name']
            params['node_detail'] = virtual_apl_data['node_detail']
            params['server_id'] = virtual_apl_data['server_id']
            params['server_info'] = virtual_apl_data['server_info']
            params['MSA_device_id'] = virtual_apl_data['MSA_device_id']
            params['dns_server_ip_address'] = \
                virtual_apl_data.get('dns_server_ip_address', '')
            params['ntp_server_ip_address'] = \
                virtual_apl_data.get('ntp_server_ip_address', '')
            params['snmp_server_ip_address'] = \
                virtual_apl_data.get('snmp_server_ip_address', '')
            params['syslog_server_ip_address'] = \
                virtual_apl_data.get('syslog_server_ip_address', '')
            db_create_instance.set_context(db_endpoint_apl, params)
            db_create_instance.execute()

        # Create NAL_VIRTUAL_LAN_MNG(DB Client)
        for virtual_lan_data in virtual_lan_list:
            params = {}
            params['create_id'] = virtual_lan_data['create_id']
            params['update_id'] = virtual_lan_data['update_id']
            params['delete_flg'] = virtual_lan_data['delete_flg']
            params['tenant_name'] = virtual_lan_data['tenant_name']
            params['tenant_id'] = virtual_lan_data['tenant_id']
            params['network_id'] = virtual_lan_data['network_id']
            params['pod_id'] = virtual_lan_data['pod_id']
            params['vlan_id'] = virtual_lan_data['vlan_id']
            params['IaaS_network_type'] \
                                = virtual_lan_data['IaaS_network_type']
            params['IaaS_network_id'] \
                                = virtual_lan_data['IaaS_network_id']
            params['IaaS_segmentation_id'] \
                                = virtual_lan_data['IaaS_segmentation_id']
            params['rule_id'] = virtual_lan_data['rule_id']
            params['nal_vlan_info'] = virtual_lan_data['nal_vlan_info']
            db_create_instance.set_context(db_endpoint_vlan, params)
            db_create_instance.execute()

        # Create NAL_PORT_MNG(DB Client)
        for apl_port_data in apl_port_list:
            params = {}
            params['create_id'] = apl_port_data['create_id']
            params['update_id'] = apl_port_data['update_id']
            params['delete_flg'] = apl_port_data['delete_flg']
            params['tenant_name'] = apl_port_data['tenant_name']
            params['tenant_id'] = apl_port_data['tenant_id']
            params['apl_type'] = apl_port_data['apl_type']
            params['port_id'] = apl_port_data['port_id']
            params['IaaS_port_id'] = apl_port_data['IaaS_port_id']
            params['node_id'] = apl_port_data['node_id']
            params['network_id'] = apl_port_data['network_id']
            params['nic'] = apl_port_data['nic']
            params['ip_address'] = apl_port_data['ip_address']
            params['netmask'] = apl_port_data['netmask']
            params['ip_address_v6'] = apl_port_data.get('ip_address_v6', '')
            params['netmask_v6'] = apl_port_data.get('netmask_v6', '')
            params['port_info'] = apl_port_data['port_info']
            params['msa_info'] = apl_port_data['msa_info']
            params['network_type'] = apl_port_data['network_type']
            params['network_type_detail'] = apl_port_data[
                'network_type_detail']
            db_create_instance.set_context(db_endpoint_port, params)
            db_create_instance.execute()

        # Update NAL_PORT_MNG(DB Client)
        for apl_port_data in update_apl_port_list:
            params = {}
            params['update_id'] = apl_port_data['params']['update_id']
            params['node_id'] = apl_port_data['params']['node_id']
            params['nic'] = apl_port_data['params']['nic']
            params['msa_info'] = apl_port_data['params']['msa_info']
            keys = [apl_port_data['keys']['ID']]
            db_update_instance.set_context(db_endpoint_port, keys, params)
            db_update_instance.execute()

        for apl_port_data in update_apl_wan_port_list:
            params = {}
            params['update_id'] = apl_port_data['params']['update_id']
            params['msa_info'] = apl_port_data['params']['msa_info']

            if 'ip_address_v6' in apl_port_data['params']:
                params['ip_address_v6'] = apl_port_data['params'][
                    'ip_address_v6']
            if 'netmask_v6' in apl_port_data['params']:
                params['netmask_v6'] = apl_port_data['params']['netmask_v6']

            if 'port_info' in apl_port_data['params']:
                params['port_info'] = apl_port_data['params']['port_info']

            keys = [apl_port_data['keys']['ID']]
            db_update_instance.set_context(db_endpoint_port, keys, params)
            db_update_instance.execute()

        # Update NAL_LICENSE_MNG(DB Client)
        for (license_id, apl_info) in zip(license_list, virtual_apl_list):

            # Update NAL_LICENSE_MNG
            keys = [license_id]
            params = {}
            params['node_id'] = apl_info['node_id']
            db_update_instance.set_context(db_endpoint_license, keys, params)
            db_update_instance.execute()

        # Set JOB Output Parameters
        job_output = {}

        # Output Log(Job Output)
        self.output_log_job_params(self.LOG_TYPE_OUTPUT, __name__,
                                   function_name, job_output)

        return job_output
Ejemplo n.º 21
0
    def dc_member_create_info_get(self, job_input):

        function_name = inspect.currentframe().f_code.co_name

        # Output Log(Job Input)
        self.output_log_job_params(self.LOG_TYPE_INPUT, __name__,
                                   function_name, job_input)

        # Get JOB Input Parameters
        iaas_tenant_id = job_input['IaaS_tenant_id']
        operation_id = job_input['operation_id']
        dc_id = job_input['dc_id']
        group_type = job_input['group_type']
        group_name = job_input['group_name']
        tenant_name = job_input['tenant_name']

        # Get Endpoint(DB Client)
        db_endpoint_dc = self.get_db_endpoint(self.job_config.REST_URI_WIM_DC)
        db_endpoint_dc_group = self.get_db_endpoint(
            self.job_config.REST_URI_WIM_DC_CON_GROUP)
        db_endpoint_dc_member = self.get_db_endpoint(
            self.job_config.REST_URI_WIM_DC_CON_MEMBER)
        db_endpoint_dc_vlan = self.get_db_endpoint(
            self.job_config.REST_URI_WIM_DC_CON_VLAN)
        db_endpoint_dc_segment = self.get_db_endpoint(
            self.job_config.REST_URI_WIM_DC_SEGMENT_MNG)

        # Create Instance(DB Client)
        db_create_instance = create.CreateClient(self.job_config)
        db_list_instance = list.ListClient(self.job_config)
        db_update_instance = update.UpdateClient(self.job_config)

        # List WIM_DC_MNG(DB Client)
        params = {}
        params['dc_id'] = dc_id
        params['delete_flg'] = 0
        db_list_instance.set_context(db_endpoint_dc, params)
        db_list_instance.execute()
        dc_mng_list = db_list_instance.get_return_param()

        if len(dc_mng_list) == 0:
            raise SystemError('dc info not exists.')

        # List WIM_DC_CONNECT_GROUP_MNG(DB Client)
        params = {}
        params['tenant_name'] = tenant_name
        params['group_type'] = group_type
        params['delete_flg'] = 0
        db_list_instance.set_context(db_endpoint_dc_group, params)
        db_list_instance.execute()
        dc_group_list = db_list_instance.get_return_param()

        group_id = ''
        group_rec_id = ''

        if len(dc_group_list) == 0:

            # Generate Group Id
            group_id = str(uuid.uuid4())

            # Create WIM_DC_CONNECT_GROUP_MNG(DB Client)
            params = {}
            params['create_id'] = operation_id
            params['update_id'] = operation_id
            params['delete_flg'] = 0
            params['IaaS_tenant_id'] = iaas_tenant_id
            params['group_id'] = group_id
            params['group_type'] = group_type
            params['group_name'] = group_name
            params['tenant_name'] = tenant_name
            params['task_status'] = 0
            db_create_instance.set_context(db_endpoint_dc_group, params)
            db_create_instance.execute()

            # List WIM_DC_CONNECT_GROUP_MNG(DB Client)
            params = {}
            params['tenant_name'] = tenant_name
            params['group_type'] = group_type
            params['delete_flg'] = 0
            db_list_instance.set_context(db_endpoint_dc_group, params)
            db_list_instance.execute()
            dc_group_list = db_list_instance.get_return_param()

            group_rec_id = dc_group_list[0]['ID']

        else:

            group_id = dc_group_list[0]['group_id']
            group_rec_id = dc_group_list[0]['ID']

            # Update WIM_DC_VLAN_MNG(DB Client)
            keys = [group_rec_id]
            params = {}
            params['task_status'] = 0
            params['update_id'] = operation_id
            db_update_instance.set_context(db_endpoint_dc_group, keys, params)
            db_update_instance.execute()

        # List WIM_DC_CONNECT_MEMBER_MNG(DB Client)
        params = {}
        params['tenant_name'] = tenant_name
        params['group_id'] = group_id
        params['delete_flg'] = 0
        db_list_instance.set_context(db_endpoint_dc_member, params)
        db_list_instance.execute()
        dc_member_list = db_list_instance.get_return_param()

        dc_vlan_id = None

        if job_input['group_type'] in [
                str(self.job_config.GROUP_TYPE_CSRV_TUNNEL_ESP),
                str(self.job_config.GROUP_TYPE_CSRV_TUNNEL_AH),
        ]:

            # List WIM_DC_SEGMENT_MNG(DB Client)
            params = {}
            params['dc_id'] = dc_id
            params['group_id'] = group_id
            params['status'] = 1
            params['delete_flg'] = 0
            db_list_instance.set_context(db_endpoint_dc_segment, params)
            db_list_instance.execute()
            dc_segment_list = db_list_instance.get_return_param()

            if len(dc_segment_list) == 0:

                # List WIM_DC_SEGMENT_MNG(DB Client)
                params = {}
                params['dc_id'] = dc_id
                params['status'] = 0
                params['delete_flg'] = 0
                db_list_instance.set_context(db_endpoint_dc_segment, params)
                db_list_instance.execute()
                dc_segment_list1 = db_list_instance.get_return_param()

                if len(dc_segment_list1) > 0:

                    # Update WIM_DC_SEGMENT_MNG(DB Client)
                    keys = [dc_segment_list1[0]['ID']]
                    params = {}
                    params['status'] = 1
                    params['group_id'] = group_id
                    params['update_id'] = operation_id
                    db_update_instance.set_context(db_endpoint_dc_segment,
                                                   keys, params)
                    db_update_instance.execute()

                else:
                    # List WIM_DC_SEGMENT_MNG(DB Client)
                    params = {}
                    params['dc_id'] = dc_id
                    params['status'] = 2
                    params['delete_flg'] = 0
                    db_list_instance.set_context(db_endpoint_dc_segment,
                                                 params)
                    db_list_instance.execute()
                    dc_segment_list2 = db_list_instance.get_return_param()

                    if len(dc_segment_list2) > 0:

                        # Update WIM_DC_SEGMENT_MNG(DB Client)
                        keys = [dc_segment_list2[0]['ID']]
                        params = {}
                        params['status'] = 1
                        params['group_id'] = group_id
                        params['update_id'] = operation_id
                        db_update_instance.set_context(db_endpoint_dc_segment,
                                                       keys, params)
                        db_update_instance.execute()

                    else:
                        raise SystemError('dc segment not found.')

        else:
            # List WIM_DC_VLAN_MNG(DB Client)
            params = {}
            params['group_id'] = group_id
            params['delete_flg'] = 0
            db_list_instance.set_context(db_endpoint_dc_vlan, params)
            db_list_instance.execute()
            dc_vlan_list = db_list_instance.get_return_param()

            if len(dc_vlan_list) > 0:
                dc_vlan_id = dc_vlan_list[0]['vlan_id']

            else:

                # List WIM_DC_VLAN_MNG(DB Client)
                params = {}
                params['status'] = 0
                params['delete_flg'] = 0
                db_list_instance.set_context(db_endpoint_dc_vlan, params)
                db_list_instance.execute()
                dc_vlan_list1 = db_list_instance.get_return_param()

                if len(dc_vlan_list1) > 0:

                    # Update WIM_DC_VLAN_MNG(DB Client)
                    keys = [dc_vlan_list1[0]['ID']]
                    params = {}
                    params['status'] = 1
                    params['group_id'] = group_id
                    params['update_id'] = operation_id
                    db_update_instance.set_context(db_endpoint_dc_vlan, keys,
                                                   params)
                    db_update_instance.execute()

                    dc_vlan_id = dc_vlan_list1[0]['vlan_id']

                else:
                    # List WIM_DC_VLAN_MNG(DB Client)
                    params = {}
                    params['status'] = 2
                    params['delete_flg'] = 0
                    db_list_instance.set_context(db_endpoint_dc_vlan, params)
                    db_list_instance.execute()
                    dc_vlan_list2 = db_list_instance.get_return_param()

                    if len(dc_vlan_list2) > 0:

                        # Update WIM_DC_VLAN_MNG(DB Client)
                        keys = [dc_vlan_list2[0]['ID']]
                        params = {}
                        params['status'] = 1
                        params['group_id'] = group_id
                        params['update_id'] = operation_id
                        db_update_instance.set_context(db_endpoint_dc_vlan,
                                                       keys, params)
                        db_update_instance.execute()

                        dc_vlan_id = dc_vlan_list2[0]['vlan_id']

                    else:
                        raise SystemError('vlanid not found.')

        # Get Config(wan_allocation_info)
        wan_allocation_info = self.get_wan_allocation_info(
            job_input['group_type'], dc_id)

        # Set JOB Output Parameters
        job_output = {
            'dc_name': dc_mng_list[0]['dc_name'],
            'group_id': group_id,
            'group_rec_id': group_rec_id,
            'dc_member_list': dc_member_list,
            'dc_vlan_id': dc_vlan_id,
            'wan_allocation_info': wan_allocation_info,
        }

        # Output Log(Job Output)
        self.output_log_job_params(self.LOG_TYPE_OUTPUT, __name__,
                                   function_name, job_output)

        return job_output