def _check_ikepolicy_ipsecpolicy_allowed(self, ikepolicy, ipsecpolicy):
        """Check whether ikepolicy and ipsecpolicy are allowed on vshield edge.

        Some IPsec VPN configurations and features are configured by default or
        not supported on vshield edge.

        """
        # Check validation of IKEPolicy.
        if ikepolicy['ike_version'] != 'v1':
            msg = _("Unsupported ike_version: %s! Only 'v1' ike version is "
                    "supported on vshield Edge!") % ikepolicy['ike_version']
            LOG.warning(msg)
            raise vcns_exc.VcnsBadRequest(resource='ikepolicy', msg=msg)

        # In VSE, Phase 1 and Phase 2 share the same encryption_algorithm
        # and authentication algorithms setting. At present, just record the
        # discrepancy error in log and take ipsecpolicy to do configuration.
        if (ikepolicy['auth_algorithm'] != ipsecpolicy['auth_algorithm']
                or ikepolicy['encryption_algorithm'] !=
                ipsecpolicy['encryption_algorithm']
                or ikepolicy['pfs'] != ipsecpolicy['pfs']):
            LOG.warning(
                _LW("IKEPolicy and IPsecPolicy should have consistent "
                    "auth_algorithm, encryption_algorithm and pfs for VSE!"))

        # Check whether encryption_algorithm is allowed.
        encryption_algorithm = ENCRYPTION_ALGORITHM_MAP.get(
            ipsecpolicy.get('encryption_algorithm'), None)
        if not encryption_algorithm:
            msg = _("Unsupported encryption_algorithm: %s! '3des', "
                    "'aes-128' and 'aes-256' are supported on VSE right now."
                    ) % ipsecpolicy['encryption_algorithm']
            LOG.warning(msg)
            raise vcns_exc.VcnsBadRequest(resource='ipsecpolicy', msg=msg)

        # Check whether pfs is allowed.
        if not PFS_MAP.get(ipsecpolicy['pfs']):
            msg = _("Unsupported pfs: %s! 'group2' and 'group5' "
                    "are supported on VSE right now.") % ipsecpolicy['pfs']
            LOG.warning(msg)
            raise vcns_exc.VcnsBadRequest(resource='ipsecpolicy', msg=msg)

        # Check whether transform protocol is allowed.
        if ipsecpolicy['transform_protocol'] not in TRANSFORM_PROTOCOL_ALLOWED:
            msg = _("Unsupported transform protocol: %s! 'esp' is supported "
                    "by default on VSE right now."
                    ) % ipsecpolicy['transform_protocol']
            LOG.warning(msg)
            raise vcns_exc.VcnsBadRequest(resource='ipsecpolicy', msg=msg)

        # Check whether encapsulation mode is allowed.
        if ipsecpolicy['encapsulation_mode'] not in ENCAPSULATION_MODE_ALLOWED:
            msg = _("Unsupported encapsulation mode: %s! 'tunnel' is "
                    "supported by default on VSE right now."
                    ) % ipsecpolicy['encapsulation_mode']
            LOG.warning(msg)
            raise vcns_exc.VcnsBadRequest(resource='ipsecpolicy', msg=msg)
Beispiel #2
0
 def _convert_firewall_action(self, action):
     if action == FWAAS_ALLOW:
         return VSE_FWAAS_ALLOW
     elif action == FWAAS_DENY:
         return VSE_FWAAS_DENY
     else:
         msg = _("Invalid action value %s in a firewall rule") % action
         raise vcns_exc.VcnsBadRequest(resource='firewall_rule', msg=msg)
Beispiel #3
0
 def _restore_firewall_action(self, action):
     if action == VSE_FWAAS_ALLOW:
         return FWAAS_ALLOW
     elif action == VSE_FWAAS_DENY:
         return FWAAS_DENY
     else:
         msg = (_("Invalid action value %s in "
                  "a vshield firewall rule") % action)
         raise vcns_exc.VcnsBadRequest(resource='firewall_rule', msg=msg)
Beispiel #4
0
 def insert_rule(self, context, rule_info, edge_id, fwr):
     if rule_info.get('insert_before'):
         self._add_rule_above(context, rule_info['insert_before'], edge_id,
                              fwr)
     elif rule_info.get('insert_after'):
         self._add_rule_below(context, rule_info['insert_after'], edge_id,
                              fwr)
     else:
         msg = _("Can't execute insert rule operation "
                 "without reference rule_id")
         raise vcns_exc.VcnsBadRequest(resource='firewall_rule', msg=msg)