fixed some bumpy case issues brought up in review. changed get_client_home get_client_etc to get_kollacli_home and get_kollacli_etc

This commit is contained in:
Borne Mace 2015-08-18 17:26:44 -07:00
parent b25319fa84
commit 1f610661aa
4 changed files with 26 additions and 23 deletions

View File

@ -246,7 +246,7 @@ class Inventory(object):
@staticmethod
def load():
"""load the inventory from a pickle file"""
inventory_path = os.path.join(utils.get_client_etc(), INVENTORY_PATH)
inventory_path = os.path.join(utils.get_kollacli_etc(), INVENTORY_PATH)
try:
if os.path.exists(inventory_path):
with open(inventory_path, 'rb') as inv_file:
@ -267,7 +267,7 @@ class Inventory(object):
@staticmethod
def save(inventory):
"""Save the inventory in a pickle file"""
inventory_path = os.path.join(utils.get_client_etc(), INVENTORY_PATH)
inventory_path = os.path.join(utils.get_kollacli_etc(), INVENTORY_PATH)
try:
# the file handle returned from mkstemp must be closed or else
# if this is called many times you will have an unpleasant

View File

@ -18,6 +18,7 @@ import subprocess
from kollacli.i18n import _
from kollacli.utils import get_kolla_etc
from kollacli.utils import get_kolla_home
from kollacli.utils import get_kollacli_home
from cliff.command import Command
@ -28,17 +29,19 @@ class Deploy(Command):
log = logging.getLogger(__name__)
def take_action(self, parsed_args):
kollaHome = get_kolla_home()
kollaEtc = get_kolla_etc()
self.log.info(kollaHome)
commandString = 'ansible-playbook '
inventoryString = '-i /home/bmace/devel/openstack-kollaclient/kollacli/ansible/json_generator.py '
defaultsString = '-e @' + os.path.join(kollaEtc, 'defaults.yml')
globalsString = ' -e @' + os.path.join(kollaEtc, 'globals.yml')
passwordsString = ' -e @' + os.path.join(kollaEtc, 'passwords.yml')
siteString = ' ' + os.path.join(kollaHome, 'ansible/site.yml')
cmd = commandString + inventoryString + defaultsString + globalsString
cmd = cmd + passwordsString + siteString
kollacli_home = get_kollacli_home()
kolla_home = get_kolla_home()
kolla_etc = get_kolla_etc()
command_string = 'ansible-playbook '
inventory_string = '-i ' + os.path.join(kollacli_home,
'kollacli/ansible',
'json_generator.py ')
default_string = '-e @' + os.path.join(kolla_etc, 'defaults.yml')
globals_string= ' -e @' + os.path.join(kolla_etc, 'globals.yml')
passwords_string = ' -e @' + os.path.join(kolla_etc, 'passwords.yml')
site_string = ' ' + os.path.join(kolla_home, 'ansible/site.yml')
cmd = command_string + inventory_string + default_string + globals_string
cmd = cmd + passwords_string + site_string
self.log.debug('cmd:' + cmd)
output, error = subprocess.Popen(cmd.split(' '),
stdout=subprocess.PIPE,

View File

@ -23,20 +23,20 @@ def get_kolla_etc():
return os.environ.get("KOLLA_ETC", "/etc/kolla/")
def get_client_home():
return os.environ.get("KOLLA_CLIENT_HOME", "/opt/kollacli/")
def get_kollacli_home():
return os.environ.get("KOLLA_CLI_HOME", "/opt/kollacli/")
def get_client_etc():
return os.environ.get("KOLLA_CLIENT_ETC", "/etc/kolla/kollacli/")
def get_kollacli_etc():
return os.environ.get("KOLLA_CLI_ETC", "/etc/kolla/kollacli/")
def get_admin_user():
return os.environ.get("KOLLA_ADMIN_USER", "kolla")
return os.environ.get("KOLLA_CLI_ADMIN_USER", "kolla")
def get_pk_file():
return os.environ.get("KOLLA_CLIENT_PKPATH",
return os.environ.get("KOLLA_CLI_PKPATH",
"/etc/kolla/kollacli/etc/id_rsa")
@ -52,7 +52,7 @@ def get_pk_bits():
def load_etc_yaml(fileName):
contents = {}
try:
with open(get_client_etc() + fileName, 'r') as f:
with open(get_kollacli_etc() + fileName, 'r') as f:
contents = yaml.load(f)
except Exception:
# TODO(bmace) if file doesn't exist on a load we don't
@ -62,5 +62,5 @@ def load_etc_yaml(fileName):
def save_etc_yaml(fileName, contents):
with open(get_client_etc() + fileName, 'w') as f:
with open(get_kollacli_etc() + fileName, 'w') as f:
f.write(yaml.dump(contents))

View File

@ -75,13 +75,13 @@ class KollaCliTest(testtools.TestCase):
# PRIVATE FUNCTIONS ----------------------------------------------------
def _setup_env_var(self):
etc_path = utils.get_client_etc()
etc_path = utils.get_kollacli_etc()
if not etc_path.endswith(TEST_SUFFIX):
etc_path = os.path.join(etc_path, TEST_SUFFIX)
os.environ[ENV_ETC] = etc_path
def _restore_env_var(self):
etc_path = utils.get_client_etc()
etc_path = utils.get_kollacli_etc()
if etc_path.endswith(TEST_SUFFIX):
etc_path = etc_path.rsplit('/', 1)[0]
os.environ[ENV_ETC] = etc_path