コード例 #1
0
 def update_vpnservice(self, context, old_vpnservice, vpnservice):
     # Only handle the case of admin-state-up changes
     if old_vpnservice['admin_state_up'] != vpnservice['admin_state_up']:
         # update all relevant connections
         filters = {'vpnservice_id': [vpnservice['id']]}
         connections = self.vpn_plugin.get_ipsec_site_connections(
             context, filters=filters)
         for conn in connections:
             mapping = db.get_nsx_vpn_connection_mapping(
                 context.session, conn['id'])
             if mapping:
                 connection_enabled = (vpnservice['admin_state_up'] and
                                       conn['admin_state_up'])
                 self._update_session(mapping['session_id'], conn,
                                      enabled=connection_enabled)
コード例 #2
0
    def get_ipsec_site_connection_status(self, context, ipsec_site_conn_id):
        mapping = db.get_nsx_vpn_connection_mapping(
            context.session, ipsec_site_conn_id)
        if not mapping or not mapping['session_id']:
            LOG.info("Couldn't find NSX session for VPN connection %s",
                     ipsec_site_conn_id)
            return

        status_result = self._nsx_vpn.session.get_status(mapping['session_id'])
        if status_result and 'session_status' in status_result:
            status = status_result['session_status']
            # NSX statuses are UP, DOWN, DEGRADE
            # VPNaaS connection status should be ACTIVE or DOWN
            if status == 'UP':
                return 'ACTIVE'
            elif status == 'DOWN' or status == 'DEGRADED':
                return 'DOWN'
コード例 #3
0
    def update_ipsec_site_connection(self, context, old_ipsec_conn,
                                     ipsec_site_conn):
        LOG.debug('Updating ipsec site connection new %(site)s.',
                  {"site": ipsec_site_conn})
        LOG.debug('Updating ipsec site connection old %(site)s.',
                  {"site": old_ipsec_conn})

        # Note(asarfaty) the plugin already calls the validator
        # which also validated the policies and service

        ipsec_id = old_ipsec_conn['id']
        vpnservice_id = old_ipsec_conn['vpnservice_id']
        vpnservice = self.service_plugin._get_vpnservice(
            context, vpnservice_id)
        mapping = db.get_nsx_vpn_connection_mapping(context.session,
                                                    ipsec_site_conn['id'])
        if not mapping:
            LOG.error("Couldn't find nsx ids for VPN connection %s",
                      ipsec_site_conn['id'])
            self._update_status(context, vpnservice_id, ipsec_id, "ERROR")
            raise nsx_exc.NsxIPsecVpnMappingNotFound(conn=ipsec_id)

        # check if the dpd configuration changed
        old_dpd = old_ipsec_conn['dpd']
        new_dpd = ipsec_site_conn['dpd']
        if (old_dpd['action'] != new_dpd['action']
                or old_dpd['timeout'] != new_dpd['timeout']
                or old_ipsec_conn['name'] != ipsec_site_conn['name']):
            self._update_dpd_profile(ipsec_site_conn,
                                     mapping['dpd_profile_id'])

        # update peer endpoint with all the parameters that could be modified
        # Note(asarfaty): local endpoints are reusable and will not be updated
        self._update_peer_endpoint(mapping['peer_ep_id'], ipsec_site_conn)
        rules = self._get_session_rules(context, ipsec_site_conn, vpnservice)
        connection_enabled = (vpnservice['admin_state_up']
                              and ipsec_site_conn['admin_state_up'])
        self._update_session(mapping['session_id'],
                             ipsec_site_conn,
                             rules,
                             enabled=connection_enabled)

        if ipsec_site_conn['peer_cidrs'] != old_ipsec_conn['peer_cidrs']:
            # Update firewall
            self._update_firewall_rules(context, vpnservice)
コード例 #4
0
ファイル: ipsec_driver.py プロジェクト: openstack/vmware-nsx
    def update_ipsec_site_connection(self, context, old_ipsec_conn,
                                     ipsec_site_conn):
        LOG.debug('Updating ipsec site connection new %(site)s.',
                  {"site": ipsec_site_conn})
        LOG.debug('Updating ipsec site connection old %(site)s.',
                  {"site": old_ipsec_conn})

        # Note(asarfaty) the plugin already calls the validator
        # which also validated the policies and service

        ipsec_id = old_ipsec_conn['id']
        vpnservice_id = old_ipsec_conn['vpnservice_id']
        vpnservice = self.service_plugin._get_vpnservice(
            context, vpnservice_id)
        mapping = db.get_nsx_vpn_connection_mapping(
            context.session, ipsec_site_conn['id'])
        if not mapping:
            LOG.error("Couldn't find nsx ids for VPN connection %s",
                      ipsec_site_conn['id'])
            self._update_status(context, vpnservice_id, ipsec_id, "ERROR")
            raise nsx_exc.NsxIPsecVpnMappingNotFound(conn=ipsec_id)

        # check if the dpd configuration changed
        old_dpd = old_ipsec_conn['dpd']
        new_dpd = ipsec_site_conn['dpd']
        if (old_dpd['action'] != new_dpd['action'] or
            old_dpd['timeout'] != new_dpd['timeout'] or
            old_ipsec_conn['name'] != ipsec_site_conn['name']):
            self._update_dpd_profile(ipsec_site_conn,
                                     mapping['dpd_profile_id'])

        # update peer endpoint with all the parameters that could be modified
        # Note(asarfaty): local endpoints are reusable and will not be updated
        self._update_peer_endpoint(mapping['peer_ep_id'], ipsec_site_conn)
        rules = self._get_session_rules(
            context, ipsec_site_conn, vpnservice)
        connection_enabled = (vpnservice['admin_state_up'] and
                              ipsec_site_conn['admin_state_up'])
        self._update_session(mapping['session_id'], ipsec_site_conn, rules,
                             enabled=connection_enabled)

        if ipsec_site_conn['peer_cidrs'] != old_ipsec_conn['peer_cidrs']:
            # Update firewall
            self._update_firewall_rules(context, vpnservice)
コード例 #5
0
    def delete_ipsec_site_connection(self, context, ipsec_site_conn):
        LOG.debug('Deleting ipsec site connection %(site)s.',
                  {"site": ipsec_site_conn})

        vpnservice_id = ipsec_site_conn['vpnservice_id']
        vpnservice = self.service_plugin._get_vpnservice(
            context, vpnservice_id)

        # get all data from the nsx based on the connection id in the DB
        mapping = db.get_nsx_vpn_connection_mapping(context.session,
                                                    ipsec_site_conn['id'])
        if not mapping:
            LOG.warning("Couldn't find nsx ids for VPN connection %s",
                        ipsec_site_conn['id'])
            # Do not fail the deletion
            return

        if mapping['session_id']:
            self._delete_session(mapping['session_id'])
        if mapping['peer_ep_id']:
            self._delete_peer_endpoint(mapping['peer_ep_id'])
        if mapping['dpd_profile_id']:
            self._delete_dpd_profile(mapping['dpd_profile_id'])
        if mapping['ipsec_profile_id']:
            self._delete_ipsec_profile(mapping['ipsec_profile_id'])
        if mapping['ike_profile_id']:
            self._delete_ike_profile(mapping['ike_profile_id'])

        # Do not delete the local endpoint and service as they are reused
        db.delete_nsx_vpn_connection_mapping(context.session,
                                             ipsec_site_conn['id'])
        # update router firewall rules
        self._update_firewall_rules(context, vpnservice)

        # update router advertisement rules
        self._update_router_advertisement(context, vpnservice)
コード例 #6
0
ファイル: ipsec_driver.py プロジェクト: openstack/vmware-nsx
    def delete_ipsec_site_connection(self, context, ipsec_site_conn):
        LOG.debug('Deleting ipsec site connection %(site)s.',
                  {"site": ipsec_site_conn})

        vpnservice_id = ipsec_site_conn['vpnservice_id']
        vpnservice = self.service_plugin._get_vpnservice(
            context, vpnservice_id)

        # get all data from the nsx based on the connection id in the DB
        mapping = db.get_nsx_vpn_connection_mapping(
            context.session, ipsec_site_conn['id'])
        if not mapping:
            LOG.warning("Couldn't find nsx ids for VPN connection %s",
                      ipsec_site_conn['id'])
            # Do not fail the deletion
            return

        if mapping['session_id']:
            self._delete_session(mapping['session_id'])
        if mapping['peer_ep_id']:
            self._delete_peer_endpoint(mapping['peer_ep_id'])
        if mapping['dpd_profile_id']:
            self._delete_dpd_profile(mapping['dpd_profile_id'])
        if mapping['ipsec_profile_id']:
            self._delete_ipsec_profile(mapping['ipsec_profile_id'])
        if mapping['ike_profile_id']:
            self._delete_ike_profile(mapping['ike_profile_id'])

        # Do not delete the local endpoint and service as they are reused
        db.delete_nsx_vpn_connection_mapping(context.session,
                                             ipsec_site_conn['id'])
        # update router firewall rules
        self._update_firewall_rules(context, vpnservice)

        # update router advertisement rules
        self._update_router_advertisement(context, vpnservice)