New command 'add-key'
also, fixed pep8
Change-Id: I526083d72b50dc99b7e945db8d3e95ddbb81459f
diff --git a/reclass_tools/reclass_models.py b/reclass_tools/reclass_models.py
index 7ebb1f3..4f85e5e 100644
--- a/reclass_tools/reclass_models.py
+++ b/reclass_tools/reclass_models.py
@@ -1,11 +1,25 @@
+# Copyright 2013 - 2017 Mirantis, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
import reclass
-from reclass.adapters import salt as reclass_salt
+# from reclass.adapters import salt as reclass_salt
from reclass import config as reclass_config
from reclass import core as reclass_core
from reclass_tools import helpers
-#import salt.cli.call
-#import salt.cli.caller
+# import salt.cli.call
+# import salt.cli.caller
def get_core():
@@ -23,23 +37,24 @@
return reclass_core.Core(storage, None, None)
-#def get_minion_domain():
-# """Try to get domain from the local salt minion"""
-# client = salt.cli.call.SaltCall()
-# client.parse_args(args=['pillar.items'])
-# caller = salt.cli.caller.Caller.factory(client.config)
-# result = caller.call()
-# # Warning! There is a model-related parameter
-# # TODO: move the path to the parameter to a settings/defaults
-# domain = result['return']['_param']['cluster_domain']
-# return domain
+# def get_minion_domain():
+# """Try to get domain from the local salt minion"""
+# client = salt.cli.call.SaltCall()
+# client.parse_args(args=['pillar.items'])
+# caller = salt.cli.caller.Caller.factory(client.config)
+# result = caller.call()
+# # Warning! There is a model-related parameter
+# # TODO(ddmitriev): move the path to the parameter to a settings/defaults
+# domain = result['return']['_param']['cluster_domain']
+# return domain
def inventory_list(domain=None):
core = get_core()
inventory = core.inventory()['nodes']
if domain is not None:
- inventory = {key:val for (key, val) in inventory.items() if key.endswith(domain)}
+ inventory = {key: val for (key, val) in inventory.items()
+ if key.endswith(domain)}
return inventory
@@ -65,9 +80,12 @@
vcp_nodes = helpers.get_nested_key(node, path=vcp_path)
if vcp_nodes is not None:
for vcp_node_name, vcp_node in vcp_nodes.items():
- vcp_node_names.add((vcp_node['name'], helpers.get_nested_key(node, path=domain_path)))
+ vcp_node_names.add((
+ vcp_node['name'],
+ helpers.get_nested_key(node, path=domain_path)))
return vcp_node_names
+
def reclass_storage(domain=None, inventory=None):
"""List VCP node names
@@ -77,12 +95,12 @@
inventory = inventory or inventory_list(domain=domain)
storage_path = 'parameters.reclass.storage.node'.split('.')
- result = dict()
+ res = dict()
for node_name, node in inventory.items():
storage_nodes = helpers.get_nested_key(node, path=storage_path)
if storage_nodes is not None:
for storage_node_name, storage_node in storage_nodes.items():
- if storage_node['domain'] not in result:
- result[storage_node['domain']] = dict()
- result[storage_node['domain']][storage_node_name] = storage_node
- return result
+ if storage_node['domain'] not in res:
+ res[storage_node['domain']] = dict()
+ res[storage_node['domain']][storage_node_name] = storage_node
+ return res