コード例 #1
0
    def update(self):
        """Update Status based on vpnservice configuration."""

        # Disable the process if a vpnservice is disabled or it has no
        # enabled IPSec site connections.
        vpnservice_has_active_ipsec_site_conns = any(
            [ipsec_site_conn['admin_state_up']
             for ipsec_site_conn in self.vpnservice['ipsec_site_connections']])
        if (not self.vpnservice['admin_state_up'] or
                not vpnservice_has_active_ipsec_site_conns):
            self.disable()
        else:
            self.enable()

        if plugin_utils.in_pending_status(self.vpnservice['status']):
            self.updated_pending_status = True

        self.vpnservice['status'] = self.status
        for ipsec_site_conn in self.vpnservice['ipsec_site_connections']:
            if plugin_utils.in_pending_status(ipsec_site_conn['status']):
                conn_id = ipsec_site_conn['id']
                conn_status = self.connection_status.get(conn_id)
                if not conn_status:
                    continue
                conn_status['updated_pending_status'] = True
                ipsec_site_conn['status'] = conn_status['status']
コード例 #2
0
ファイル: ipsec.py プロジェクト: openstack/neutron-vpnaas
    def update(self):
        """Update Status based on vpnservice configuration."""

        # Disable the process if a vpnservice is disabled or it has no
        # enabled IPSec site connections.
        vpnservice_has_active_ipsec_site_conns = any(
            [ipsec_site_conn['admin_state_up']
             for ipsec_site_conn in self.vpnservice['ipsec_site_connections']])
        if (not self.vpnservice['admin_state_up'] or
                not vpnservice_has_active_ipsec_site_conns):
            self.disable()
        else:
            self.enable()

        if plugin_utils.in_pending_status(self.vpnservice['status']):
            self.updated_pending_status = True

        self.vpnservice['status'] = self.status
        for ipsec_site_conn in self.vpnservice['ipsec_site_connections']:
            if plugin_utils.in_pending_status(ipsec_site_conn['status']):
                conn_id = ipsec_site_conn['id']
                conn_status = self.connection_status.get(conn_id)
                if not conn_status:
                    continue
                conn_status['updated_pending_status'] = True
                ipsec_site_conn['status'] = conn_status['status']
コード例 #3
0
    def build_report_for_service(self, vpn_service):
        """Create the report info for a VPN service and its IPSec connections.

        Get the report info for the connections on the service, and include
        it into the report info for the VPN service. If there is no report
        info for the connection, then no change has occurred and no report
        will be generated. If there is only one connection for the service,
        we'll set the service state to match the connection (with ERROR seen
        as DOWN).
        """
        conn_report = self.build_report_for_connections_on(vpn_service)
        if conn_report or vpn_service.connections_removed:
            pending_handled = plugin_utils.in_pending_status(
                vpn_service.last_status)
            vpn_service.update_last_status()
            LOG.debug("Report: Adding info for VPN service %s",
                      vpn_service.service_id)
            return {
                u'id': vpn_service.service_id,
                u'status': vpn_service.last_status,
                u'updated_pending_status': pending_handled,
                u'ipsec_site_connections': conn_report
            }
        else:
            return {}
コード例 #4
0
 def update_status_and_build_report(self, current_status):
     if current_status != self.last_status:
         pending_handled = plugin_utils.in_pending_status(self.last_status)
         self.last_status = current_status
         return {
             self.conn_id: {
                 'status': current_status,
                 'updated_pending_status': pending_handled
             }
         }
     else:
         return {}
コード例 #5
0
ファイル: vpn_db.py プロジェクト: hellochosen/neutron-vpnaas
    def _update_connection_status(self, context, conn_id, new_status,
                                  updated_pending):
        """Update the connection status, if changed.

        If the connection is not in a pending state, unconditionally update
        the status. Likewise, if in a pending state, and have an indication
        that the status has changed, then update the database.
        """
        try:
            conn_db = self._get_ipsec_site_connection(context, conn_id)
        except vpnaas.IPsecSiteConnectionNotFound:
            return
        if not utils.in_pending_status(conn_db.status) or updated_pending:
            conn_db.status = new_status
コード例 #6
0
ファイル: vpn_db.py プロジェクト: hellochosen/neutron-vpnaas
    def update_status_by_agent(self, context, service_status_info_list):
        """Updating vpnservice and vpnconnection status.

        :param context: context variable
        :param service_status_info_list: list of status
        The structure is
        [{id: vpnservice_id,
          status: ACTIVE|DOWN|ERROR,
          updated_pending_status: True|False
          ipsec_site_connections: {
              ipsec_site_connection_id: {
                  status: ACTIVE|DOWN|ERROR,
                  updated_pending_status: True|False
              }
          }]
        The agent will set updated_pending_status as True,
        when agent updates any pending status.
        """
        with context.session.begin(subtransactions=True):
            for vpnservice in service_status_info_list:
                try:
                    vpnservice_db = self._get_vpnservice(
                        context, vpnservice['id'])
                except vpnaas.VPNServiceNotFound:
                    LOG.warning('vpnservice %s in db is already deleted',
                                vpnservice['id'])
                    continue

                if (not utils.in_pending_status(vpnservice_db.status)
                        or vpnservice['updated_pending_status']):
                    vpnservice_db.status = vpnservice['status']
                for conn_id, conn in vpnservice[
                        'ipsec_site_connections'].items():
                    self._update_connection_status(
                        context, conn_id, conn['status'],
                        conn['updated_pending_status'])
コード例 #7
0
ファイル: vpn_db.py プロジェクト: hellochosen/neutron-vpnaas
 def assert_update_allowed(self, obj):
     status = getattr(obj, 'status', None)
     _id = getattr(obj, 'id', None)
     if utils.in_pending_status(status):
         raise vpnaas.VPNStateInvalidToUpdate(id=_id, state=status)