Exemplo n.º 1
0
    def __get_port_nic_name(self, job_input, subnet_ip, subnet_id):

        # Get JOB Input Parameters
        node_id = job_input['apl_info'][
                        self.job_config.VM_ROUTER_NODE_NAME1]['node_id']

        nic_name = ''
        if len(subnet_ip) > 0 and len(subnet_id) > 0:
            # Create Instance(DB Client)
            db_list = list.ListClient(self.job_config)

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

            params = {}
            params['node_id'] = node_id

            if self.utils.get_ipaddress_version(subnet_ip) \
                                            == self.utils.IP_VER_V4:
                params['IaaS_subnet_id'] = subnet_id
            else:
                params['IaaS_subnet_id_v6'] = subnet_id

            db_list.set_context(db_endpoint_port, params)
            db_list.execute()
            apl_list = db_list.get_return_param()

            nic_name = apl_list[0]['nic']

        return nic_name
Exemplo n.º 2
0
    def __get_nodedetail_objlist(self, job_input, list_type):

        node_id = job_input['node_id']

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

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)

        # List NAL_VNF_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['node_id'] = node_id
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        apl_list = db_list.get_return_param()

        node_detail_dict = json.loads(apl_list[0]['node_detail'])

        if list_type == 'zone':
            obj_list = node_detail_dict.get('ZoneNameList', [])
        else:
            obj_list = node_detail_dict.get('InterFaceList', [])

        return obj_list
Exemplo n.º 3
0
    def __update_db_apl(self, job_input, node_detail_update):

        # Get JOB Input Parameters
        operation_id = job_input['operation_id']
        node_id = job_input['node_id']

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

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)
        db_update = update.UpdateClient(self.job_config)

        # List NAL_VNF_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['node_id'] = node_id
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        apl_list = db_list.get_return_param()

        node_detail_dict = json.loads(apl_list[0]['node_detail'])
        node_detail_dict.update(node_detail_update)

        # Update NAL_LICENSE_MNG(DB Client)
        keys = [apl_list[0]['ID']]
        params = {}
        params['update_id'] = operation_id
        params['node_detail'] = json.dumps(node_detail_dict)
        db_update.set_context(db_endpoint, keys, params)
        db_update.execute()
Exemplo n.º 4
0
    def __get_vlan(self, job_input):

        # Get JOB Input Parameters
        tenant_name = job_input['tenant_name']
        pod_id = job_input['pod_id']
        nal_tenant_id = job_input['nal_tenant_id']
        iaas_network_id = job_input['IaaS_network_id']
        iaas_network_type = job_input['IaaS_network_type']

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

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

        # List NAL_VIRTUAL_LAN_MNG(DB Client)
        params = {}
        params['tenant_name'] = tenant_name
        params['pod_id'] = pod_id
        params['tenant_id'] = nal_tenant_id
        params['IaaS_network_id'] = iaas_network_id
        params['IaaS_network_type'] = iaas_network_type
        params['delete_flg'] = 0
        db_list_instance.set_context(db_endpoint_vlan, params)
        db_list_instance.execute()
        vlan_list = db_list_instance.get_return_param()

        return vlan_list
Exemplo n.º 5
0
    def __withdraw_global_ip(self, operation_id, global_ip):

        # Get Endpoint(DB Client)
        db_endpoint_global_ip = self.get_db_endpoint(
            self.job_config.REST_URI_GLOBAL_IP)

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)
        db_update = update.UpdateClient(self.job_config)

        # List NAL_GLOBAL_IP_MNG(DB Client)
        params = {}
        params['status'] = 101
        params['delete_flg'] = 0
        params['global_ip'] = global_ip
        db_list.set_context(db_endpoint_global_ip, params)
        db_list.execute()
        global_ip_list = db_list.get_return_param()

        if len(global_ip_list) == 0:
            raise SystemError('global_ip is already deleted.')

        # Update NAL_GLOBAL_IP_MNG(DB Client)
        keys = [global_ip_list[0]['ID']]
        params = {}
        params['status'] = 103
        params['tenant_name'] = ''
        params['node_id'] = ''
        params['update_id'] = operation_id
        db_update.set_context(db_endpoint_global_ip, keys, params)
        db_update.execute()
Exemplo n.º 6
0
    def __withdraw_license(self, job_input, node_id):

        # Get JOB Input Parameters
        operation_id = job_input['data']['operation_id']

        # Get Endpoint(DB Client)
        db_endpoint_license = self.get_db_endpoint(
            self.job_config.REST_URI_LICENSE)

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)
        db_update = update.UpdateClient(self.job_config)

        # List NAL_LICENSE_MNG(DB Client)
        params = {}
        params['status'] = 2
        params['node_id'] = node_id
        params['delete_flg'] = 0
        db_list.set_context(db_endpoint_license, params)
        db_list.execute()
        license_list = db_list.get_return_param()

        # Update NAL_LICENSE_MNG(DB Client)
        for rec in license_list:
            keys = [rec['ID']]
            params = {}
            params['status'] = 3
            params['tenant_name'] = ''
            params['node_id'] = ''
            params['update_id'] = operation_id
            db_update.set_context(db_endpoint_license, keys, params)
            db_update.execute()
Exemplo n.º 7
0
    def __setup_tenant_vlan_fortigate(self,
                                      job_input,
                                      pod_id,
                                      msa_device_id,
                                      msa_config_for_common,
                                      msa_config_for_device):

        msa_info = {}

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id4 = job_input['port_id4']

        # List NAL_VNF_MNG(DB Client)
        db_endpoint = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id4
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        port_list = db_list.get_return_param()

        # Create Instance(MSA Soap Client)
        msa = fortigatevm541ordercmdws.FortigateVm541OrderCommandWs(
                                                    self.job_config,
                                                    self.nal_endpoint_config,
                                                    pod_id)

        for count in range(int(self.job_config.MSA_AFTER_ATTACH_COUNT)):
            try:
                # Create Interface(MSA)
                msa_res = self.execute_msa_command(
                    msa_config_for_device,
                    msa,
                    'create_fortigate_vm_interface',
                    msa_device_id,
                    port_list[0]['nic'],
                    port_list[0]['ip_address'],
                    self.utils.get_subnet_mask_from_cidr_len(
                                        port_list[0]['netmask']),
                    'Enable',
                    'Enable',
                    'Enable'
                )
                msa_info['create_fortigate_vm_interface'] = \
                    msa_res[msa.RES_KEY_IN]
                break

            except SystemError as e:
                time.sleep(int(self.job_config.MSA_AFTER_ATTACH_INTERVAL))
                count += 1

                if count == int(self.job_config.MSA_AFTER_ATTACH_COUNT):
                    raise e

        # Update NAL_PORT_MNG(DB)
        self.__update_db_port(job_input, port_id4, msa_info)
Exemplo n.º 8
0
    def routing_vxlangw_pod(self, job_input):

        # Get JOB Input Parameters
        iaas_region_id = job_input.get('IaaS_region_id', '')

        # Get Endpoint(DB Client)
        db_endpoint = self.get_db_endpoint(
            self.job_config.REST_URI_VXLANGW_POD)

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

        # List NAL_POD_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['IaaS_region_id'] = iaas_region_id
        db_list_instance.set_context(db_endpoint, params)
        db_list_instance.execute()
        pod_list = db_list_instance.get_return_param()

        # Assing Pod
        weight = 0
        assing_pod = {}
        for pod_wk in pod_list:
            if int(pod_wk['weight']) > weight:
                weight = int(pod_wk['weight'])
                assing_pod = pod_wk

        # Check
        if len(assing_pod.get('vxlangw_pod_id', '')) == 0:
            raise SystemError('vxlangw_pods not exists.')

        return assing_pod['vxlangw_pod_id']
Exemplo n.º 9
0
    def update_db_license_status(self, device_type, status):

        # Create Instance(DB Client)
        db_list = list.ListClient(config.JobConfig())
        db_update = update.UpdateClient(config.JobConfig())

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

        # Update NAL_LICENSE_MNG
        params = {}
        params['create_id'] = 'test_nw_automation_user_001'
        params['type'] = 2
        params['device_type'] = device_type

        db_list.set_context(db_endpoint_license, params)
        db_list.execute()
        update_license_list = db_list.get_return_param()

        for update_license in update_license_list:
            keys = [update_license['ID']]
            params = {}
            params['status'] = status
            db_update.set_context(db_endpoint_license, keys, params)
            db_update.execute()
Exemplo n.º 10
0
    def __update_db_port(self, job_input, port_id, msa_info):

        # Get JOB Input Parameters
        operation_id = job_input['operation_id']
        nal_tenant_id = job_input['nal_tenant_id']

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

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)
        db_update = update.UpdateClient(self.job_config)

        # List NAL_VNF_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        port_list = db_list.get_return_param()

        # Update NAL_LICENSE_MNG(DB Client)
        keys = [port_list[0]['ID']]
        params = {}
        params['update_id'] = operation_id
        params['msa_info'] = json.dumps(msa_info)
        db_update.set_context(db_endpoint, keys, params)
        db_update.execute()
Exemplo n.º 11
0
    def __get_db_apl(self, job_input):

        # Get Input Parameters
        tenant_name = job_input['tenant_name']
        device_type = job_input['device_type']

        apl_type = self.job_config.APL_TYPE_VR
        hard_type = self.job_config.TYPE_RT

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

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

        # List NAL_APL_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['tenant_name'] = tenant_name
        params['apl_type'] = apl_type
        params['type'] = hard_type
        params['device_type'] = device_type
        db_list_instance.set_context(db_endpoint_apl, params)
        db_list_instance.execute()
        apl_list = db_list_instance.get_return_param()

        return apl_list
Exemplo n.º 12
0
    def __setup_tenant_vlan_intersec_base(self, job_input, pod_id,
                                          msa_device_id, msa_config_for_common,
                                          msa_config_for_device):

        msa_info = {}
        node_detail = {}

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id4 = job_input['port_id4']

        # List NAL_VNF_MNG(DB Client)
        db_endpoint = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id4
        db_list.set_context(db_endpoint, params)
        db_list.execute()

        port_list = db_list.get_return_param()

        # Create Instance(MSA Soap Client)
        msa = intersecordercmdws.IntersecOrderCommandWs(
            self.job_config, self.nal_endpoint_config, pod_id)

        # Create Network(MSA)
        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_intersec_sg_nw', msa_device_id,
            port_list[0]['nic'], port_list[0]['ip_address'],
            self.utils.get_subnet_mask_from_cidr_len(port_list[0]['netmask']))
        msa_info['create_intersec_sg_nw'] = msa_res[msa.RES_KEY_IN]

        # Reboot(MSA)
        msa_res = self.execute_msa_command(msa_config_for_device, msa,
                                           'create_intersec_sg_reboot',
                                           msa_device_id)
        # Wait(MSA)
        self.__wait_for_reboot(pod_id, msa_device_id, msa_config_for_device)

        # Create Zabbix Setting(MSA)
        zabbixVIPipAddress = job_input.get('zabbix_vip_ip')
        zabbix01ipAddress = job_input.get('zabbix_01_ip')
        zabbix02ipAddress = job_input.get('zabbix_02_ip')

        if len(zabbixVIPipAddress) > 0 \
                and len(zabbix01ipAddress) > 0 \
                and len(zabbix02ipAddress) > 0:

            msa_res = self.execute_msa_command(
                msa_config_for_device, msa, 'create_intersec_sg_zabbix',
                msa_device_id, job_input['host_name'], zabbixVIPipAddress,
                zabbix01ipAddress, zabbix02ipAddress)
            node_detail['create_intersec_sg_zabbix'] = msa_res[msa.RES_KEY_IN]

        return {'node_detail': node_detail, 'msa_info': msa_info}
Exemplo n.º 13
0
    def __unsetup_ext_lan_fortigate(self, job_input, pod_id, msa_device_id,
                                    vdom_name, msa_config_for_common,
                                    msa_config_for_device, nic_external):

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        node_id = job_input['node_id']
        job_cleaning_mode = job_input.get('job_cleaning_mode', '0')

        # Get Network Info
        ext_network_info = self.get_os_network_info(
            pod_id, nal_tenant_id, self.job_config.NW_NAME_EXT, '')

        # List NAL_VNF_MNG(DB Client)
        db_endpoint = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        # Get Network Info pub
        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['network_id'] = ext_network_info['network_id']
        params['node_id'] = node_id
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        port_list = db_list.get_return_param()
        ip_address_v6 = port_list[0].get('ip_address_v6', '')

        # Create Instance(MSA Soap Client)
        msa = fortigateordercmdws.FortigateOrderCommandWs(
            self.job_config, self.nal_endpoint_config, pod_id)

        if ip_address_v6 != '':
            try:
                # Delete Interface(MSA)
                self.execute_msa_command(
                    msa_config_for_device, msa,
                    'delete_fortigate_vlan_ipv6_interface', msa_device_id,
                    vdom_name + '_' + str(ext_network_info['vlan_id']))
            except:
                if job_cleaning_mode == '1':
                    self.output_log_fatal(__name__, traceback.format_exc())
                else:
                    raise

        try:
            # Delete Interface(MSA)
            self.execute_msa_command(
                msa_config_for_device, msa, 'delete_fortigate_vlan_interface',
                msa_device_id,
                vdom_name + '_' + str(ext_network_info['vlan_id']))
        except:
            if job_cleaning_mode == '1':
                self.output_log_fatal(__name__, traceback.format_exc())
            else:
                raise
Exemplo n.º 14
0
    def __get_device_endpoint_info(self, job_input):
        # Get JOB Input Parameters
        tenant_name = job_input['tenant_name']
        pod_id = job_input['pod_id']
        operation_id = job_input['operation_id']
        dc_id = job_input.get('dc_id', 'system')

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

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

        # Get Endpoint(OpenStack:VIM)
        endpoint_config = self.nal_endpoint_config[dc_id]['vim'][pod_id]
        admin_tenant_id = endpoint_config['admin_tenant_id']
        admin_tenant_name = endpoint_config['admin_tenant_name']

        # List NAL_TENANT_MNG(DB Client)
        params = {}
        params['tenant_name'] = tenant_name
        params['delete_flg'] = 0
        db_list_instance.set_context(db_endpoint_tenant, params)
        db_list_instance.execute()
        nal_tenant_list = db_list_instance.get_return_param()

        if len(nal_tenant_list) == 0:
            raise SystemError('tenant not exists.')

        rec_id = nal_tenant_list[0]['ID']
        tenant_info = json.loads(nal_tenant_list[0]['tenant_info'])

        tenant_info_wk = {}
        tenant_info_wk['pod_id'] = pod_id
        tenant_info_wk['id'] = admin_tenant_id
        tenant_info_wk['name'] = admin_tenant_name
        tenant_info_wk['msa_customer_name'] = ''
        tenant_info_wk['msa_customer_id'] = 0
        tenant_info.append(tenant_info_wk)

        # Update NAL_VNF_MNG(DB Client):Set DeleteFlg On
        params = {}
        params['update_id'] = operation_id
        params['tenant_info'] = json.dumps(tenant_info)
        keys = [rec_id]
        db_update_instance.set_context(db_endpoint_tenant, keys, params)
        db_update_instance.execute()

        job_output = {
            'nal_tenant_id': admin_tenant_id,
            'nal_tenant_name': admin_tenant_name,
        }

        return job_output
Exemplo n.º 15
0
    def __setup_add_ipv6_bigip_ve(self, job_input, pod_id, msa_device_id,
                                  msa_config_for_device):

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id = job_input['port_id']
        vlan_name = job_input['network_name']
        fw_ip_v6_address = self.utils.get_ipaddress_compressed(
            job_input['fw_ip_v6_address'])

        # List NAL_PORT_MNG(DB Client)
        db_endpoint_port = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id
        db_list.set_context(db_endpoint_port, params)
        db_list.execute()

        port_list = db_list.get_return_param()

        msa_info = json.loads(port_list[0]['msa_info'])

        # Create Instance(MSA Soap Client)
        msa = bigipveordercmdws.BigIpVeOrderCommandWs(self.job_config,
                                                      self.nal_endpoint_config,
                                                      pod_id)

        # Setting SelfIP IPv6(MSA Soap Client)
        object_params_v4 = json.loads(
            msa_info['create_big_ip_network_self_ip']['objectParameters'])

        for key in object_params_v4[
                msa.OBJECT_FILE_NAME['create_big_ip_network_self_ip']].keys():
            self_ip_name_v4 = key
            break

        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_f5_bigipve_ipv6_selfip',
            msa_device_id, self_ip_name_v4 + 'v6',
            port_list[0]['ip_address_v6'], port_list[0]['netmask_v6'],
            vlan_name)
        msa_info['create_f5_bigipve_ipv6_selfip'] = msa_res[msa.RES_KEY_IN]

        # Setting Static Route(MSA Soap Client)
        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_f5_bigipve_ipv6_staticroute',
            msa_device_id, 'defaultGWv6', 'yes', fw_ip_v6_address, '', '')
        msa_info['create_f5_bigipve_ipv6_staticroute'] = msa_res[
            msa.RES_KEY_IN]

        # Update NAL_PORT_MNG(DB)
        self.__update_db_port(job_input, port_id, msa_info)
Exemplo n.º 16
0
    def tearDown(self):
        """Clear the test environment"""
        super(TestLicenseAPI, self).tearDown()

        # Create Instance(DB Client)
        db_delete = delete.DeleteClient(config.JobConfig())
        db_list = list.ListClient(config.JobConfig())

        # Get Endpoint(DB Client)
        db_endpoint_license = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_LICENSE)
        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)

        # Delete from NAL_LICENSE_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']

        db_list.set_context(db_endpoint_license, params)
        db_list.execute()
        delete_list = db_list.get_return_param()

        for delete_res in delete_list:
            key = delete_res['ID']
            db_delete.set_context(db_endpoint_license, [key])
            db_delete.execute()

        # Delete from NAL_MSA_VLAN_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']

        db_list.set_context(db_endpoint_msa_vlan, params)
        db_list.execute()
        delete_list = db_list.get_return_param()

        for delete_res in delete_list:
            key = delete_res['ID']
            db_delete.set_context(db_endpoint_msa_vlan, [key])
            db_delete.execute()

        # Delete from NAL_PORT_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']

        db_list.set_context(db_endpoint_port, params)
        db_list.execute()
        delete_list = db_list.get_return_param()

        for delete_res in delete_list:
            key = delete_res['ID']
            db_delete.set_context(db_endpoint_port, [key])
            db_delete.execute()
Exemplo n.º 17
0
    def __get_apl_info(self, tenant_name, apl_table_rec_id):

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

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)
        db_update = update.UpdateClient(self.job_config)

        # List NAL_APL_MNG(DB Client)
        params = {}
        params['tenant_name'] = tenant_name
        params['ID'] = apl_table_rec_id
        params['delete_flg'] = 0
        db_list.set_context(db_endpoint_apl, params)
        db_list.execute()
        vnf_list = db_list.get_return_param()

        if len(vnf_list) == 0:
            raise SystemError('server not exists.')

        # Update NAL_APL_MNG(DB Client)
        params = {}
        params['task_status'] = 0
        keys = [vnf_list[0]['ID']]
        db_update.set_context(db_endpoint_apl, keys, params)
        db_update.execute()

        vnf_output = {
            'apl_table_rec_id':
            vnf_list[0]['ID'],
            'msa_device_id':
            vnf_list[0]['MSA_device_id'],
            'pod_id':
            vnf_list[0]['pod_id'],
            'apl_type':
            vnf_list[0]['apl_type'],
            'type':
            vnf_list[0]['type'],
            'device_type':
            vnf_list[0]['device_type'],
            'nal_tenant_id':
            vnf_list[0]['tenant_id'],
            'node_id':
            vnf_list[0]['node_id'],
            'redundant_configuration_flg':
            vnf_list[0]['redundant_configuration_flg']
        }

        return vnf_output
Exemplo n.º 18
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']
Exemplo n.º 19
0
    def __setup_pub_lan_fortigate(self, job_input, pod_id, msa_device_id,
                                  msa_config_for_common, msa_config_for_device,
                                  nic_public):

        msa_info = {}

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id2 = job_input['port_id2']

        # List NAL_VNF_MNG(DB Client)
        db_endpoint = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id2
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        port_list = db_list.get_return_param()

        # Get Network Info
        pub_network_info = self.get_os_network_info(
            pod_id, nal_tenant_id, self.job_config.NW_NAME_PUB, '')

        # Create Instance(MSA Soap Client)
        msa = fortigateordercmdws.FortigateOrderCommandWs(
            self.job_config, self.nal_endpoint_config, pod_id)

        # Create Intergace(MSA)
        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_fortigate_vlan_interface',
            msa_device_id,
            job_input['vdom_name'] + '_' + str(pub_network_info['vlan_id']),
            job_input['vdom_name'], str(pub_network_info['vlan_id']),
            port_list[0]['ip_address'],
            self.utils.get_subnet_mask_from_cidr_len(port_list[0]['netmask']),
            nic_public, 'no')
        msa_info['create_fortigate_vlan_interface'] = \
            msa_res[msa.RES_KEY_IN]

        # Update NAL_PORT_MNG(DB)
        self.__update_db_port(job_input, port_id2, msa_info)
Exemplo n.º 20
0
    def __setup_system_common_intersec_lb(self, job_input, pod_id,
                                          msa_device_id, msa_config_for_common,
                                          msa_config_for_device):

        node_detail = {}

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id1 = job_input['port_id1']

        # List NAL_VNF_MNG(DB Client)
        db_endpoint_port = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id1
        db_list.set_context(db_endpoint_port, params)
        db_list.execute()

        port_list = db_list.get_return_param()

        # Create Instance(MSA Soap Client)
        msa = intersecordercmdws.IntersecOrderCommandWs(
            self.job_config, self.nal_endpoint_config, pod_id)

        # Wait(MSA)
        self.__wait_for_reboot(pod_id, msa_device_id, msa_config_for_device)

        # Create System Common(MSA)
        msa_res = self.execute_msa_command(msa_config_for_device, msa,
                                           'create_intersec_lb_startup',
                                           msa_device_id,
                                           job_input['host_name'],
                                           port_list[0]['ip_address'],
                                           job_input['license_key'])
        node_detail['create_intersec_lb_startup'] = msa_res[msa.RES_KEY_IN]

        # Wait(MSA)
        self.__wait_for_reboot(pod_id, msa_device_id, msa_config_for_device)

        # Update NAL_VNF_MNG(DB)
        self.__update_db_apl(job_input, node_detail)
Exemplo n.º 21
0
    def __setup_ext_lan_fortigate(self, job_input, pod_id, msa_device_id,
                                  msa_config_for_common,
                                  msa_config_for_device):

        msa_info = {}

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id3 = job_input['port_id3']

        # List NAL_VNF_MNG(DB Client)
        db_endpoint = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id3
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        port_list = db_list.get_return_param()

        # Create Instance(MSA Soap Client)
        msa = fortigatevmordercmdws.FortigateVmOrderCommandWs(
            self.job_config, self.nal_endpoint_config, pod_id)

        # Create Interface(MSA)
        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_fortigate_vm_interface',
            msa_device_id, port_list[0]['nic'], port_list[0]['ip_address'],
            self.utils.get_subnet_mask_from_cidr_len(port_list[0]['netmask']),
            'Enable', 'Disable', 'Disable')
        msa_info['create_fortigate_vm_interface'] = msa_res[msa.RES_KEY_IN]

        # Create Static Route(MSA)
        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_fortigate_vm_router_static',
            msa_device_id, 2, None, 'yes',
            msa_config_for_common['ext_vlan_gateway'], '', '',
            port_list[0]['nic'])
        msa_info['create_fortigate_vm_router_static'] = msa_res[msa.RES_KEY_IN]

        # Update NAL_PORT_MNG(DB)
        self.__update_db_port(job_input, port_id3, msa_info)
Exemplo n.º 22
0
    def __get_msa_network_info(self, tenant_name, pod_id):

        # Get Endpoint(DB Client)
        db_endpoint_msa_vlan = self.get_db_endpoint(
            self.job_config.REST_URI_MSA_VLAN)

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)

        # List NAL_MSA_VLAN_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['pod_id'] = pod_id
        params['tenant_name'] = tenant_name
        db_list.set_context(db_endpoint_msa_vlan, params)
        db_list.execute()
        msa_network_info = db_list.get_return_param()

        return msa_network_info
Exemplo n.º 23
0
    def __assign_global_ip(self, tenant_name, operation_id):

        # Get Endpoint(DB Client)
        db_endpoint_global_ip = self.get_db_endpoint(
            self.job_config.REST_URI_GLOBAL_IP)

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)
        db_update = update.UpdateClient(self.job_config)

        # List NAL_GLOBAL_IP_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        db_list.set_context(db_endpoint_global_ip, params)
        db_list.execute()
        global_ip_list = db_list.get_return_param()

        global_ip = ''
        for rec in global_ip_list:
            if str(rec['status']) == '0':
                key_id = rec['ID']
                global_ip = rec['global_ip']

        if len(global_ip) == 0:
            for rec in global_ip_list:
                if str(rec['status']) == '103' or \
                        str(rec['status']) == '203':
                    key_id = rec['ID']
                    global_ip = rec['global_ip']

        if len(global_ip) == 0:
            raise SystemError('global ip not found.')

        # Update NAL_GLOBAL_IP_MNG(DB Client)
        keys = [key_id]
        params = {}
        params['status'] = 101
        params['tenant_name'] = tenant_name
        params['update_id'] = operation_id
        db_update.set_context(db_endpoint_global_ip, keys, params)
        db_update.execute()

        return global_ip
Exemplo n.º 24
0
    def __get_db_apl(self, job_input):

        node_id = job_input['node_id']

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

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)

        # List NAL_VNF_MNG(DB Client)
        params = {}
        params['delete_flg'] = 0
        params['node_id'] = node_id
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        apl_list = db_list.get_return_param()

        return apl_list[0]
Exemplo n.º 25
0
    def hostname_check(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
        host_name = job_input['host_name']
        nal_tenant_name = job_input['tenant_name']
        apl_table_rec_id = job_input['apl_table_rec_id']

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

        # List NAL_VNF_MNG(DB Client)
        db_list = list.ListClient(self.job_config)
        params = {}
        params['tenant_name'] = nal_tenant_name
        params['node_name'] = host_name
        params['delete_flg'] = 0
        db_list.set_context(db_endpoint_apl, params)
        db_list.execute()
        tenant_list = db_list.get_return_param()

        host_check_flg = 0
        for tenant_data in tenant_list:
            if tenant_data['ID'] != apl_table_rec_id:
                host_check_flg = 1
                break

        if host_check_flg == 1:
            raise SystemError('host_name duplicated:' + host_name)

        job_output = {}

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

        return job_output
Exemplo n.º 26
0
    def _get_dc_segment(self, dc_id, group_id):

        # Get Endpoint(DB Client)
        db_endpoint_dc_segment = self.get_db_endpoint(
                                self.job_config.REST_URI_WIM_DC_SEGMENT_MNG)

        # Create Instance(DB Client)
        db_list = list.ListClient(self.job_config)

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

        return dc_segment_list[0]
Exemplo n.º 27
0
    def __setup_tenant_vlan_add(self, job_input, pod_id, msa_device_id,
                                msa_config_for_common, msa_config_for_device):

        msa_info = {}

        # Get JOB Input Parameters
        nal_tenant_id = job_input['nal_tenant_id']
        port_id4 = job_input['port_id4']

        # List NAL_VNF_MNG(DB Client)
        db_endpoint = self.get_db_endpoint(self.job_config.REST_URI_PORT)
        db_list = list.ListClient(self.job_config)

        params = {}
        params['delete_flg'] = 0
        params['tenant_id'] = nal_tenant_id
        params['port_id'] = port_id4
        db_list.set_context(db_endpoint, params)
        db_list.execute()
        port_list = db_list.get_return_param()

        # Create Instance(MSA Soap Client)
        msa = intersecordercmdws.IntersecOrderCommandWs(
            self.job_config, self.nal_endpoint_config, pod_id)

        # Create Network(MSA)
        msa_res = self.execute_msa_command(
            msa_config_for_device, msa, 'create_intersec_sg_nw', msa_device_id,
            port_list[0]['nic'], port_list[0]['ip_address'],
            self.utils.get_subnet_mask_from_cidr_len(port_list[0]['netmask']))
        msa_info['create_intersec_sg_nw'] = msa_res[msa.RES_KEY_IN]

        # Reboot(MSA)
        msa_res = self.execute_msa_command(msa_config_for_device, msa,
                                           'create_intersec_sg_reboot',
                                           msa_device_id)
        # Wait(MSA)
        self.__wait_for_reboot(pod_id, msa_device_id, msa_config_for_device)

        # Update NAL_PORT_MNG(DB)
        self.__update_db_port(job_input, job_input['port_id4'], msa_info)
Exemplo n.º 28
0
    def __get_db_port(self, job_input, node_id):

        # Get Input Parameters
        tenant_name = job_input['tenant_name']

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

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

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

        return port_list
Exemplo n.º 29
0
    def tearDown(self):
        """Clear the test environment"""
        super(TestSetupDeviceBigIpApi, self).tearDown()

        # Create Instance(DB Client)
        db_delete = delete.DeleteClient(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)
        db_endpoint_port = base.JobAutoBase().get_db_endpoint(
            config.JobConfig().REST_URI_PORT)

        # Delete from NAL_APL_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']

        db_list.set_context(db_endpoint_apl, params)
        db_list.execute()
        delete_list = db_list.get_return_param()

        for delete_res in delete_list:
            key = delete_res['ID']
            db_delete.set_context(db_endpoint_apl, [key])
            db_delete.execute()

        # Delete from NAL_PORT_MNG
        params = {}
        params['create_id'] = JOB_INPUT['operation_id']

        db_list.set_context(db_endpoint_port, params)
        db_list.execute()
        delete_list = db_list.get_return_param()

        for delete_res in delete_list:
            key = delete_res['ID']
            db_delete.set_context(db_endpoint_port, [key])
            db_delete.execute()
Exemplo n.º 30
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']