Merge pull request #472 from mpath/toggle_sg_3
Tenant network sg toggle
This commit is contained in:
@@ -22,6 +22,7 @@ CONF = cfg.CONF
|
|||||||
class Capabilities(object):
|
class Capabilities(object):
|
||||||
SECURITY_GROUPS = "security_groups"
|
SECURITY_GROUPS = "security_groups"
|
||||||
EGRESS = "egress"
|
EGRESS = "egress"
|
||||||
|
TENANT_NETWORK_SG = "tenant_network_sg"
|
||||||
|
|
||||||
|
|
||||||
quark_opts = [
|
quark_opts = [
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ class SecurityGroupsNotImplemented(exceptions.InvalidInput):
|
|||||||
"create")
|
"create")
|
||||||
|
|
||||||
|
|
||||||
|
class TenantNetworkSecurityGroupRulesNotEnabled(exceptions.InvalidInput):
|
||||||
|
message = _("Tenant network security group rules are not currently "
|
||||||
|
"allowed by environment_capabilities configuration.")
|
||||||
|
|
||||||
|
|
||||||
class EgressSecurityGroupRulesNotEnabled(exceptions.InvalidInput):
|
class EgressSecurityGroupRulesNotEnabled(exceptions.InvalidInput):
|
||||||
message = _("Egress security group rules are not currently allowed "
|
message = _("Egress security group rules are not currently allowed "
|
||||||
"by environment_capabilities configuration.")
|
"by environment_capabilities configuration.")
|
||||||
|
|||||||
@@ -297,10 +297,11 @@ def update_port(context, id, port):
|
|||||||
fixed_ips_per_port=len(fixed_ips))
|
fixed_ips_per_port=len(fixed_ips))
|
||||||
|
|
||||||
new_security_groups = utils.pop_param(port_dict, "security_groups")
|
new_security_groups = utils.pop_param(port_dict, "security_groups")
|
||||||
if Capabilities.SECURITY_GROUPS not in CONF.QUARK.environment_capabilities:
|
|
||||||
if new_security_groups is not None:
|
if new_security_groups is not None:
|
||||||
|
if (Capabilities.TENANT_NETWORK_SG not in
|
||||||
|
CONF.QUARK.environment_capabilities):
|
||||||
if not STRATEGY.is_provider_network(port_db["network_id"]):
|
if not STRATEGY.is_provider_network(port_db["network_id"]):
|
||||||
raise q_exc.TenantNetworkSecurityGroupsNotImplemented()
|
raise q_exc.TenantNetworkSecurityGroupRulesNotEnabled()
|
||||||
|
|
||||||
if new_security_groups is not None and not port_db["device_id"]:
|
if new_security_groups is not None and not port_db["device_id"]:
|
||||||
raise q_exc.SecurityGroupsRequireDevice()
|
raise q_exc.SecurityGroupsRequireDevice()
|
||||||
|
|||||||
Reference in New Issue
Block a user