Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions fmcapi/api_objects/policy_services/accessrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def source_port(self, action, name="", literal=None, protocol="TCP"):
:return: None
"""
logging.debug("In source_port() for AccessRules class.")
if literal and name != "":
if literal is not None and name != "":
raise ValueError(
"Only one of literal or name (object name) should be set while creating a source port"
)
Expand All @@ -591,7 +591,7 @@ def source_port(self, action, name="", literal=None, protocol="TCP"):
self.sourcePorts = {"objects": [], "literals": []}

if action == "add":
if literal:
if literal is not None:
port_literal = validate_port_literal(literal, protocol)
if port_literal not in self.sourcePorts["literals"]:
self.sourcePorts["literals"].append(port_literal)
Expand Down Expand Up @@ -668,7 +668,7 @@ def source_port(self, action, name="", literal=None, protocol="TCP"):
)
elif action == "remove":
if "sourcePorts" in self.__dict__:
if literal:
if literal is not None:
try:
port_literal = validate_port_literal(literal, protocol)
if port_literal in self.sourcePorts["literals"]:
Expand Down Expand Up @@ -728,7 +728,7 @@ def destination_port(self, action, name="", literal=None, protocol="TCP"):
:return: None
"""
logging.debug("In destination_port() for AccessRules class.")
if literal and name != "":
if literal is not None and name != "":
raise ValueError(
"Only one of literal or name (object name) should be set while creating a destination port"
)
Expand All @@ -737,7 +737,7 @@ def destination_port(self, action, name="", literal=None, protocol="TCP"):
self.destinationPorts = {"objects": [], "literals": []}

if action == "add":
if literal:
if literal is not None:
port_literal = validate_port_literal(literal, protocol)
if port_literal not in self.destinationPorts["literals"]:
self.destinationPorts["literals"].append(port_literal)
Expand Down Expand Up @@ -814,7 +814,7 @@ def destination_port(self, action, name="", literal=None, protocol="TCP"):
)
elif action == "remove":
if "destinationPorts" in self.__dict__:
if literal:
if literal is not None:
try:
port_literal = validate_port_literal(literal, protocol)
if port_literal in self.destinationPorts["literals"]:
Expand Down Expand Up @@ -876,7 +876,7 @@ def source_network(self, action, name="", literal=None):
"""
# using dict() as default value is dangerous here, any thoughts/workarounds on this?
logging.debug("In source_network() for AccessRules class.")
if literal and name != "":
if literal is not None and name != "":
raise ValueError(
"Only one of literals or name (object name) should be set while creating a source network"
)
Expand All @@ -885,7 +885,7 @@ def source_network(self, action, name="", literal=None):
self.sourceNetworks = {"objects": [], "literals": {}}

if action == "add":
if literal:
if literal is not None:
type_ = get_networkaddress_type(literal)
self.sourceNetworks["literals"][literal] = type_
logging.info(
Expand Down Expand Up @@ -1005,7 +1005,7 @@ def destination_network(self, action, name="", literal=None):
# using dict() as default value is dangerous here, any thoughts/workarounds on this?

logging.debug("In destination_network() for ACPRule class.")
if literal and name != "":
if literal is not None and name != "":
raise ValueError(
"Only one of literals or name (object name) should be set while creating a source network"
)
Expand All @@ -1014,7 +1014,7 @@ def destination_network(self, action, name="", literal=None):
self.destinationNetworks = {"objects": [], "literals": {}}

if action == "add":
if literal:
if literal is not None:
type_ = get_networkaddress_type(literal)
self.destinationNetworks["literals"][literal] = type_
logging.info(
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def source_sgt(self, action, name="", literal=None):
# using dict() as default value is dangerous here, any thoughts/workarounds on this?

logging.debug("In source_sgt() for ACPRule class.")
if literal and name != "":
if literal is not None and name != "":
raise ValueError(
"Only one of literals or name (object name) should be set while creating a source sgt"
)
Expand All @@ -1146,7 +1146,7 @@ def source_sgt(self, action, name="", literal=None):
self.sourceSecurityGroupTags = {"objects": [], "literals": {}}

if action == "add":
if literal:
if literal is not None:
type_ = "ISESecurityGroupTag"
self.sourceSecurityGroupTags["literals"][literal] = type_
logging.info(
Expand Down