Change slightly to ssh-keyfile and TODOs
ssh-keyfile string templat is moved to userdata.sh, and userdata.sh is renamed to userdata.sh.template Change-Id: I704192cafe210c90c829c83af6b219786996dad0
This commit is contained in:
parent
72d5811bb9
commit
307400e5c1
|
@ -16,5 +16,10 @@ sudo sed -i -e 's/sleep\ 20/sleep\ 1/g' -e 's/sleep\ 40/sleep\ 1/g' \
|
||||||
-e 's/sleep\ 59/sleep\ 1/g' /etc/init/failsafe.conf
|
-e 's/sleep\ 59/sleep\ 1/g' /etc/init/failsafe.conf
|
||||||
sudo sed -i 's/long=120/long=20/g' /etc/init/cloud-init-nonet.conf
|
sudo sed -i 's/long=120/long=20/g' /etc/init/cloud-init-nonet.conf
|
||||||
|
|
||||||
|
# template_str, two args are (user, ssh_keycontent)
|
||||||
|
cat >> /home/%s/.ssh/authorized_keys <<EOF
|
||||||
|
%s
|
||||||
|
EOF
|
||||||
|
|
||||||
# create a folder to indicate userdata done
|
# create a folder to indicate userdata done
|
||||||
sudo mkdir -p /etc/inception/
|
sudo mkdir -p /etc/inception/
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
- Networks:
|
TODOS
|
||||||
|
|
||||||
|
Networks:
|
||||||
(use /24 address for now (faster OpenStack deployment), increase to /16 later)
|
(use /24 address for now (faster OpenStack deployment), increase to /16 later)
|
||||||
|
|
||||||
eth0, management: inherent interface on each rVM
|
eth0, management: inherent interface on each rVM
|
||||||
|
@ -16,7 +17,7 @@ rVMs eth1 IPs
|
||||||
[prefix]-worker-1, 10.251.1.1
|
[prefix]-worker-1, 10.251.1.1
|
||||||
[prefix]-worker-2(s), 10.251.1.2 [ - 10.251.255.254] # maximum ~65000
|
[prefix]-worker-2(s), 10.251.1.2 [ - 10.251.255.254] # maximum ~65000
|
||||||
|
|
||||||
webui: end-user input: (1) # of workers (default 2), (2) ssh_public_key
|
WebUI: Horizon-based
|
||||||
|
|
||||||
templatize all templatable configurations (environments, roles, etc), put the
|
templatize all templatable configurations (environments, roles, etc), put the
|
||||||
rest (sensitive data) in a private configuration file specific to each
|
rest (sensitive data) in a private configuration file specific to each
|
||||||
|
@ -51,6 +52,7 @@ class Orchestrator(object):
|
||||||
chef_repo,
|
chef_repo,
|
||||||
chef_repo_branch,
|
chef_repo_branch,
|
||||||
parallel,
|
parallel,
|
||||||
|
ssh_keyfile=None,
|
||||||
user='ubuntu',
|
user='ubuntu',
|
||||||
image='8e446e6a-3ea4-4908-bd12-4d0e691f37f7',
|
image='8e446e6a-3ea4-4908-bd12-4d0e691f37f7',
|
||||||
flavor=4,
|
flavor=4,
|
||||||
|
@ -59,10 +61,9 @@ class Orchestrator(object):
|
||||||
security_groups=('default', 'ssh'),
|
security_groups=('default', 'ssh'),
|
||||||
src_dir='../bin/',
|
src_dir='../bin/',
|
||||||
dst_dir='/home/ubuntu/',
|
dst_dir='/home/ubuntu/',
|
||||||
userdata='userdata.sh',
|
userdata='userdata.sh.template',
|
||||||
timeout=999999,
|
timeout=999999,
|
||||||
poll_interval=5,
|
poll_interval=5):
|
||||||
ssh_keyfile=None):
|
|
||||||
"""
|
"""
|
||||||
@param prefix: unique name as prefix
|
@param prefix: unique name as prefix
|
||||||
@param num_workers: how many worker nodes you'd like
|
@param num_workers: how many worker nodes you'd like
|
||||||
|
@ -70,6 +71,7 @@ class Orchestrator(object):
|
||||||
@param chef_repo_branch: which branch to use in repo
|
@param chef_repo_branch: which branch to use in repo
|
||||||
@param parallel: whether run functions in parallel (via threads, for
|
@param parallel: whether run functions in parallel (via threads, for
|
||||||
accelerating) or sequential
|
accelerating) or sequential
|
||||||
|
@param ssh_keyfile: extra ssh public key to login user account
|
||||||
@param user: username (with root permission) for all servers
|
@param user: username (with root permission) for all servers
|
||||||
@param image: default u1204-130531-gv
|
@param image: default u1204-130531-gv
|
||||||
@param flavor: default large
|
@param flavor: default large
|
||||||
|
@ -85,7 +87,6 @@ class Orchestrator(object):
|
||||||
@param timeout: sleep time (s) for servers to be launched
|
@param timeout: sleep time (s) for servers to be launched
|
||||||
@param poll_interval: every this time poll to check whether a server
|
@param poll_interval: every this time poll to check whether a server
|
||||||
has finished launching, i.e., ssh-able + userdata done
|
has finished launching, i.e., ssh-able + userdata done
|
||||||
@param ssh_keyfile: extra ssh public key to login ubuntu account
|
|
||||||
"""
|
"""
|
||||||
## check args
|
## check args
|
||||||
if num_workers > 5:
|
if num_workers > 5:
|
||||||
|
@ -109,17 +110,12 @@ class Orchestrator(object):
|
||||||
self.dst_dir = os.path.abspath(dst_dir)
|
self.dst_dir = os.path.abspath(dst_dir)
|
||||||
with open(os.path.join(self.src_dir, userdata), 'r') as fin:
|
with open(os.path.join(self.src_dir, userdata), 'r') as fin:
|
||||||
self.userdata = fin.read()
|
self.userdata = fin.read()
|
||||||
inject_script = ""
|
# Inject the extra ssh public key if any
|
||||||
if ssh_keyfile:
|
ssh_keycontent = ''
|
||||||
# Inject the extra ssh public key
|
if ssh_keyfile:
|
||||||
with open(ssh_keyfile, "r") as keyfile:
|
with open(ssh_keyfile, 'r') as fin:
|
||||||
key_content = keyfile.read()
|
ssh_keycontent = fin.read()
|
||||||
inject_script = """
|
self.userdata = self.userdata % (user, ssh_keycontent)
|
||||||
cat >> /home/%s/.ssh/authorized_keys < EOF
|
|
||||||
%s
|
|
||||||
EOF
|
|
||||||
""" % (user, key_content)
|
|
||||||
self.userdata += inject_script
|
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.poll_interval = poll_interval
|
self.poll_interval = poll_interval
|
||||||
# scripts to run on chefserver, execute one by one (sequence matters)
|
# scripts to run on chefserver, execute one by one (sequence matters)
|
||||||
|
@ -502,12 +498,14 @@ def main():
|
||||||
"""
|
"""
|
||||||
program starting point
|
program starting point
|
||||||
"""
|
"""
|
||||||
|
# default argument values
|
||||||
shell = False
|
shell = False
|
||||||
atomic = False
|
atomic = False
|
||||||
cleanup = False
|
cleanup = False
|
||||||
chef_repo = "git://github.com/maoy/inception-chef-repo.git"
|
chef_repo = "git://github.com/maoy/inception-chef-repo.git"
|
||||||
chef_repo_branch = "master"
|
chef_repo_branch = "master"
|
||||||
parallel = False
|
parallel = False
|
||||||
|
ssh_keyfile = None
|
||||||
try:
|
try:
|
||||||
optlist, _ = getopt.getopt(sys.argv[1:], 'p:n:',
|
optlist, _ = getopt.getopt(sys.argv[1:], 'p:n:',
|
||||||
["shell", "atomic", "cleanup", "parallel",
|
["shell", "atomic", "cleanup", "parallel",
|
||||||
|
@ -528,14 +526,14 @@ def main():
|
||||||
chef_repo_branch = optdict["--chef-repo-branch"]
|
chef_repo_branch = optdict["--chef-repo-branch"]
|
||||||
if "--parallel" in optdict:
|
if "--parallel" in optdict:
|
||||||
parallel = True
|
parallel = True
|
||||||
ssh_keyfile = optdict.get("--ssh-keyfile", None)
|
if "--ssh-keyfile" in optdict:
|
||||||
|
ssh_keyfile = optdict["--ssh-keyfile"]
|
||||||
except Exception:
|
except Exception:
|
||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
usage()
|
usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
orchestrator = Orchestrator(prefix, num_workers, chef_repo,
|
orchestrator = Orchestrator(prefix, num_workers, chef_repo,
|
||||||
chef_repo_branch, parallel,
|
chef_repo_branch, parallel, ssh_keyfile)
|
||||||
ssh_keyfile=ssh_keyfile)
|
|
||||||
if shell:
|
if shell:
|
||||||
# give me a ipython shell
|
# give me a ipython shell
|
||||||
IPython.embed()
|
IPython.embed()
|
||||||
|
|
Loading…
Reference in New Issue