Moved util programs to utils...
This commit is contained in:
@@ -83,29 +83,13 @@ def parse():
|
|||||||
default=True)
|
default=True)
|
||||||
parser.add_option_group(stop_un_group)
|
parser.add_option_group(stop_un_group)
|
||||||
|
|
||||||
misc_group = OptionGroup(parser, "Miscellaneous options")
|
|
||||||
misc_group.add_option("--list-deps",
|
|
||||||
action="store_true",
|
|
||||||
dest="list_deps",
|
|
||||||
help="show dependencies of COMPONENT (default: %default)",
|
|
||||||
default=False)
|
|
||||||
misc_group.add_option("--describe-components",
|
|
||||||
action="store_true",
|
|
||||||
dest="describe_comp",
|
|
||||||
help="describe COMPONENT (default: %default)",
|
|
||||||
default=False)
|
|
||||||
parser.add_option_group(misc_group)
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
#extract only what we care about
|
#extract only what we care about
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
output = dict()
|
output = dict()
|
||||||
output['components'] = options.component
|
output['components'] = options.component
|
||||||
output['dir'] = options.dir
|
output['dir'] = options.dir
|
||||||
output['ref_components'] = options.r_component
|
output['ref_components'] = options.r_component
|
||||||
output['action'] = options.action
|
output['action'] = options.action
|
||||||
output['list_deps'] = options.list_deps
|
|
||||||
output['describe_comp'] = options.describe_comp
|
|
||||||
output['force'] = options.force
|
output['force'] = options.force
|
||||||
if options.ensure_deps:
|
if options.ensure_deps:
|
||||||
output['ignore_deps'] = False
|
output['ignore_deps'] = False
|
||||||
|
@@ -36,7 +36,7 @@ done
|
|||||||
|
|
||||||
function run_pep8 {
|
function run_pep8 {
|
||||||
echo "Running pep8 ..."
|
echo "Running pep8 ..."
|
||||||
srcfiles=`find devstack -type f | grep "py\$"`
|
srcfiles=`find devstack utils -type f | grep "py\$"`
|
||||||
srcfiles+=" stack"
|
srcfiles+=" stack"
|
||||||
pep_ignores="E202,E501"
|
pep_ignores="E202,E501"
|
||||||
tee_fn="pep8.log"
|
tee_fn="pep8.log"
|
||||||
@@ -53,7 +53,7 @@ function run_pep8 {
|
|||||||
|
|
||||||
function run_pylint {
|
function run_pylint {
|
||||||
echo "Running pylint ..."
|
echo "Running pylint ..."
|
||||||
srcfiles=`find devstack -type f | grep "py\$"`
|
srcfiles=`find devstack utils -type f | grep "py\$"`
|
||||||
srcfiles+=" stack"
|
srcfiles+=" stack"
|
||||||
tee_fn="pylint.log"
|
tee_fn="pylint.log"
|
||||||
pylint_opts="--rcfile=$pylintrc_fn"
|
pylint_opts="--rcfile=$pylintrc_fn"
|
||||||
|
15
stack
15
stack
@@ -26,7 +26,7 @@ import traceback
|
|||||||
#this needs to happen immediately (or thats what it seems)
|
#this needs to happen immediately (or thats what it seems)
|
||||||
log_fn = os.getenv('LOG_FILE')
|
log_fn = os.getenv('LOG_FILE')
|
||||||
if(log_fn == None):
|
if(log_fn == None):
|
||||||
log_fn = os.path.join("conf", 'logging.ini')
|
log_fn = os.path.normpath(os.path.join("conf", 'logging.ini'))
|
||||||
logging.config.fileConfig(log_fn)
|
logging.config.fileConfig(log_fn)
|
||||||
|
|
||||||
#this handles our option parsing
|
#this handles our option parsing
|
||||||
@@ -35,23 +35,12 @@ from devstack import utils
|
|||||||
|
|
||||||
#these are the program runtimes that actually do the running
|
#these are the program runtimes that actually do the running
|
||||||
from devstack.progs import actions
|
from devstack.progs import actions
|
||||||
from devstack.progs import describe
|
|
||||||
from devstack.progs import deps
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
#parse and get it done!
|
|
||||||
args = opts.parse()
|
args = opts.parse()
|
||||||
#figure out what to do
|
|
||||||
module = None
|
|
||||||
if args.get('describe_comp'):
|
|
||||||
module = describe
|
|
||||||
elif args.get('list_deps'):
|
|
||||||
module = deps
|
|
||||||
else:
|
|
||||||
module = actions
|
|
||||||
try:
|
try:
|
||||||
ran_ok = module.run(args)
|
ran_ok = actions.run(args)
|
||||||
if not ran_ok:
|
if not ran_ok:
|
||||||
me = utils.color_text((os.path.basename(sys.argv[0])), "red", True)
|
me = utils.color_text((os.path.basename(sys.argv[0])), "red", True)
|
||||||
me += " " + utils.color_text('--help', 'red')
|
me += " " + utils.color_text('--help', 'red')
|
||||||
|
@@ -14,6 +14,22 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import optparse
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
|
os.pardir,
|
||||||
|
os.pardir))
|
||||||
|
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||||
|
|
||||||
|
log_fn = os.getenv('LOG_FILE')
|
||||||
|
if(log_fn == None):
|
||||||
|
log_fn = os.path.normpath(os.path.join("conf", 'logging.ini'))
|
||||||
|
logging.config.fileConfig(log_fn)
|
||||||
|
|
||||||
from devstack import settings
|
from devstack import settings
|
||||||
from devstack import utils
|
from devstack import utils
|
||||||
|
|
||||||
@@ -62,3 +78,34 @@ def run(args):
|
|||||||
(rep, maxlen) = utils.welcome(PROG_NAME)
|
(rep, maxlen) = utils.welcome(PROG_NAME)
|
||||||
_run_dep_comps(args, rep, maxlen)
|
_run_dep_comps(args, rep, maxlen)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = optparse.OptionParser()
|
||||||
|
known_components = sorted(settings.COMPONENT_NAMES)
|
||||||
|
components = "(" + ", ".join(known_components) + ")"
|
||||||
|
parser.add_option("-c", "--component",
|
||||||
|
action="append",
|
||||||
|
dest="component",
|
||||||
|
help="openstack component, ie %s" % (components))
|
||||||
|
known_actions = sorted(settings.ACTIONS)
|
||||||
|
actions = "(" + ", ".join(known_actions) + ")"
|
||||||
|
parser.add_option("-a", "--action",
|
||||||
|
action="store",
|
||||||
|
type="string",
|
||||||
|
dest="action",
|
||||||
|
metavar="ACTION",
|
||||||
|
help="action to perform, ie %s" % (actions))
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
opts = dict()
|
||||||
|
opts['components'] = options.component
|
||||||
|
opts['action'] = options.action
|
||||||
|
utils.welcome(PROG_NAME)
|
||||||
|
result = run(opts)
|
||||||
|
if not result:
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
@@ -14,7 +14,23 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import optparse
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
|
os.pardir,
|
||||||
|
os.pardir))
|
||||||
|
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||||
|
|
||||||
|
log_fn = os.getenv('LOG_FILE')
|
||||||
|
if(log_fn == None):
|
||||||
|
log_fn = os.path.normpath(os.path.join("conf", 'logging.ini'))
|
||||||
|
logging.config.fileConfig(log_fn)
|
||||||
|
|
||||||
|
|
||||||
from devstack import settings
|
from devstack import settings
|
||||||
from devstack import utils
|
from devstack import utils
|
||||||
@@ -74,3 +90,24 @@ def run(args):
|
|||||||
(rep, maxlen) = utils.welcome(PROG_NAME)
|
(rep, maxlen) = utils.welcome(PROG_NAME)
|
||||||
_run_describe_comps(args, rep, maxlen)
|
_run_describe_comps(args, rep, maxlen)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = optparse.OptionParser()
|
||||||
|
known_components = sorted(settings.COMPONENT_NAMES)
|
||||||
|
components = "(" + ", ".join(known_components) + ")"
|
||||||
|
parser.add_option("-c", "--component",
|
||||||
|
action="append",
|
||||||
|
dest="component",
|
||||||
|
help="openstack component, ie %s" % (components))
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
opts = dict()
|
||||||
|
opts['components'] = options.component
|
||||||
|
result = run(opts)
|
||||||
|
if not result:
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
77
utils/env_gen.py
Normal file
77
utils/env_gen.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import optparse
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
|
os.pardir,
|
||||||
|
os.pardir))
|
||||||
|
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||||
|
|
||||||
|
log_fn = os.getenv('LOG_FILE')
|
||||||
|
if(log_fn == None):
|
||||||
|
log_fn = os.path.normpath(os.path.join("conf", 'logging.ini'))
|
||||||
|
logging.config.fileConfig(log_fn)
|
||||||
|
|
||||||
|
from devstack import cfg
|
||||||
|
from devstack import utils
|
||||||
|
from devstack.progs import common
|
||||||
|
|
||||||
|
|
||||||
|
PROG_NAME = "Env. file generator"
|
||||||
|
|
||||||
|
CFG_MAKE = {
|
||||||
|
'ADMIN_PASSWORD': ('passwords', 'horizon_keystone_admin'),
|
||||||
|
'MYSQL_PASSWORD': ('passwords', 'sql'),
|
||||||
|
'RABBIT_PASSWORD': ('passwords', 'rabbit'),
|
||||||
|
'SERVICE_TOKEN': ('passwords', 'service_token'),
|
||||||
|
'FLAT_INTERFACE': ('nova', 'flat_interface'),
|
||||||
|
}
|
||||||
|
|
||||||
|
DEF_FN = 'localrc'
|
||||||
|
|
||||||
|
|
||||||
|
def write_line(text, fh):
|
||||||
|
fh.write(text)
|
||||||
|
fh.write(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
opts = optparse.OptionParser()
|
||||||
|
opts.add_option("-o", "--output", dest="filename",
|
||||||
|
help="write output to FILE", metavar="FILE")
|
||||||
|
(options, args) = opts.parse_args()
|
||||||
|
fn = options.filename
|
||||||
|
if not fn:
|
||||||
|
fn = DEF_FN
|
||||||
|
utils.welcome(PROG_NAME)
|
||||||
|
cfg = common.get_config()
|
||||||
|
with open(fn, "w") as fh:
|
||||||
|
for (out_name, cfg_data) in CFG_MAKE.items():
|
||||||
|
section = cfg_data[0]
|
||||||
|
key = cfg_data[1]
|
||||||
|
value = cfg.get(section, key)
|
||||||
|
write_line("%s=%s" % (out_name, value), fh)
|
||||||
|
print("Check file \"%s\" for your environment configuration." % (os.path.normpath(fn)))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
@@ -1,7 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
me = os.path.basename(sys.argv[0])
|
me = os.path.basename(sys.argv[0])
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
|
Reference in New Issue
Block a user