summaryrefslogtreecommitdiffstats
path: root/modules/opnfv/deployment/manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/opnfv/deployment/manager.py')
-rw-r--r--modules/opnfv/deployment/manager.py58
1 files changed, 44 insertions, 14 deletions
diff --git a/modules/opnfv/deployment/manager.py b/modules/opnfv/deployment/manager.py
index 8c9599b6e..43a79488b 100644
--- a/modules/opnfv/deployment/manager.py
+++ b/modules/opnfv/deployment/manager.py
@@ -89,25 +89,35 @@ class Deployment(object):
sdn_controller=self.deployment_info['sdn_controller'])
for node in self.deployment_info['nodes']:
- s += '\t\t{node_object}\n'.format(node_object=node)
+ s += '{node_object}\n'.format(node_object=node)
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,9 +163,9 @@ class Node(object):
'''
Run command remotely on a node
'''
- if self.status is not Node.STATUS_OK:
- logger.info("The node %s is not active" % self.ip)
- return 1
+ if self.status is not NodeStatus.STATUS_OK:
+ logger.error("The node %s is not active" % self.ip)
+ return None
_, stdout, stderr = (self.ssh_client.exec_command(cmd))
error = stderr.readlines()
if len(error) > 0:
@@ -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,12 +205,32 @@ 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
+ def get_ovs_info(self):
+ '''
+ Returns the ovs version installed
+ '''
+ cmd = "ovs-vsctl --version|head -1| sed 's/^.*) //'"
+ return self.run_cmd(cmd)
+
def __str__(self):
- return str(self.get_dict())
+ return '''
+ name: {name}
+ id: {id}
+ ip: {ip}
+ status: {status}
+ roles: {roles}
+ ovs: {ovs}
+ info: {info}'''.format(name=self.name,
+ id=self.id,
+ ip=self.ip,
+ status=self.status,
+ roles=self.roles,
+ ovs=self.get_ovs_info(),
+ info=self.info)
class DeploymentHandler(object):
@@ -236,7 +266,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: