diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-01-16 09:17:48 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-01-16 09:18:44 +0000 |
commit | fa3afbcac13e1aa3ae9cc2977dcb4cd882112f6f (patch) | |
tree | b9884b84f976f5d75d22b447d38f3c49e4a947fd /yardstick/benchmark/contexts | |
parent | f036e9898a69f5041f9cde02e3652c29e2de1643 (diff) |
Use """ to replace ''' in docstring
JIRA: YARDSTICK-525
For consistency, we always use """triple double quotes""" around
docstrings.
Change-Id: I47a20bbd8b55bc544b4841ea4006929af0a044ac
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r-- | yardstick/benchmark/contexts/base.py | 16 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/dummy.py | 6 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 20 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/model.py | 36 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/node.py | 12 |
5 files changed, 45 insertions, 45 deletions
diff --git a/yardstick/benchmark/contexts/base.py b/yardstick/benchmark/contexts/base.py index 054ce4236..9f2b21537 100644 --- a/yardstick/benchmark/contexts/base.py +++ b/yardstick/benchmark/contexts/base.py @@ -15,7 +15,7 @@ import yardstick.common.utils as utils @six.add_metaclass(abc.ABCMeta) class Context(object): - '''Class that represents a context in the logical model''' + """Class that represents a context in the logical model""" list = [] def __init__(self): @@ -27,7 +27,7 @@ class Context(object): @staticmethod def get_cls(context_type): - '''Return class of specified type.''' + """Return class of specified type.""" for context in utils.itersubclasses(Context): if context_type == context.__context_type__: return context @@ -41,23 +41,23 @@ class Context(object): @abc.abstractmethod def deploy(self): - '''Deploy context.''' + """Deploy context.""" @abc.abstractmethod def undeploy(self): - '''Undeploy context.''' + """Undeploy context.""" @abc.abstractmethod def _get_server(self, attr_name): - '''get server info by name from context - ''' + """get server info by name from context + """ @staticmethod def get_server(attr_name): - '''lookup server info by name from context + """lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates - ''' + """ server = None for context in Context.list: server = context._get_server(attr_name) diff --git a/yardstick/benchmark/contexts/dummy.py b/yardstick/benchmark/contexts/dummy.py index 0e76b5a82..f7530035c 100644 --- a/yardstick/benchmark/contexts/dummy.py +++ b/yardstick/benchmark/contexts/dummy.py @@ -17,7 +17,7 @@ LOG = logging.getLogger(__name__) class DummyContext(Context): - '''Class that handle dummy info''' + """Class that handle dummy info""" __context_type__ = "Dummy" @@ -28,11 +28,11 @@ class DummyContext(Context): pass def deploy(self): - '''don't need to deploy''' + """don't need to deploy""" pass def undeploy(self): - '''don't need to undeploy''' + """don't need to undeploy""" pass def _get_server(self, attr_name): diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index 0b2fbdcd6..0346efcf4 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__) class HeatContext(Context): - '''Class that represents a context in the logical model''' + """Class that represents a context in the logical model""" __context_type__ = "Heat" @@ -58,7 +58,7 @@ class HeatContext(Context): super(self.__class__, self).__init__() def init(self, attrs): - '''initializes itself from the supplied arguments''' + """initializes itself from the supplied arguments""" self.name = attrs["name"] if "user" in attrs: @@ -101,21 +101,21 @@ class HeatContext(Context): @property def image(self): - '''returns application's default image name''' + """returns application's default image name""" return self._image @property def flavor(self): - '''returns application's default flavor name''' + """returns application's default flavor name""" return self._flavor @property def user(self): - '''return login user name corresponding to image''' + """return login user name corresponding to image""" return self._user def _add_resources_to_template(self, template): - '''add to the template the resources represented by this context''' + """add to the template the resources represented by this context""" template.add_keypair(self.keypair_name, self.key_uuid) template.add_security_group(self.secgroup_name) @@ -200,7 +200,7 @@ class HeatContext(Context): server.add_to_template(template, self.networks, {}) def deploy(self): - '''deploys template into a stack using cloud''' + """deploys template into a stack using cloud""" print("Deploying context '%s'" % self.name) heat_template = HeatTemplate(self.name, self.template_file, @@ -232,7 +232,7 @@ class HeatContext(Context): print("Context '%s' deployed" % self.name) def undeploy(self): - '''undeploys stack from cloud''' + """undeploys stack from cloud""" if self.stack: print("Undeploying context '%s'" % self.name) self.stack.delete() @@ -247,10 +247,10 @@ class HeatContext(Context): LOG.exception("Key filename %s", self.key_filename) def _get_server(self, attr_name): - '''lookup server info by name from context + """lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates - ''' + """ key_filename = pkg_resources.resource_filename( 'yardstick.resources', 'files/yardstick_key-' + get_short_key_uuid(self.key_uuid)) diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py index 1d0a5a133..636abfa35 100644 --- a/yardstick/benchmark/contexts/model.py +++ b/yardstick/benchmark/contexts/model.py @@ -15,9 +15,9 @@ from six.moves import range class Object(object): - '''Base class for classes in the logical model + """Base class for classes in the logical model Contains common attributes and methods - ''' + """ def __init__(self, name, context): # model identities and reference @@ -30,15 +30,15 @@ class Object(object): @property def dn(self): - '''returns distinguished name for object''' + """returns distinguished name for object""" return self.name + "." + self._context.name class PlacementGroup(Object): - '''Class that represents a placement group in the logical model + """Class that represents a placement group in the logical model Concept comes from the OVF specification. Policy should be one of "availability" or "affinity (there are more but they are not supported)" - ''' + """ map = {} def __init__(self, name, context, policy): @@ -63,7 +63,7 @@ class PlacementGroup(Object): class Router(Object): - '''Class that represents a router in the logical model''' + """Class that represents a router in the logical model""" def __init__(self, name, network_name, context, external_gateway_info): super(self.__class__, self).__init__(name, context) @@ -74,7 +74,7 @@ class Router(Object): class Network(Object): - '''Class that represents a network in the logical model''' + """Class that represents a network in the logical model""" list = [] def __init__(self, name, context, attrs): @@ -91,22 +91,22 @@ class Network(Object): Network.list.append(self) def has_route_to(self, network_name): - '''determines if this network has a route to the named network''' + """determines if this network has a route to the named network""" if self.router and self.router.external_gateway_info == network_name: return True return False @staticmethod def find_by_route_to(external_network): - '''finds a network that has a route to the specified network''' + """finds a network that has a route to the specified network""" for network in Network.list: if network.has_route_to(external_network): return network @staticmethod def find_external_network(): - '''return the name of an external network some network in this - context has a route to''' + """return the name of an external network some network in this + context has a route to""" for network in Network.list: if network.router: return network.router.external_gateway_info @@ -114,7 +114,7 @@ class Network(Object): class Server(Object): - '''Class that represents a server in the logical model''' + """Class that represents a server in the logical model""" list = [] def __init__(self, name, context, attrs): @@ -171,7 +171,7 @@ class Server(Object): @property def image(self): - '''returns a server's image name''' + """returns a server's image name""" if self._image: return self._image else: @@ -179,14 +179,14 @@ class Server(Object): @property def flavor(self): - '''returns a server's flavor name''' + """returns a server's flavor name""" if self._flavor: return self._flavor else: return self._context.flavor def _add_instance(self, template, server_name, networks, scheduler_hints): - '''adds to the template one server and corresponding resources''' + """adds to the template one server and corresponding resources""" port_name_list = [] for network in networks: port_name = server_name + "-" + network.name + "-port" @@ -219,7 +219,7 @@ class Server(Object): scheduler_hints=scheduler_hints) def add_to_template(self, template, networks, scheduler_hints=None): - '''adds to the template one or more servers (instances)''' + """adds to the template one or more servers (instances)""" if self.instances == 1: server_name = self.stack_name self._add_instance(template, server_name, networks, @@ -233,9 +233,9 @@ class Server(Object): def update_scheduler_hints(scheduler_hints, added_servers, placement_group): - ''' update scheduler hints from server's placement configuration + """ update scheduler hints from server's placement configuration TODO: this code is openstack specific and should move somewhere else - ''' + """ if placement_group.policy == "affinity": if "same_host" in scheduler_hints: host_list = scheduler_hints["same_host"] diff --git a/yardstick/benchmark/contexts/node.py b/yardstick/benchmark/contexts/node.py index 6db51cccb..e02a71669 100644 --- a/yardstick/benchmark/contexts/node.py +++ b/yardstick/benchmark/contexts/node.py @@ -20,7 +20,7 @@ LOG = logging.getLogger(__name__) class NodeContext(Context): - '''Class that handle nodes info''' + """Class that handle nodes info""" __context_type__ = "Node" @@ -34,7 +34,7 @@ class NodeContext(Context): super(self.__class__, self).__init__() def init(self, attrs): - '''initializes itself from the supplied arguments''' + """initializes itself from the supplied arguments""" self.name = attrs["name"] self.file_path = attrs.get("file", "pod.yaml") if not os.path.exists(self.file_path): @@ -61,17 +61,17 @@ class NodeContext(Context): LOG.debug("BareMetals: %r", self.baremetals) def deploy(self): - '''don't need to deploy''' + """don't need to deploy""" pass def undeploy(self): - '''don't need to undeploy''' + """don't need to undeploy""" pass def _get_server(self, attr_name): - '''lookup server info by name from context + """lookup server info by name from context attr_name: a name for a server listed in nodes config file - ''' + """ if type(attr_name) is dict: return None |