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