aboutsummaryrefslogtreecommitdiffstats
path: root/opnfv/deployment/manager.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2017-02-10 17:10:18 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2017-02-14 21:06:22 +0100
commitf76ce64057a07130c6c07e924e2151ca56800df9 (patch)
tree39d2126128f6014e6db8957fefdef693db673aa6 /opnfv/deployment/manager.py
parent2f0c4e1baa6a45dc451142f1372c48e69a5d1565 (diff)
[deployment handler] Add Roles and Status classes
By doing this, we can handle roles and status as a list in the node object. Output: http://pastebin.com/raw/PAMrWRJi Change-Id: I0e3c7f375b19548a7e424e3257b84424c8fe4725 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'opnfv/deployment/manager.py')
-rw-r--r--opnfv/deployment/manager.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/opnfv/deployment/manager.py b/opnfv/deployment/manager.py
index 8c9599b..9be5166 100644
--- a/opnfv/deployment/manager.py
+++ b/opnfv/deployment/manager.py
@@ -94,20 +94,30 @@ class Deployment(object):
return s
-class Node(object):
+class Role():
+ CONTROLLER = 'controller'
+ COMPUTE = 'compute'
+ ODL = 'opendaylight'
+ ONOS = 'onos'
+
+class NodeStatus():
STATUS_OK = 'active'
STATUS_INACTIVE = 'inactive'
STATUS_OFFLINE = 'offline'
- STATUS_FAILED = 'failed'
+ STATUS_ERROR = 'error'
+ STATUS_UNUSED = 'unused'
+
+
+class Node(object):
def __init__(self,
id,
ip,
name,
status,
- roles,
- ssh_client,
+ roles=[],
+ ssh_client=None,
info={}):
self.id = id
self.ip = ip
@@ -121,7 +131,7 @@ class Node(object):
'''
SCP file from a node
'''
- if self.status is not Node.STATUS_OK:
+ if self.status is not NodeStatus.STATUS_OK:
logger.info("The node %s is not active" % self.ip)
return 1
logger.info("Fetching %s from %s" % (src, self.ip))
@@ -137,7 +147,7 @@ class Node(object):
'''
SCP file to a node
'''
- if self.status is not Node.STATUS_OK:
+ if self.status is not NodeStatus.STATUS_OK:
logger.info("The node %s is not active" % self.ip)
return 1
logger.info("Copying %s to %s" % (src, self.ip))
@@ -153,7 +163,7 @@ class Node(object):
'''
Run command remotely on a node
'''
- if self.status is not Node.STATUS_OK:
+ if self.status is not NodeStatus.STATUS_OK:
logger.info("The node %s is not active" % self.ip)
return 1
_, stdout, stderr = (self.ssh_client.exec_command(cmd))
@@ -187,7 +197,7 @@ class Node(object):
'''
Returns if the node is a controller
'''
- if 'controller' in self.get_attribute('roles'):
+ if 'controller' in self.roles:
return True
return False
@@ -195,7 +205,7 @@ class Node(object):
'''
Returns if the node is a compute
'''
- if 'compute' in self.get_attribute('roles'):
+ if 'compute' in self.roles:
return True
return False
@@ -236,7 +246,7 @@ class DeploymentHandler(object):
self.installer_node = Node(id='',
ip=installer_ip,
name=installer,
- status='active',
+ status=NodeStatus.STATUS_OK,
ssh_client=self.installer_connection,
roles='installer node')
else: