Incoporate oslo.config facilities in Inception
Convert Inception code to use a configuration file and command line options as processed by oslo.config. + orchestrator modified to use oslo.config for options + sample config file introduced + dependency on oslo.config added to setup.py + version string moved from setup.py to module init for ready access for --version and others Implements: blueprint Inception Configuration Blueprint Change-Id: I984700867d8ddf5ee1602cc4ed6608f36a38a6be
This commit is contained in:
parent
53e6f000dc
commit
03ed5b7e9f
|
@ -0,0 +1,48 @@
|
||||||
|
# inception.conf
|
||||||
|
#
|
||||||
|
# To use this configuration, add one of the following options to your command
|
||||||
|
# line:
|
||||||
|
#
|
||||||
|
# --config-file <d>/inception.conf
|
||||||
|
# or
|
||||||
|
# --config-dir <d>
|
||||||
|
#
|
||||||
|
# where <d> is the path to the directory containing this file
|
||||||
|
|
||||||
|
[DEFAULT]
|
||||||
|
|
||||||
|
# user - login id with sudo for image used for nodes in Inception Cloud
|
||||||
|
user = ubuntu
|
||||||
|
|
||||||
|
# image - id of image used to construct nodes in Inception Cloud
|
||||||
|
image = f3d62d5b-a76b-4997-a579-ff946a606132
|
||||||
|
|
||||||
|
# flavor - id of machine flavor used for nodes in Inception Cloud (3 = med)
|
||||||
|
flavor = 3
|
||||||
|
|
||||||
|
# gateway_flavor - id of machine flavor used to construct GW in Inception Cloud
|
||||||
|
gateway_flavor = 1
|
||||||
|
|
||||||
|
# key_name - name of PK pair for node access
|
||||||
|
key_name = <your_key_name_here>
|
||||||
|
|
||||||
|
# security_groups - firewall rules
|
||||||
|
security_groups = default, ssh
|
||||||
|
|
||||||
|
# src_dir - source location of various chef-related setup scripts on client
|
||||||
|
src_dir = ../bin/
|
||||||
|
|
||||||
|
# dst_dir - absolute destination path for chef-related setup scripts on nodes
|
||||||
|
dst_dir = /home/ubuntu/
|
||||||
|
|
||||||
|
# userdata - bash script run by cloud-init in late boot stage (rc.local-like)
|
||||||
|
userdata = userdata.sh.template
|
||||||
|
|
||||||
|
# timeout - maximum time to wait for all servers to be reachable (seconds)
|
||||||
|
timeout = 999999
|
||||||
|
|
||||||
|
# poll_interval - interval between readiness [ssh+userdata] polls (seconds)
|
||||||
|
poll_interval = 5
|
||||||
|
|
||||||
|
# pool - name of pool for floating IP addresses
|
||||||
|
pool = research
|
|
@ -0,0 +1 @@
|
||||||
|
__version__ = '0.0.1'
|
|
@ -38,9 +38,90 @@ import traceback
|
||||||
|
|
||||||
import IPython
|
import IPython
|
||||||
from novaclient.v1_1.client import Client
|
from novaclient.v1_1.client import Client
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from inception import __version__
|
||||||
from inception.utils import cmd
|
from inception.utils import cmd
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
inception_opts = [
|
||||||
|
cfg.StrOpt('prefix',
|
||||||
|
default=None,
|
||||||
|
metavar='PREFIX',
|
||||||
|
required=True,
|
||||||
|
short='p',
|
||||||
|
help='(unique) prefix for node names (no hyphens allowed)'),
|
||||||
|
cfg.IntOpt('num_workers',
|
||||||
|
default=2,
|
||||||
|
metavar='NUM',
|
||||||
|
short='n',
|
||||||
|
help='number of worker nodes to create'),
|
||||||
|
cfg.BoolOpt('shell',
|
||||||
|
default=False,
|
||||||
|
help='initialize, then drop to embedded IPython shell'),
|
||||||
|
cfg.BoolOpt('atomic',
|
||||||
|
default=False,
|
||||||
|
help='on error, run as if --cleanup was specified'),
|
||||||
|
cfg.BoolOpt('cleanup',
|
||||||
|
default=False,
|
||||||
|
help='take down the inception cloud'),
|
||||||
|
cfg.BoolOpt('parallel',
|
||||||
|
default=False,
|
||||||
|
help='execute chef-related setup tasks in parallel'),
|
||||||
|
cfg.StrOpt('chef_repo',
|
||||||
|
default='git://github.com/maoy/inception-chef-repo.git',
|
||||||
|
metavar='URL',
|
||||||
|
help='URL of Chef repo'),
|
||||||
|
cfg.StrOpt('chef_repo_branch',
|
||||||
|
default='master',
|
||||||
|
metavar='BRANCH',
|
||||||
|
help='name of branch of Chef repo to use'),
|
||||||
|
cfg.StrOpt('ssh_keyfile',
|
||||||
|
default=None,
|
||||||
|
metavar='PATH',
|
||||||
|
help='path of additional keyfile for node access via ssh'),
|
||||||
|
cfg.StrOpt('pool',
|
||||||
|
default='research',
|
||||||
|
help='name of pool for floating IP addresses'),
|
||||||
|
cfg.StrOpt('user',
|
||||||
|
default='ubuntu',
|
||||||
|
help=''),
|
||||||
|
cfg.StrOpt('image',
|
||||||
|
default='f3d62d5b-a76b-4997-a579-ff946a606132',
|
||||||
|
help=''),
|
||||||
|
cfg.IntOpt('flavor',
|
||||||
|
default=3,
|
||||||
|
help='id of machine flavor used for nodes'),
|
||||||
|
cfg.IntOpt('gateway_flavor',
|
||||||
|
default=1,
|
||||||
|
help='id of machine flavor used for gateway'),
|
||||||
|
cfg.StrOpt('key_name',
|
||||||
|
default='<your_key_name_here>',
|
||||||
|
help='name of key for node access via ssh'),
|
||||||
|
cfg.ListOpt('security_groups',
|
||||||
|
default=['default', 'ssh'],
|
||||||
|
help='list of security groups for nodes'),
|
||||||
|
cfg.StrOpt('src_dir',
|
||||||
|
default='../bin/',
|
||||||
|
help='path of setup script source dir on client'),
|
||||||
|
cfg.StrOpt('dst_dir',
|
||||||
|
default='/home/ubuntu/',
|
||||||
|
help='path of setup script destination dir on nodes'),
|
||||||
|
cfg.StrOpt('userdata',
|
||||||
|
default='userdata.sh.template',
|
||||||
|
help='template for user data script'),
|
||||||
|
cfg.IntOpt('timeout',
|
||||||
|
default=999999,
|
||||||
|
help='number of seconds for creation timeout'),
|
||||||
|
cfg.IntOpt('poll_interval',
|
||||||
|
default=5,
|
||||||
|
help='interval (in seconds) between readiness polls'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Register options
|
||||||
|
CONF.register_cli_opts(inception_opts)
|
||||||
|
|
||||||
|
|
||||||
class Orchestrator(object):
|
class Orchestrator(object):
|
||||||
"""
|
"""
|
||||||
|
@ -59,7 +140,7 @@ class Orchestrator(object):
|
||||||
image='f3d62d5b-a76b-4997-a579-ff946a606132',
|
image='f3d62d5b-a76b-4997-a579-ff946a606132',
|
||||||
flavor=3,
|
flavor=3,
|
||||||
gateway_flavor=1,
|
gateway_flavor=1,
|
||||||
key_name='shared',
|
key_name='<your_key_name_here>',
|
||||||
security_groups=('default', 'ssh'),
|
security_groups=('default', 'ssh'),
|
||||||
src_dir='../bin/',
|
src_dir='../bin/',
|
||||||
dst_dir='/home/ubuntu/',
|
dst_dir='/home/ubuntu/',
|
||||||
|
@ -508,63 +589,41 @@ def main():
|
||||||
"""
|
"""
|
||||||
program starting point
|
program starting point
|
||||||
"""
|
"""
|
||||||
# default argument values
|
|
||||||
shell = False
|
# Processes both config file and cmd line opts
|
||||||
atomic = False
|
|
||||||
cleanup = False
|
|
||||||
chef_repo = "git://github.com/maoy/inception-chef-repo.git"
|
|
||||||
chef_repo_branch = "master"
|
|
||||||
parallel = False
|
|
||||||
ssh_keyfile = None
|
|
||||||
pool = 'research'
|
|
||||||
try:
|
try:
|
||||||
optlist, _ = getopt.getopt(sys.argv[1:], 'p:n:',
|
CONF(args=sys.argv[1:], version="Inception: version %s" % __version__)
|
||||||
["shell", "atomic", "cleanup", "parallel",
|
except Exception, e:
|
||||||
"chef-repo=", "chef-repo-branch=",
|
print e
|
||||||
"ssh-keyfile=", 'pool='])
|
sys.exit(-2)
|
||||||
optdict = dict(optlist)
|
|
||||||
prefix = optdict['-p']
|
orchestrator = Orchestrator(CONF.prefix,
|
||||||
num_workers = int(optdict['-n'])
|
CONF.num_workers,
|
||||||
if "--shell" in optdict:
|
CONF.chef_repo,
|
||||||
shell = True
|
CONF.chef_repo_branch,
|
||||||
if "--atomic" in optdict:
|
CONF.parallel,
|
||||||
atomic = True
|
CONF.ssh_keyfile,
|
||||||
if "--cleanup" in optdict:
|
CONF.pool,
|
||||||
cleanup = True
|
CONF.user,
|
||||||
if "--chef-repo" in optdict:
|
CONF.image,
|
||||||
chef_repo = optdict["--chef-repo"]
|
CONF.flavor,
|
||||||
if "--chef-repo-branch" in optdict:
|
CONF.gateway_flavor,
|
||||||
chef_repo_branch = optdict["--chef-repo-branch"]
|
CONF.key_name,
|
||||||
if "--parallel" in optdict:
|
CONF.security_groups,
|
||||||
parallel = True
|
CONF.src_dir,
|
||||||
if "--ssh-keyfile" in optdict:
|
CONF.dst_dir,
|
||||||
ssh_keyfile = optdict["--ssh-keyfile"]
|
CONF.userdata,
|
||||||
if "--pool" in optdict:
|
CONF.timeout,
|
||||||
pool = optdict["--pool"]
|
CONF.poll_interval)
|
||||||
except Exception:
|
|
||||||
print traceback.format_exc()
|
if CONF.shell:
|
||||||
usage()
|
|
||||||
sys.exit(1)
|
|
||||||
orchestrator = Orchestrator(prefix, num_workers, chef_repo,
|
|
||||||
chef_repo_branch, parallel, ssh_keyfile, pool)
|
|
||||||
if shell:
|
|
||||||
# give me a ipython shell
|
# give me a ipython shell
|
||||||
IPython.embed()
|
IPython.embed()
|
||||||
return
|
return
|
||||||
if cleanup:
|
if CONF.cleanup:
|
||||||
orchestrator.cleanup()
|
orchestrator.cleanup()
|
||||||
else:
|
else:
|
||||||
orchestrator.start(atomic)
|
orchestrator.start(CONF.atomic)
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
print """
|
|
||||||
python %s -p <prefix> -n <num_workers> [--shell] [--atomic] [--cleanup]
|
|
||||||
[--parallel] [--chef-repo=git://github.com/maoy/inception-chef-repo.git]
|
|
||||||
[--chef-repo-branch=master] [--ssh-keyfile=/path/to/key] [--pool=nova]
|
|
||||||
|
|
||||||
Note: make sure OpenStack-related environment variables are defined.
|
|
||||||
""" % (__file__,)
|
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
7
setup.py
7
setup.py
|
@ -7,17 +7,20 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
version = '0.0.1'
|
|
||||||
|
# move version string out of setup so it is readily available to others
|
||||||
|
from inception import __version__
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='inception',
|
name='inception',
|
||||||
version=version,
|
version=__version__,
|
||||||
description="Inception: Towards a Nested Cloud Architecture",
|
description="Inception: Towards a Nested Cloud Architecture",
|
||||||
license="Apache 2.0",
|
license="Apache 2.0",
|
||||||
classifiers=["Programming Language :: Python"],
|
classifiers=["Programming Language :: Python"],
|
||||||
url='https://github.com/maoy/inception',
|
url='https://github.com/maoy/inception',
|
||||||
packages=["inception"],
|
packages=["inception"],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
"oslo.config>=1.1.1",
|
||||||
"python-novaclient>=2.13.0",
|
"python-novaclient>=2.13.0",
|
||||||
"IPython>=0.13.2",
|
"IPython>=0.13.2",
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue