aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/client.py')
-rw-r--r--deploy/client.py40
1 files changed, 25 insertions, 15 deletions
diff --git a/deploy/client.py b/deploy/client.py
index 910aa7f8..3a9b0dec 100644
--- a/deploy/client.py
+++ b/deploy/client.py
@@ -79,8 +79,8 @@ opts = [
cfg.BoolOpt('poll_switches',
help='if the client polls switches',
default=True),
- cfg.StrOpt('machines',
- help='comma separated mac addresses of machines',
+ cfg.StrOpt('machine_file',
+ help='mac addresses and ipmi info of machines',
default=''),
cfg.StrOpt('subnets',
help='comma seperated subnets',
@@ -259,6 +259,9 @@ opts = [
cfg.StrOpt('plugins',
help='plugin dict',
default='{}'),
+ cfg.StrOpt('cluster_param',
+ help='cluster dict',
+ default='{}'),
cfg.StrOpt('offline_deployment',
help='offline_deployment',
default='Disable'),
@@ -324,12 +327,12 @@ class CompassClient(object):
'get all machines status: %s, resp: %s', status, resp)
raise RuntimeError('failed to get machines')
- machines_to_add = list(set([
- machine for machine in CONF.machines.split(',')
- if machine
- ]))
+ with open(CONF.machine_file) as fd:
+ machines_to_add = [str(m["mac"]) for m in yaml.load(fd)]
+ resp = byteify(resp)
machines_db = [str(m["mac"]) for m in resp]
+
LOG.info(
'machines in db: %s\n to add: %s',
machines_db,
@@ -399,17 +402,20 @@ class CompassClient(object):
except:
raise RuntimeError('subnet %s format is invalid' % subnet)
- if CONF.expansion == "false":
+ subnet_exist = False
+ for subnet_in_db in subnets_in_db:
+ if subnet == subnet_in_db['subnet']:
+ subnet_mapping[subnet] = subnet_in_db['id']
+ subnet_exist = True
+ break
+
+ if not subnet_exist:
status, resp = self.client.add_subnet(subnet)
LOG.info('add subnet %s status %s response %s',
subnet, status, resp)
if not self.is_ok(status):
raise RuntimeError('failed to add subnet %s' % subnet)
subnet_mapping[resp['subnet']] = resp['id']
- else:
- for subnet_in_db in subnets_in_db:
- if subnet == subnet_in_db['subnet']:
- subnet_mapping[subnet] = subnet_in_db['id']
self.subnet_mapping = subnet_mapping
@@ -475,8 +481,8 @@ class CompassClient(object):
if host['hostname'] in hostnames:
self.host_mapping[host['hostname']] = host['id']
- if CONF.expansion == "false":
- assert(len(self.host_mapping) == len(machines))
+ # if CONF.expansion == "false":
+ # assert(len(self.host_mapping) == len(machines))
def set_cluster_os_config(self, cluster_id):
"""set cluster os config."""
@@ -800,11 +806,17 @@ class CompassClient(object):
package_config['odl_l3_agent'] = "Enable" if CONF.odl_l3_agent == "Enable" else "Disable" # noqa
package_config['onos_sfc'] = "Enable" if CONF.onos_sfc == "Enable" else "Disable" # noqa
package_config['plugins'] = []
+ package_config['cluster_param'] = []
if CONF.plugins:
for item in CONF.plugins.split(','):
key, value = item.split(':')
package_config['plugins'].append({key: value})
+ if CONF.cluster_param:
+ for item in CONF.cluster_param.split(','):
+ key, value = item.split(':')
+ package_config['cluster_param'].append({key: value})
+
status, resp = self.client.update_cluster_config(
cluster_id, package_config=package_config)
LOG.info(
@@ -971,8 +983,6 @@ class CompassClient(object):
ansible_log = "%s/work/deploy/docker/ansible/run/%s-%s/ansible.log" \
% (compass_dir, CONF.adapter_name, CONF.cluster_name)
os.system("sudo touch %s" % ansible_log)
- os.system("sudo chmod +x -R %s/work/deploy/docker/ansible/run/"
- % compass_dir)
ansible_print = multiprocessing.Process(target=print_log,
args=(ansible_log,))
ansible_print.start()