Add get deploy mode action

Change-Id: I53af08a97c2ba2b4d07cc0778814985834fb4a27
This commit is contained in:
cao.yuan 2019-07-26 10:45:36 +08:00
parent f467c033e7
commit 6b03977fd7
3 changed files with 35 additions and 0 deletions

View File

@ -208,3 +208,19 @@ class ControlPlaneApi(object):
inventory = Inventory.load()
inventory.set_deploy_mode(remote_mode)
Inventory.save(inventory)
@staticmethod
def get_deploy_mode():
"""Get deploy mode from either local or remote.
Local indicates that the openstack deployment will be
to the local host. Remote means that the deployment is
executed via ssh.
NOTE: local mode is not supported and should never be used
in production environments.
"""
inventory = Inventory.load()
remote_mode = inventory.remote_mode
deploy_mode = 'remote' if remote_mode else 'local'
return deploy_mode

View File

@ -56,3 +56,21 @@ class Setdeploy(Command):
raise e
except Exception:
raise Exception(traceback.format_exc())
class Getdeploy(Command):
"""get deploy mode from either local or remote.
Local indicates that the openstack deployment will be
to the local host. Remote means that the deployment is
on remote hosts.
"""
def take_action(self, parsed_args):
try:
mode = CLIENT.get_deploy_mode()
return mode
except CommandError as e:
raise e
except Exception:
raise Exception(traceback.format_exc())

View File

@ -35,6 +35,7 @@ kolla.cli =
deploy = kolla_cli.commands.kolla_action:Deploy
dump = kolla_cli.commands.support:Dump
genconfig = kolla_cli.commands.kolla_action:Genconfig
getdeploy = kolla_cli.commands.mode:Getdeploy
group_add = kolla_cli.commands.group:GroupAdd
group_addhost = kolla_cli.commands.group:GroupAddhost
group_listhosts = kolla_cli.commands.group:GroupListhosts