diff options
author | Niko Hermanns <nikolas.hermanns@ericsson.com> | 2016-11-30 11:59:44 +0100 |
---|---|---|
committer | Nikolas Hermanns <nikolas.hermanns@ericsson.com> | 2016-12-13 11:26:00 +0100 |
commit | 416f9cf177801cecfe39f5249d73e3a4a85f0bbd (patch) | |
tree | bea48ec45edc10489aa76d348b0dbfbb1cf4d7ab /odl-pipeline/lib/utils/node_manager.py | |
parent | b9eb7024b014cba0d299b1cf3b01e179c7d0482e (diff) |
adding odl-pipeline
Change-Id: I1c08883f0d68a61ce9e10c5596aec1a259eed71f
Signed-off-by: Nikolas Hermanns <nikolas.hermanns@ericsson.com>
Diffstat (limited to 'odl-pipeline/lib/utils/node_manager.py')
-rwxr-xr-x | odl-pipeline/lib/utils/node_manager.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/odl-pipeline/lib/utils/node_manager.py b/odl-pipeline/lib/utils/node_manager.py new file mode 100755 index 0000000..d11065f --- /dev/null +++ b/odl-pipeline/lib/utils/node_manager.py @@ -0,0 +1,43 @@ +# +# Copyright (c) 2015 All rights reserved +# This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# +from ssh_util import SshUtil + + +class NodeManager(object): + + env_nodes = [] + env_node_dict = {} + primary_controller = None + + def __init__(self, config=None): + if config: + for (node_name, node_config) in config.iteritems(): + self.add_node(node_name, node_config) + + def add_node(self, node_name, node_config): + from node import Node + if not node_config.get('address'): + node_config['address'] = self.get_address_of_node(node_name) + node = Node(node_name, dict=node_config) + self.env_nodes.append(node) + self.env_node_dict[node_name] = node + return node + + def get_nodes(self): + return self.env_nodes + + def get_node(self, name): + return self.env_node_dict[name] + + @classmethod + def gen_ssh_config(cls, node): + if node not in cls.env_nodes: + cls.env_nodes.append(node) + SshUtil.gen_ssh_config(cls.env_nodes) |