Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
updated cluster_id logic (#1467)
Browse files Browse the repository at this point in the history
Signed-off-by: Tanuja Shinde <[email protected]>

Co-authored-by: Pritam Bhavsar <[email protected]>
  • Loading branch information
tanujashinde0405 and 83bhp authored Jul 5, 2021
1 parent 2f27d01 commit d4d0ef9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
4 changes: 3 additions & 1 deletion api/python/provisioner/commands/cluster_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def run(self, targets=ALL_MINIONS):

# Ensure cluster-id file is created in all nodes
StatesApplier.apply(
['components.provisioner.config.cluster_id'],
['components.provisioner.config.cluster_id',
'components.system.config.sync_salt'
],
targets=ALL_MINIONS
)

Expand Down
7 changes: 6 additions & 1 deletion api/python/provisioner/commands/confstore_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ def run(self, **kwargs):
template_file_path = str(
CORTX_CONFIG_DIR /
'provisioner_confstore_template')

# TODO
# Not a good way to call primary node with hardcoded value
# need to remove it for hostname bug for cortx_setup API
node= 'srvnode-1'
StateFunExecuter.execute(
'file.managed',
fun_kwargs=dict(
name=template_file_path,
source='salt://components/system/files/confstore_template.j2',
template='jinja'))
template='jinja'),targets=node)
logger.info("Pillar confstore template is created at "
f"{template_file_path}"
)
Expand Down
16 changes: 12 additions & 4 deletions lr-cli/cortx_setup/commands/cluster/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@
local_minion_id,
cmd_run
)
from provisioner import salt
from provisioner.api import grains_get
from cortx_setup.config import (
ALL_MINIONS
)
from provisioner.salt import StatesApplier


class ClusterCreate(Command):
Expand Down Expand Up @@ -133,6 +138,7 @@ def run(self, **kwargs):
"""
try:
index = 'node_info_index'
local_minion = None
local_fqdn = socket.gethostname()
cluster_args = ['name', 'site_count', 'storageset_count']

Expand All @@ -148,6 +154,7 @@ def run(self, **kwargs):
for idx, node in enumerate(nodes):
if node == local_fqdn:
nodes[idx] = f"srvnode-1:{node}"
local_minion = 'srvnode-1'
else:
nodes[idx] = f"srvnode-{idx+1}:{node}"

Expand Down Expand Up @@ -182,7 +189,7 @@ def run(self, **kwargs):
f"Starting bootstrap process now with args: {kwargs}"
)
bootstrap_provisioner.BootstrapProvisioner()._run(**kwargs)

salt._local_minion_id = local_minion
if SOURCE_PATH.exists():
self.logger.debug("Cleanup existing storage config on all nodes")
cmd_run(f"mv {SOURCE_PATH} {DEST_PATH}")
Expand All @@ -201,8 +208,9 @@ def run(self, **kwargs):
self.logger.debug("Creating service user")
create_service_user.CreateServiceUser.run(user="cortxub")

node_id = 'srvnode-1'
self.logger.debug("Setting up Cluster ID on the system")
cluster_id.ClusterId().run()
cmd_run('provisioner cluster_id', targets=node_id)

self.logger.debug("Encrypting config data")
EncryptSecrets().run()
Expand All @@ -214,15 +222,15 @@ def run(self, **kwargs):
# TODO: move this to time.py after encryption issue
self.logger.debug("Setting time on node with server & timezone")

node_id = local_minion_id()
# node_id = local_minion_id()
NodePrepareTime().set_server_time()
machine_id = get_machine_id(node_id)
enclosure_id = grains_get("enclosure_id")[node_id]["enclosure_id"]
if enclosure_id:
if not machine_id in enclosure_id: # check if the system is VM or HW
self.logger.debug(f"Setting time on enclosure with server & timezone")
NodePrepareTime().set_enclosure_time()

StatesApplier.apply( ['components.system.config.sync_salt'] ,targets=ALL_MINIONS)
self.logger.debug("Exporting to Confstore")
confstore_export.ConfStoreExport().run()

Expand Down
4 changes: 3 additions & 1 deletion lr-cli/cortx_setup/commands/cluster/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def run(self, targets=ALL_MINIONS):
self.logger.debug("Generating cluster pillar")

StatesApplier.apply(
['components.provisioner.config.generate_cluster_pillar'],
['components.provisioner.config.generate_cluster_pillar',
'components.system.config.sync_salt'
],
targets=ALL_MINIONS
)

Expand Down

0 comments on commit d4d0ef9

Please sign in to comment.