Example #1
0
    def _delete_nat(self, context, **kwargs):
        nwa_data = kwargs.get('nwa_data')
        floating = kwargs.get('floating')

        vlan_logical_name = data_utils.get_vlan_logical_name(
            nwa_data, floating['floating_network_id'])
        dev_name = data_utils.get_tfw_device_name(nwa_data,
                                                  floating['device_id'])

        # setting nat
        rcode, body = self.client.l3.delete_nat(
            kwargs.get('nwa_tenant_id'),
            vlan_logical_name,
            'PublicVLAN',
            floating['fixed_ip_address'],
            floating['floating_ip_address'],
            dev_name,
            data=floating)

        if rcode != 200 or body['status'] != 'SUCCEED':
            LOG.debug("DeleteNat Error: invalid responce."
                      " rcode=%d status=%s" % (rcode, body))
            raise nwa_exc.AgentProxyException(value=None)
        else:
            LOG.debug("DeleteNat SUCCEED")
            data_utils.strip_floatingip_data(nwa_data, floating)
            return nwa_data
Example #2
0
    def _update_tenant_fw_connect(self, context, **kwargs):
        nwa_data = kwargs.get('nwa_data')

        device_id = kwargs['nwa_info']['device']['id']
        network_id = kwargs['nwa_info']['network']['id']

        rcode, body = self.client.l3.update_tenant_fw(
            kwargs['nwa_tenant_id'],
            data_utils.get_tfw_device_name(nwa_data, device_id),
            kwargs['nwa_info']['port']['ip'],
            data_utils.get_vlan_logical_name(nwa_data, network_id),
            kwargs['nwa_info']['network']['vlan_type'],
            connect='connect')

        if rcode != 200 or body['status'] != 'SUCCEED':
            raise nwa_exc.AgentProxyException(value=None)

        LOG.debug("UpdateTenantFW succeed.")
        resource_group_name_nw = kwargs['nwa_info']['resource_group_name_nw']
        tfw_name = body['resultdata']['TenantFWName']

        data_utils.set_tfw_interface_data(nwa_data, device_id, network_id,
                                          resource_group_name_nw, tfw_name,
                                          kwargs['nwa_info'])
        vlan_id = data_utils.get_vlan_id(network_id, nwa_data,
                                         body['resultdata'])
        data_utils.set_vp_net_data(nwa_data, network_id,
                                   resource_group_name_nw,
                                   nwa_const.NWA_DEVICE_TFW, vlan_id)

        if self.tenant_fw_connect_hook:
            self.tenant_fw_connect_hook(context, tfw_name, **kwargs)
        return nwa_data
Example #3
0
    def _setting_nat(self, context, **kwargs):
        nwa_tenant_id = kwargs.get('nwa_tenant_id')
        nwa_data = kwargs.get('nwa_data')
        floating = kwargs.get('floating')

        # new code.(neet ut)
        nat_key = 'NAT_' + floating['id']
        if nat_key in nwa_data:
            LOG.debug('already in use NAT key =%s', nat_key)
            raise nwa_exc.AgentProxyException(value=None)

        vlan_logical_name = data_utils.get_vlan_logical_name(
            nwa_data, floating['floating_network_id'])
        dev_name = data_utils.get_tfw_device_name(nwa_data,
                                                  floating['device_id'])

        # setting nat
        rcode, body = self.client.l3.setting_nat(
            nwa_tenant_id,
            vlan_logical_name,
            'PublicVLAN',
            floating['fixed_ip_address'],
            floating['floating_ip_address'],
            dev_name,
            data=floating)

        if rcode != 200 or body['status'] != 'SUCCEED':
            LOG.debug("SettingNat Error: invalid responce."
                      " rcode=%d status=%s" % (rcode, body))
            raise nwa_exc.AgentProxyException(value=None)
        else:
            LOG.debug("SettingNat SUCCEED")
            data_utils.set_floatingip_data(nwa_data, floating)
            return nwa_data
Example #4
0
    def _setting_nat(self, context, **kwargs):
        nwa_tenant_id = kwargs.get('nwa_tenant_id')
        nwa_data = kwargs.get('nwa_data')
        floating = kwargs.get('floating')

        # new code.(neet ut)
        nat_key = 'NAT_' + floating['id']
        if nat_key in nwa_data:
            LOG.debug('already in use NAT key =%s', nat_key)
            raise nwa_exc.AgentProxyException(value=None)

        vlan_logical_name = data_utils.get_vlan_logical_name(
            nwa_data, floating['floating_network_id'])
        dev_name = data_utils.get_tfw_device_name(nwa_data,
                                                  floating['device_id'])

        # setting nat
        rcode, body = self.client.l3.setting_nat(
            nwa_tenant_id,
            vlan_logical_name, 'PublicVLAN',
            floating['fixed_ip_address'],
            floating['floating_ip_address'], dev_name, data=floating
        )

        if rcode != 200 or body['status'] != 'SUCCEED':
            LOG.debug("SettingNat Error: invalid responce."
                      " rcode=%d status=%s" % (rcode, body))
            raise nwa_exc.AgentProxyException(value=None)
        else:
            LOG.debug("SettingNat SUCCEED")
            data_utils.set_floatingip_data(nwa_data, floating)
            return nwa_data
Example #5
0
    def _update_tenant_fw_connect(self, context, **kwargs):
        nwa_data = kwargs.get('nwa_data')

        device_id = kwargs['nwa_info']['device']['id']
        network_id = kwargs['nwa_info']['network']['id']

        rcode, body = self.client.l3.update_tenant_fw(
            kwargs['nwa_tenant_id'],
            data_utils.get_tfw_device_name(nwa_data, device_id),
            kwargs['nwa_info']['port']['ip'],
            data_utils.get_vlan_logical_name(nwa_data, network_id),
            kwargs['nwa_info']['network']['vlan_type'],
            connect='connect')

        if rcode != 200 or body['status'] != 'SUCCEED':
            raise nwa_exc.AgentProxyException(value=None)

        LOG.debug("UpdateTenantFW succeed.")
        resource_group_name_nw = kwargs['nwa_info']['resource_group_name_nw']
        tfw_name = body['resultdata']['TenantFWName']

        data_utils.set_tfw_interface_data(nwa_data, device_id, network_id,
                                          resource_group_name_nw,
                                          tfw_name, kwargs['nwa_info'])
        vlan_id = data_utils.get_vlan_id(network_id, nwa_data,
                                         body['resultdata'])
        data_utils.set_vp_net_data(nwa_data, network_id,
                                   resource_group_name_nw,
                                   nwa_const.NWA_DEVICE_TFW,
                                   vlan_id)

        if self.tenant_fw_connect_hook:
            self.tenant_fw_connect_hook(context, tfw_name, **kwargs)
        return nwa_data
    def _update_tenant_fw_disconnect(self, context, **kwargs):
        """Update Tenant FW

        @param context: contains user information.
        @param kwargs:
        @return: nwa_data
        @raise AgentProxyException
        """
        if self.multi_dc:
            self.proxy_l2.delete_connect_port(context, **kwargs)
        nwa_data = kwargs.get('nwa_data')
        device_id = kwargs['nwa_info']['device']['id']
        network_id = kwargs['nwa_info']['network']['id']
        device_name = data_utils.get_tfw_device_name(nwa_data, device_id)

        if self.tenant_fw_disconnect_hook:
            self.tenant_fw_disconnect_hook(context, device_name, **kwargs)

        rcode, body = self.client.l3.update_tenant_fw(
            kwargs['nwa_tenant_id'],
            device_name,
            kwargs['nwa_info']['port']['ip'],
            data_utils.get_vlan_logical_name(nwa_data, network_id),
            kwargs['nwa_info']['network']['vlan_type'],
            connect='disconnect')
        if rcode != 200 or body['status'] != 'SUCCEED':
            LOG.error(_LE("UpdateTenantFW(disconnect) FAILED."))
            info = {
                'status': 'FAILED',
                'msg': 'UpdateTenantFW(disconnect) FAILED.'
            }
            raise nwa_exc.AgentProxyException(value=info)

        LOG.debug("UpdateTenantFW(disconnect) SUCCEED.")
        resource_group_name_nw = kwargs['nwa_info']['resource_group_name_nw']

        data_utils.strip_interface_data(nwa_data, device_id, network_id,
                                        resource_group_name_nw)
        data_utils.strip_tfw_data_if_exist(nwa_data, device_id, network_id,
                                           resource_group_name_nw)

        if not l2.check_segment_tfw(network_id, resource_group_name_nw,
                                    nwa_data):
            data_utils.strip_vp_net_data(nwa_data, network_id,
                                         resource_group_name_nw,
                                         nwa_const.NWA_DEVICE_TFW)
        return nwa_data
    def _update_tenant_fw_disconnect(self, context, **kwargs):
        """Update Tenant FW

        @param context: contains user information.
        @param kwargs:
        @return: nwa_data
        @raise AgentProxyException
        """
        if self.multi_dc:
            self.proxy_l2.delete_connect_port(context, **kwargs)
        nwa_data = kwargs.get('nwa_data')
        device_id = kwargs['nwa_info']['device']['id']
        network_id = kwargs['nwa_info']['network']['id']
        device_name = data_utils.get_tfw_device_name(nwa_data, device_id)

        if self.tenant_fw_disconnect_hook:
            self.tenant_fw_disconnect_hook(context, device_name, **kwargs)

        rcode, body = self.client.l3.update_tenant_fw(
            kwargs['nwa_tenant_id'],
            device_name,
            kwargs['nwa_info']['port']['ip'],
            data_utils.get_vlan_logical_name(nwa_data, network_id),
            kwargs['nwa_info']['network']['vlan_type'],
            connect='disconnect'
        )
        if rcode != 200 or body['status'] != 'SUCCEED':
            LOG.error(_LE("UpdateTenantFW(disconnect) FAILED."))
            info = {'status': 'FAILED',
                    'msg': 'UpdateTenantFW(disconnect) FAILED.'}
            raise nwa_exc.AgentProxyException(value=info)

        LOG.debug("UpdateTenantFW(disconnect) SUCCEED.")
        resource_group_name_nw = kwargs['nwa_info']['resource_group_name_nw']

        data_utils.strip_interface_data(nwa_data, device_id, network_id,
                                        resource_group_name_nw)
        data_utils.strip_tfw_data_if_exist(nwa_data, device_id, network_id,
                                           resource_group_name_nw)

        if not l2.check_segment_tfw(network_id, resource_group_name_nw,
                                    nwa_data):
            data_utils.strip_vp_net_data(nwa_data, network_id,
                                         resource_group_name_nw,
                                         nwa_const.NWA_DEVICE_TFW)
        return nwa_data
    def _delete_tenant_fw(self, context, **kwargs):
        """Delete Tenant FW

        @param context: contains user information.
        @param kwargs: nwa_tenant_id, nwa_tenant_id, nwa_info, nwa_data
        @return: resutl(succeed = True, other = False), data(nwa_data or None)
        """
        if self.multi_dc:
            self.proxy_l2.delete_connect_port(context, **kwargs)
        nwa_data = kwargs.get('nwa_data')
        nwa_info = kwargs['nwa_info']

        network_id = nwa_info['network']['id']
        device_id = nwa_info['device']['id']

        device_name = data_utils.get_tfw_device_name(nwa_data, device_id)
        if self.tenant_fw_delete_hook:
            self.tenant_fw_delete_hook(context, device_name, **kwargs)

        rcode, body = self.client.l3.delete_tenant_fw(
            kwargs['nwa_tenant_id'],
            device_name,
            'TFW'
        )
        if rcode != 200 or body['status'] != 'SUCCEED':
            msg = _LE("DeleteTenantFW %s."), body['status']
            LOG.error(msg)
            raise nwa_exc.AgentProxyException(value=nwa_data)

        LOG.debug("DeleteTenantFW SUCCEED.")

        resource_group_name_nw = nwa_info['resource_group_name_nw']
        # delete recode
        data_utils.strip_device_data(nwa_data, device_id)
        data_utils.strip_interface_data(nwa_data, device_id, network_id,
                                        resource_group_name_nw)
        data_utils.strip_tfw_data_if_exist(nwa_data, device_id, network_id,
                                           resource_group_name_nw)

        if not l2.check_segment_tfw(network_id, resource_group_name_nw,
                                    nwa_data):
            data_utils.strip_vp_net_data(nwa_data, network_id,
                                         resource_group_name_nw,
                                         nwa_const.NWA_DEVICE_TFW)
        return nwa_data
    def _delete_tenant_fw(self, context, **kwargs):
        """Delete Tenant FW

        @param context: contains user information.
        @param kwargs: nwa_tenant_id, nwa_tenant_id, nwa_info, nwa_data
        @return: resutl(succeed = True, other = False), data(nwa_data or None)
        """
        if self.multi_dc:
            self.proxy_l2.delete_connect_port(context, **kwargs)
        nwa_data = kwargs.get('nwa_data')
        nwa_info = kwargs['nwa_info']

        network_id = nwa_info['network']['id']
        device_id = nwa_info['device']['id']

        device_name = data_utils.get_tfw_device_name(nwa_data, device_id)
        if self.tenant_fw_delete_hook:
            self.tenant_fw_delete_hook(context, device_name, **kwargs)

        rcode, body = self.client.l3.delete_tenant_fw(kwargs['nwa_tenant_id'],
                                                      device_name, 'TFW')
        if rcode != 200 or body['status'] != 'SUCCEED':
            msg = _LE("DeleteTenantFW %s."), body['status']
            LOG.error(msg)
            raise nwa_exc.AgentProxyException(value=nwa_data)

        LOG.debug("DeleteTenantFW SUCCEED.")

        resource_group_name_nw = nwa_info['resource_group_name_nw']
        # delete recode
        data_utils.strip_device_data(nwa_data, device_id)
        data_utils.strip_interface_data(nwa_data, device_id, network_id,
                                        resource_group_name_nw)
        data_utils.strip_tfw_data_if_exist(nwa_data, device_id, network_id,
                                           resource_group_name_nw)

        if not l2.check_segment_tfw(network_id, resource_group_name_nw,
                                    nwa_data):
            data_utils.strip_vp_net_data(nwa_data, network_id,
                                         resource_group_name_nw,
                                         nwa_const.NWA_DEVICE_TFW)
        return nwa_data
Example #10
0
    def _delete_nat(self, context, **kwargs):
        nwa_data = kwargs.get('nwa_data')
        floating = kwargs.get('floating')

        vlan_logical_name = data_utils.get_vlan_logical_name(
            nwa_data, floating['floating_network_id'])
        dev_name = data_utils.get_tfw_device_name(nwa_data,
                                                  floating['device_id'])

        # setting nat
        rcode, body = self.client.l3.delete_nat(
            kwargs.get('nwa_tenant_id'),
            vlan_logical_name, 'PublicVLAN',
            floating['fixed_ip_address'],
            floating['floating_ip_address'], dev_name, data=floating)

        if rcode != 200 or body['status'] != 'SUCCEED':
            LOG.debug("DeleteNat Error: invalid responce."
                      " rcode=%d status=%s" % (rcode, body))
            raise nwa_exc.AgentProxyException(value=None)
        else:
            LOG.debug("DeleteNat SUCCEED")
            data_utils.strip_floatingip_data(nwa_data, floating)
            return nwa_data