Fix upload tool
This commit is contained in:
parent
a1417b10ae
commit
264fef44f6
@ -253,7 +253,7 @@ class CliResolver(object):
|
||||
class EnvResolver(DynamicResolver):
|
||||
|
||||
def get(self, section, option):
|
||||
return self._resolve_value(section, option, self._get_bashed(section, option))
|
||||
return self._get_bashed(section, option)
|
||||
|
||||
def _getdefaulted(self, section, option, default_value):
|
||||
val = self.get(section, option)
|
||||
@ -273,6 +273,7 @@ class EnvResolver(DynamicResolver):
|
||||
if not def_val and not env_key:
|
||||
msg = "Invalid bash-like value %r" % (value)
|
||||
raise excp.BadParamException(msg)
|
||||
LOG.debug("Looking for that value in environment variable: %r", env_key)
|
||||
env_value = env.get_key(env_key)
|
||||
if env_value is None:
|
||||
LOG.debug("Extracting value from config provided default value %r" % (def_val))
|
||||
|
@ -104,7 +104,7 @@ class PasswordGenerator(object):
|
||||
for lookup in self.lookups:
|
||||
LOG.debug("Looking up password using instance %s", lookup)
|
||||
password = lookup.get_password(option, prompt_text=prompt_text, length=length)
|
||||
if len(password):
|
||||
if password is not None and len(password):
|
||||
break
|
||||
|
||||
# Update via set through to the config
|
||||
|
@ -156,8 +156,11 @@ def execute(*cmd, **kwargs):
|
||||
|
||||
if not run_as_root:
|
||||
(user_uid, user_gid) = get_suids()
|
||||
LOG.audit("Running as (user=%s, group=%s)", user_uid, user_gid)
|
||||
demoter = demoter_functor(user_uid=user_uid, user_gid=user_gid)
|
||||
if user_uid is None or user_gid is None:
|
||||
pass
|
||||
else:
|
||||
LOG.audit("Running as (user=%s, group=%s)", user_uid, user_gid)
|
||||
demoter = demoter_functor(user_uid=user_uid, user_gid=user_gid)
|
||||
else:
|
||||
LOG.audit("Running as (user=%s, group=%s)", ROOT_USER_UID, ROOT_USER_UID)
|
||||
|
||||
|
@ -13,13 +13,35 @@ if os.path.exists(os.path.join(possible_topdir,
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from devstack import log as logging
|
||||
from devstack import utils
|
||||
from devstack import cfg
|
||||
from devstack import log as logging
|
||||
from devstack import passwords
|
||||
from devstack import settings
|
||||
from devstack import shell as sh
|
||||
from devstack import utils
|
||||
|
||||
from devstack.image import uploader
|
||||
|
||||
|
||||
def find_config():
|
||||
"""
|
||||
Finds the stack configuration file.
|
||||
|
||||
Arguments:
|
||||
args: command line args
|
||||
Returns: the file location or None if not found
|
||||
"""
|
||||
|
||||
locs = []
|
||||
locs.append(settings.STACK_CONFIG_LOCATION)
|
||||
locs.append(sh.joinpths("/etc", "devstack", "stack.ini"))
|
||||
locs.append(sh.joinpths(settings.STACK_CONFIG_DIR, "stack.ini"))
|
||||
locs.append(sh.joinpths("conf", "stack.ini"))
|
||||
for path in locs:
|
||||
if sh.isfile(path):
|
||||
return path
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
@ -31,10 +53,14 @@ if __name__ == "__main__":
|
||||
(options, args) = parser.parse_args()
|
||||
uris = options.uris or list()
|
||||
uri_sep = ",".join(uris)
|
||||
logging.setupLogging(logging.DEBUG)
|
||||
config = cfg.IgnoreMissingConfigParser()
|
||||
config.add_section('img')
|
||||
config.set('img', 'image_urls', uri_sep)
|
||||
logging.setupLogging(logging.INFO)
|
||||
base_config = cfg.IgnoreMissingConfigParser()
|
||||
stack_config = find_config()
|
||||
if stack_config:
|
||||
base_config.read([stack_config])
|
||||
base_config.set('img', 'image_urls', uri_sep)
|
||||
config = cfg.ProxyConfig()
|
||||
config.add_read_resolver(cfg.EnvResolver(base_config))
|
||||
pw_gen = passwords.PasswordGenerator(config)
|
||||
uploader = uploader.Service(config, pw_gen)
|
||||
uploader.install()
|
||||
|
Loading…
x
Reference in New Issue
Block a user