You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2016/10/20 15:12:03 UTC
incubator-ariatosca git commit: pylint-aria-storage [Forced Update!]
Repository: incubator-ariatosca
Updated Branches:
refs/heads/pylint-aria-storage 5139e7a97 -> bae20ae92 (forced update)
pylint-aria-storage
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/bae20ae9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/bae20ae9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/bae20ae9
Branch: refs/heads/pylint-aria-storage
Commit: bae20ae92ed0f5593ee535c1b94601b8616c6c02
Parents: 62cf248
Author: mxmrlv <mx...@gmail.com>
Authored: Wed Oct 19 17:07:45 2016 +0300
Committer: mxmrlv <mx...@gmail.com>
Committed: Thu Oct 20 18:11:50 2016 +0300
----------------------------------------------------------------------
aria/storage/__init__.py | 23 ++++++++++++++--
aria/storage/drivers.py | 11 +++++---
aria/storage/models.py | 60 ++++++++++++++++++++++++++++++++++++++---
aria/storage/structures.py | 18 +++++++++++++
tests/.pylintrc | 1 -
5 files changed, 103 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bae20ae9/aria/storage/__init__.py
----------------------------------------------------------------------
diff --git a/aria/storage/__init__.py b/aria/storage/__init__.py
index 3f9aefa..20c73a6 100644
--- a/aria/storage/__init__.py
+++ b/aria/storage/__init__.py
@@ -72,6 +72,9 @@ __all__ = (
class ModelStorage(Storage):
+ """
+ Managing the models storage.
+ """
def __init__(self, driver, models=(), **kwargs):
"""
Simple storage client api for Aria applications.
@@ -99,12 +102,15 @@ class ModelStorage(Storage):
return super(ModelStorage, self).__getattr__(table)
def register(self, model_cls):
- # todo: add documentation
+ """
+ Registers the model type in the resource storage manager.
+ :param model_cls: the model to register.
+ """
model_name = generate_lower_name(model_cls)
model_api = _ModelApi(model_name, self.driver, model_cls)
self.registered[model_name] = model_api
- for pointer, pointer_schema_register in model_api.pointer_mapping.items():
+ for pointer_schema_register in model_api.pointer_mapping.values():
model_cls = pointer_schema_register.model_cls
self.register(model_cls)
@@ -256,6 +262,12 @@ class _ModelApi(object):
class ResourceApi(object):
+ """
+ Managing the resource in the storage, using the driver.
+
+ :param basestring name: the name of the resource.
+ :param ResourceDriver driver: the driver which supports this resource in the storage.
+ """
def __init__(self, driver, resource_name):
"""
Managing the resources in the storage, using the driver.
@@ -341,6 +353,9 @@ def generate_lower_name(model_cls):
class ResourceStorage(Storage):
+ """
+ Managing the resource storage.
+ """
def __init__(self, driver, resources=(), **kwargs):
"""
Simple storage client api for Aria applications.
@@ -353,6 +368,10 @@ class ResourceStorage(Storage):
super(ResourceStorage, self).__init__(driver, resources, **kwargs)
def register(self, resource):
+ """
+ Registers the resource type in the resource storage manager.
+ :param resource: the resource to register.
+ """
self.registered[resource] = ResourceApi(self.driver, resource_name=resource)
def __getattr__(self, resource):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bae20ae9/aria/storage/drivers.py
----------------------------------------------------------------------
diff --git a/aria/storage/drivers.py b/aria/storage/drivers.py
index 17a99a1..0ad2f49 100644
--- a/aria/storage/drivers.py
+++ b/aria/storage/drivers.py
@@ -29,7 +29,8 @@ classes:
import os
import shutil
-import distutils.dir_util
+# pylint has an issue with distutils and virtualenvs: https://github.com/PyCQA/pylint/issues/73
+import distutils.dir_util # pylint: disable=no-name-in-module, import-error
from functools import partial
from multiprocessing import RLock
@@ -216,6 +217,9 @@ class ResourceDriver(Driver):
class BaseFileSystemDriver(Driver):
+ """
+ Base class which handles storage on the file system.
+ """
def __init__(self, *args, **kwargs):
super(BaseFileSystemDriver, self).__init__(*args, **kwargs)
self._lock = RLock()
@@ -324,6 +328,7 @@ class FileSystemModelDriver(ModelDriver, BaseFileSystemDriver):
entry_dict.update(**kwargs)
self.store(name, entry_id, entry_dict)
+
class FileSystemResourceDriver(ResourceDriver, BaseFileSystemDriver):
"""
FileSystemResourceDriver context manager.
@@ -386,7 +391,7 @@ class FileSystemResourceDriver(ResourceDriver, BaseFileSystemDriver):
if os.path.isfile(resource):
shutil.copy2(resource, destination)
else:
- distutils.dir_util.copy_tree(resource, destination)
+ distutils.dir_util.copy_tree(resource, destination) # pylint: disable=no-member
def upload(self, entry_type, entry_id, source, path=None):
"""
@@ -404,4 +409,4 @@ class FileSystemResourceDriver(ResourceDriver, BaseFileSystemDriver):
if os.path.isfile(source):
shutil.copy2(source, destination)
else:
- distutils.dir_util.copy_tree(source, destination)
+ distutils.dir_util.copy_tree(source, destination) # pylint: disable=no-member
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bae20ae9/aria/storage/models.py
----------------------------------------------------------------------
diff --git a/aria/storage/models.py b/aria/storage/models.py
index d96c74a..32403ed 100644
--- a/aria/storage/models.py
+++ b/aria/storage/models.py
@@ -65,6 +65,9 @@ ENTITY_TYPES = ()
class Blueprint(Model):
+ """
+ A Model which represents a blueprint
+ """
plan = Field(type=dict)
id = Field(type=basestring, default=uuid_generator)
description = Field(type=(basestring, NoneType))
@@ -74,6 +77,9 @@ class Blueprint(Model):
class Snapshot(Model):
+ """
+ A Model which represents a snapshot
+ """
CREATED = 'created'
FAILED = 'failed'
CREATING = 'creating'
@@ -87,13 +93,15 @@ class Snapshot(Model):
class Deployment(Model):
+ """
+ A Model which represents a deployment
+ """
id = Field(type=basestring, default=uuid_generator)
description = Field(type=(basestring, NoneType))
created_at = Field(type=datetime)
updated_at = Field(type=datetime)
blueprint_id = Field(type=basestring)
workflows = Field(type=dict)
- permalink = Field(default=None) # TODO: check if needed... (old todo: implement)
inputs = Field(type=dict, default=lambda: {})
policy_types = Field(type=dict, default=lambda: {})
policy_triggers = Field(type=dict, default=lambda: {})
@@ -103,6 +111,9 @@ class Deployment(Model):
class DeploymentUpdateStep(Model):
+ """
+ A Model which represents a deployment update step
+ """
id = Field(type=basestring, default=uuid_generator)
action = Field(type=basestring, choices=ACTION_TYPES)
entity_type = Field(type=basestring, choices=ENTITY_TYPES)
@@ -123,11 +134,12 @@ class DeploymentUpdateStep(Model):
if self.action != other.action:
if self.action == 'remove':
- return True
+ return_value = True
elif self.action == 'add':
- return False
+ return_value = False
else:
- return other.action == 'add'
+ return_value = other.action == 'add'
+ return return_value
if self.action == 'add':
return self.entity_type == 'node' and other.entity_type == 'relationship'
@@ -137,6 +149,9 @@ class DeploymentUpdateStep(Model):
class DeploymentUpdate(Model):
+ """
+ A Model which represents a deployment update
+ """
INITIALIZING = 'initializing'
SUCCESSFUL = 'successful'
UPDATING = 'updating'
@@ -167,6 +182,9 @@ class DeploymentUpdate(Model):
class Execution(Model):
+ """
+ A Model which represents an execution
+ """
TERMINATED = 'terminated'
FAILED = 'failed'
CANCELLED = 'cancelled'
@@ -199,6 +217,9 @@ class Execution(Model):
class Operation(Model):
+ """
+ A Model which represents an operation
+ """
PENDING = 'pending'
STARTED = 'started'
SUCCESS = 'success'
@@ -222,6 +243,9 @@ class Operation(Model):
class Relationship(Model):
+ """
+ A Model which represents a relationship
+ """
id = Field(type=basestring, default=uuid_generator)
target_id = Field(type=basestring)
source_interfaces = Field(type=dict)
@@ -234,6 +258,9 @@ class Relationship(Model):
class Node(Model):
+ """
+ A Model which represents a node
+ """
id = Field(type=basestring, default=uuid_generator)
blueprint_id = Field(type=basestring)
type = Field(type=basestring)
@@ -251,6 +278,11 @@ class Node(Model):
max_number_of_instances = Field(type=int)
def relationships_by_target(self, target_id):
+ """
+ Retreives all of the relationship by target.
+ :param target_id: the node id of the target of the relationship
+ :yields: a relationship which target and node with the specified target_id
+ """
for relationship in self.relationships:
if relationship.target_id == target_id:
yield relationship
@@ -258,6 +290,9 @@ class Node(Model):
class RelationshipInstance(Model):
+ """
+ A Model which represents a relationship instance
+ """
id = Field(type=basestring, default=uuid_generator)
target_id = Field(type=basestring)
target_name = Field(type=basestring)
@@ -266,6 +301,9 @@ class RelationshipInstance(Model):
class NodeInstance(Model):
+ """
+ A Model which represents a node instance
+ """
# todo: add statuses
UNINITIALIZED = 'uninitialized'
INITIALIZING = 'initializing'
@@ -297,6 +335,11 @@ class NodeInstance(Model):
scaling_groups = Field(default=())
def relationships_by_target(self, target_id):
+ """
+ Retreives all of the relationship by target.
+ :param target_id: the instance id of the target of the relationship
+ :yields: a relationship instance which target and node with the specified target_id
+ """
for relationship_instance in self.relationship_instances:
if relationship_instance.target_id == target_id:
yield relationship_instance
@@ -304,6 +347,9 @@ class NodeInstance(Model):
class DeploymentModification(Model):
+ """
+ A Model which represents a deployment modification
+ """
STARTED = 'started'
FINISHED = 'finished'
ROLLEDBACK = 'rolledback'
@@ -324,12 +370,18 @@ class DeploymentModification(Model):
class ProviderContext(Model):
+ """
+ A Model which represents a provider context
+ """
id = Field(type=basestring, default=uuid_generator)
context = Field(type=dict)
name = Field(type=basestring)
class Plugin(Model):
+ """
+ A Model which represents a plugin
+ """
id = Field(type=basestring, default=uuid_generator)
package_name = Field(type=basestring)
archive_name = Field(type=basestring)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bae20ae9/aria/storage/structures.py
----------------------------------------------------------------------
diff --git a/aria/storage/structures.py b/aria/storage/structures.py
index 5ebd8b8..ea4cf3a 100644
--- a/aria/storage/structures.py
+++ b/aria/storage/structures.py
@@ -48,6 +48,9 @@ __all__ = (
def uuid_generator():
+ """
+ wrapper function which generates ids
+ """
return str(uuid4())
@@ -132,6 +135,9 @@ class Field(ValidatorMixin):
class IterField(Field):
+ """
+ Represents an iterable field.
+ """
def __init__(self, **kwargs):
"""
Simple iterable field manager.
@@ -174,6 +180,11 @@ class IterPointerField(IterField, PointerField):
class Model(object):
+ """
+ Base class for all of the storage models.
+ """
+ id = None
+
def __init__(self, **fields):
"""
Abstract class for any model in the storage.
@@ -206,6 +217,10 @@ class Model(object):
@property
def fields(self):
+ """
+ Iterates over the fields of the model.
+ :yields: the class's field name
+ """
for name, field in vars(self.__class__).items():
if isinstance(field, Field):
yield name
@@ -254,6 +269,9 @@ class Model(object):
class Storage(LoggerMixin):
+ """
+ Represents the storage
+ """
def __init__(self, driver, items=(), **kwargs):
super(Storage, self).__init__(**kwargs)
self.driver = driver
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bae20ae9/tests/.pylintrc
----------------------------------------------------------------------
diff --git a/tests/.pylintrc b/tests/.pylintrc
index 753d619..f6cfd7a 100644
--- a/tests/.pylintrc
+++ b/tests/.pylintrc
@@ -404,5 +404,4 @@ overgeneral-exceptions=Exception
[pre-commit-hook]
-params=--reports=no
limit=9.5