Remove fake methods code from compute network
Network objects don't have any method needs to fake. keys() method is only used by _get_columns() helper to obtain all attributes of an object. But in compute network implementation, attributes are obtained from obj._info directly, which is a dictionary itself. So there is no need to fake this method. Change-Id: Ie6a46ef6a3042641e55a7002573ef501db7b60e1
This commit is contained in:
parent
3be49a8abe
commit
a281ef89a5
@ -342,20 +342,16 @@ class FakeSecurityGroup(object):
|
|||||||
"""Fake one or more security groups."""
|
"""Fake one or more security groups."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_security_group(attrs=None, methods=None):
|
def create_one_security_group(attrs=None):
|
||||||
"""Create a fake security group.
|
"""Create a fake security group.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, etc.
|
A FakeResource object, with id, name, etc.
|
||||||
"""
|
"""
|
||||||
if attrs is None:
|
if attrs is None:
|
||||||
attrs = {}
|
attrs = {}
|
||||||
if methods is None:
|
|
||||||
methods = {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
security_group_attrs = {
|
security_group_attrs = {
|
||||||
@ -369,28 +365,17 @@ class FakeSecurityGroup(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
security_group_attrs.update(attrs)
|
security_group_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
security_group_methods = {
|
|
||||||
'keys': ['id', 'name', 'description', 'tenant_id', 'rules'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
security_group_methods.update(methods)
|
|
||||||
|
|
||||||
security_group = fakes.FakeResource(
|
security_group = fakes.FakeResource(
|
||||||
info=copy.deepcopy(security_group_attrs),
|
info=copy.deepcopy(security_group_attrs),
|
||||||
methods=copy.deepcopy(security_group_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
return security_group
|
return security_group
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_security_groups(attrs=None, methods=None, count=2):
|
def create_security_groups(attrs=None, count=2):
|
||||||
"""Create multiple fake security groups.
|
"""Create multiple fake security groups.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of security groups to fake
|
The number of security groups to fake
|
||||||
:return:
|
:return:
|
||||||
@ -399,7 +384,7 @@ class FakeSecurityGroup(object):
|
|||||||
security_groups = []
|
security_groups = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
security_groups.append(
|
security_groups.append(
|
||||||
FakeSecurityGroup.create_one_security_group(attrs, methods))
|
FakeSecurityGroup.create_one_security_group(attrs))
|
||||||
|
|
||||||
return security_groups
|
return security_groups
|
||||||
|
|
||||||
@ -408,20 +393,16 @@ class FakeSecurityGroupRule(object):
|
|||||||
"""Fake one or more security group rules."""
|
"""Fake one or more security group rules."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_security_group_rule(attrs=None, methods=None):
|
def create_one_security_group_rule(attrs=None):
|
||||||
"""Create a fake security group rule.
|
"""Create a fake security group rule.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, etc.
|
A FakeResource object, with id, etc.
|
||||||
"""
|
"""
|
||||||
if attrs is None:
|
if attrs is None:
|
||||||
attrs = {}
|
attrs = {}
|
||||||
if methods is None:
|
|
||||||
methods = {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
security_group_rule_attrs = {
|
security_group_rule_attrs = {
|
||||||
@ -437,26 +418,17 @@ class FakeSecurityGroupRule(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
security_group_rule_attrs.update(attrs)
|
security_group_rule_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
security_group_rule_methods = {}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
security_group_rule_methods.update(methods)
|
|
||||||
|
|
||||||
security_group_rule = fakes.FakeResource(
|
security_group_rule = fakes.FakeResource(
|
||||||
info=copy.deepcopy(security_group_rule_attrs),
|
info=copy.deepcopy(security_group_rule_attrs),
|
||||||
methods=copy.deepcopy(security_group_rule_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
return security_group_rule
|
return security_group_rule
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_security_group_rules(attrs=None, methods=None, count=2):
|
def create_security_group_rules(attrs=None, count=2):
|
||||||
"""Create multiple fake security group rules.
|
"""Create multiple fake security group rules.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of security group rules to fake
|
The number of security group rules to fake
|
||||||
:return:
|
:return:
|
||||||
@ -465,8 +437,7 @@ class FakeSecurityGroupRule(object):
|
|||||||
security_group_rules = []
|
security_group_rules = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
security_group_rules.append(
|
security_group_rules.append(
|
||||||
FakeSecurityGroupRule.create_one_security_group_rule(
|
FakeSecurityGroupRule.create_one_security_group_rule(attrs))
|
||||||
attrs, methods))
|
|
||||||
|
|
||||||
return security_group_rules
|
return security_group_rules
|
||||||
|
|
||||||
@ -688,13 +659,11 @@ class FakeAvailabilityZone(object):
|
|||||||
"""Fake one or more compute availability zones (AZs)."""
|
"""Fake one or more compute availability zones (AZs)."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_availability_zone(attrs={}, methods={}):
|
def create_one_availability_zone(attrs={}):
|
||||||
"""Create a fake AZ.
|
"""Create a fake AZ.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object with zoneName, zoneState, etc.
|
A FakeResource object with zoneName, zoneState, etc.
|
||||||
"""
|
"""
|
||||||
@ -717,18 +686,15 @@ class FakeAvailabilityZone(object):
|
|||||||
|
|
||||||
availability_zone = fakes.FakeResource(
|
availability_zone = fakes.FakeResource(
|
||||||
info=copy.deepcopy(availability_zone),
|
info=copy.deepcopy(availability_zone),
|
||||||
methods=methods,
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
return availability_zone
|
return availability_zone
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_availability_zones(attrs={}, methods={}, count=2):
|
def create_availability_zones(attrs={}, count=2):
|
||||||
"""Create multiple fake AZs.
|
"""Create multiple fake AZs.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of AZs to fake
|
The number of AZs to fake
|
||||||
:return:
|
:return:
|
||||||
@ -737,8 +703,7 @@ class FakeAvailabilityZone(object):
|
|||||||
availability_zones = []
|
availability_zones = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
availability_zone = \
|
availability_zone = \
|
||||||
FakeAvailabilityZone.create_one_availability_zone(
|
FakeAvailabilityZone.create_one_availability_zone(attrs)
|
||||||
attrs, methods)
|
|
||||||
availability_zones.append(availability_zone)
|
availability_zones.append(availability_zone)
|
||||||
|
|
||||||
return availability_zones
|
return availability_zones
|
||||||
@ -748,13 +713,11 @@ class FakeFloatingIP(object):
|
|||||||
"""Fake one or more floating ip."""
|
"""Fake one or more floating ip."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_floating_ip(attrs={}, methods={}):
|
def create_one_floating_ip(attrs={}):
|
||||||
"""Create a fake floating ip.
|
"""Create a fake floating ip.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, ip, and so on
|
A FakeResource object, with id, ip, and so on
|
||||||
"""
|
"""
|
||||||
@ -770,27 +733,18 @@ class FakeFloatingIP(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
floating_ip_attrs.update(attrs)
|
floating_ip_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
floating_ip_methods = {}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
floating_ip_methods.update(methods)
|
|
||||||
|
|
||||||
floating_ip = fakes.FakeResource(
|
floating_ip = fakes.FakeResource(
|
||||||
info=copy.deepcopy(floating_ip_attrs),
|
info=copy.deepcopy(floating_ip_attrs),
|
||||||
methods=copy.deepcopy(floating_ip_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
return floating_ip
|
return floating_ip
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_floating_ips(attrs={}, methods={}, count=2):
|
def create_floating_ips(attrs={}, count=2):
|
||||||
"""Create multiple fake floating ips.
|
"""Create multiple fake floating ips.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of floating ips to fake
|
The number of floating ips to fake
|
||||||
:return:
|
:return:
|
||||||
@ -798,10 +752,7 @@ class FakeFloatingIP(object):
|
|||||||
"""
|
"""
|
||||||
floating_ips = []
|
floating_ips = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
floating_ips.append(FakeFloatingIP.create_one_floating_ip(
|
floating_ips.append(FakeFloatingIP.create_one_floating_ip(attrs))
|
||||||
attrs,
|
|
||||||
methods
|
|
||||||
))
|
|
||||||
return floating_ips
|
return floating_ips
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -828,13 +779,11 @@ class FakeNetwork(object):
|
|||||||
"""Fake one or more networks."""
|
"""Fake one or more networks."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_network(attrs={}, methods={}):
|
def create_one_network(attrs={}):
|
||||||
"""Create a fake network.
|
"""Create a fake network.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, label, cidr and so on
|
A FakeResource object, with id, label, cidr and so on
|
||||||
"""
|
"""
|
||||||
@ -877,28 +826,17 @@ class FakeNetwork(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
network_attrs.update(attrs)
|
network_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
network_methods = {
|
|
||||||
'keys': ['id', 'label', 'cidr'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
network_methods.update(methods)
|
|
||||||
|
|
||||||
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
|
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
|
||||||
methods=copy.deepcopy(network_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
return network
|
return network
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_networks(attrs={}, methods={}, count=2):
|
def create_networks(attrs={}, count=2):
|
||||||
"""Create multiple fake networks.
|
"""Create multiple fake networks.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of networks to fake
|
The number of networks to fake
|
||||||
:return:
|
:return:
|
||||||
@ -906,7 +844,7 @@ class FakeNetwork(object):
|
|||||||
"""
|
"""
|
||||||
networks = []
|
networks = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
networks.append(FakeNetwork.create_one_network(attrs, methods))
|
networks.append(FakeNetwork.create_one_network(attrs))
|
||||||
|
|
||||||
return networks
|
return networks
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user