Skip to content

Commit

Permalink
container and nutshell deploment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
schevalier committed Mar 19, 2014
1 parent 1989284 commit 83632f3
Show file tree
Hide file tree
Showing 24 changed files with 3,583 additions and 39 deletions.
1,013 changes: 1,013 additions & 0 deletions conpaas-services/scripts/create_vm/create-img-conpaas.sh

Large diffs are not rendered by default.

542 changes: 542 additions & 0 deletions conpaas-services/scripts/create_vm/create-img-nutshell.sh

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion conpaas-services/scripts/create_vm/create-img-script.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ filesize = 3072 #MB
optimize = true
#optimize = false

[NUTSHELL]

cloud = openstack

nutshell = true
container = true

hostname = nutshell
filename = nutshell.img
filesize = 6656


ubuntu_dist = precise
ubuntu_mirror = http://archive.ubuntu.com/ubuntu/

kvm_ubuntu_kernel_version = 3.5.0-41-generic

#have not tested which kernel is better for xen
xen_ubuntu_kernel_version = 3.5.0-41-generic




[SERVICES]

# Services that will be installed:
Expand Down Expand Up @@ -64,7 +87,11 @@ cds_service = false
# Identifies the files for each script

head_script = 000-head
general_scripts = 003-create-image 004-conpaas-core
image_script = 003-create-image
image_script_container = 003-create-image-container
image_script_nutshell = 003-create-image-nutshell
nutshell_config_scripts = 701-embed-container-image-nutshell 702-depend-nutshell 703-devstack-nutshell 704-conpaas-nutshell 705-config-container-nutshell
conpaas_core_script = 004-conpaas-core
php_service_script = 501-php
mysql_service_script = 502-mysql
galera_service_script = 502-galera
Expand All @@ -78,5 +105,8 @@ rm_script = 995-rm-unused-pkgs
user_script = 996-user
tail_script = 997-tail
opennebula_script = 998-opennebula
opennebula_script_nushell = 998-opennebula-nutshell
ec2_script = 998-ec2
ec2_script_nushell = 998-ec2-nutshell
resize_script=999-resize-image
resize_container_script=999-resize-image-container
134 changes: 96 additions & 38 deletions conpaas-services/scripts/create_vm/create-img-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ def error(error_msg):

config = get_cfg_file_handle()

container = config.get('NUTSHELL', 'container') == 'true'
nutshell = config.get('NUTSHELL', 'nutshell') == 'true'

output_filename = 'create-img-' + config.get('CUSTOMIZABLE', 'filename')[:-4] + '.sh'
if nutshell:
output_filename = 'create-img-' + config.get('NUTSHELL', 'filename')[:-4] + '.sh'

create_output_file()

# Write head script
Expand All @@ -99,17 +105,28 @@ def error(error_msg):

append_str_to_output('# The name and size of the image file '\
'that will be generated.\n')
append_str_to_output('FILENAME=' + config.get('CUSTOMIZABLE', 'filename') + '\n')
append_str_to_output('FILESIZE=' + config.get('CUSTOMIZABLE', 'filesize') + '\n\n')

if nutshell:
append_str_to_output('FILENAME=' + config.get('NUTSHELL','filename') + '\n')
append_str_to_output('CONT_FILENAME=' + config.get('CUSTOMIZABLE','filename') + '\n')
append_str_to_output('FILESIZE=' + config.get('NUTSHELL', 'filesize') + '\n\n')
append_str_to_output('HOST=' + config.get('NUTSHELL', 'hostname') + '\n')
append_str_to_output('DEBIAN_DIST=' + config.get('NUTSHELL', 'ubuntu_dist') + '\n')
append_str_to_output('DEBIAN_MIRROR=' + config.get('NUTSHELL', 'ubuntu_mirror') + '\n\n')
append_str_to_output('CREATE_CONT=' + config.get('NUTSHELL', 'container') + '\n\n')
container = False;
else:
append_str_to_output('FILENAME=' + config.get('CUSTOMIZABLE', 'filename') + '\n')
append_str_to_output('FILESIZE=' + config.get('CUSTOMIZABLE', 'filesize') + '\n\n')

append_str_to_output('# The Debian distribution that you would '\
append_str_to_output('# The Debian distribution that you would '\
'like to have installed (we recommend squeeze).\n')
append_str_to_output('DEBIAN_DIST=' + config.get('RECOMMENDED', 'debian_dist') + '\n')
append_str_to_output('DEBIAN_MIRROR=' + config.get('RECOMMENDED', 'debian_mirror') + '\n\n')
append_str_to_output('DEBIAN_DIST=' + config.get('RECOMMENDED', 'debian_dist') + '\n')
append_str_to_output('DEBIAN_MIRROR=' + config.get('RECOMMENDED', 'debian_mirror') + '\n\n')

append_str_to_output('# The architecture and kernel version for '\
append_str_to_output('# The architecture and kernel version for '\
'the OS that will be installed (please make\n')
append_str_to_output('# sure to modify the kernel version name accordingly if you modify the architecture).\n')
append_str_to_output('# sure to modify the kernel version name accordingly if you modify the architecture).\n')

optimize = config.get('CUSTOMIZABLE', 'optimize')

Expand All @@ -126,6 +143,10 @@ def error(error_msg):
hypervisor = 'xen'
else:
error('Unknown cloud "%s".' % cloud)

if container:
cloud = config.get('NUTSHELL', 'cloud')

append_str_to_output('CLOUD=' + cloud + '\n')

arch = config.get('RECOMMENDED', 'arch')
Expand All @@ -148,6 +169,14 @@ def error(error_msg):
kernel_version = 'linux-image-%s' % kernel_arch
else:
error('Unknown Debian distribution "%s".' % debian_dist)

if nutshell:
append_str_to_output('OPTIMIZE=' + config.get('CUSTOMIZABLE', 'optimize') + '\n')
if hypervisor == 'kvm':
kernel_version = config.get('NUTSHELL', 'kvm_ubuntu_kernel_version')
elif hypervisor == 'xen':
kernel_version = config.get('NUTSHELL', 'xen_ubuntu_kernel_version')

append_str_to_output('KERNEL=%s\n' % kernel_version)

append_str_to_output('\n\n')
Expand All @@ -157,49 +186,78 @@ def error(error_msg):
print 'Setting up image for %s, with services:' % hypervisor.upper(),

# Write general scripts
filenames = config.get('SCRIPT_FILE_NAMES', 'general_scripts')
for filename in filenames.split():
#filenames = config.get('SCRIPT_FILE_NAMES', 'general_scripts')
#for filename in filenames.split():
# append_file_to_output(root_dir + filename)

if nutshell:
filename = config.get('SCRIPT_FILE_NAMES', 'image_script_nutshell')
elif container:
filename = config.get('SCRIPT_FILE_NAMES', 'image_script_container')
else:
filename = config.get('SCRIPT_FILE_NAMES', 'image_script')

append_file_to_output(root_dir + filename)

if nutshell:
filenames = config.get('SCRIPT_FILE_NAMES', 'nutshell_config_scripts')
for filename in filenames.split():
append_str_to_output("#Section " + filename + "\n\n")
append_file_to_output(root_dir + filename)
else:

filename = config.get('SCRIPT_FILE_NAMES', 'conpaas_core_script')
append_file_to_output(root_dir + filename)

# Write service scripts
rm_script_args = ''
for servicename, should_include in config.items('SERVICES'):
if 'true' == should_include:
rm_script_args += ' --' + servicename[:-8]
filename = config.get('SCRIPT_FILE_NAMES', servicename + '_script')
# Write service scripts
rm_script_args = ''
for servicename, should_include in config.items('SERVICES'):
if 'true' == should_include:
rm_script_args += ' --' + servicename[:-8]
filename = config.get('SCRIPT_FILE_NAMES', servicename + '_script')
append_file_to_output(root_dir + filename)
print servicename.replace('_service', '').upper(),
print

if rm_script_args == '':
rm_script_args = ' --none'

# Write rm script
if optimize == 'true':
filename = config.get('SCRIPT_FILE_NAMES', 'rm_script')
append_file_to_output(root_dir + filename)
print servicename.replace('_service', '').upper(),
print
append_str_to_output("RM_SCRIPT_ARGS=" + "'" + rm_script_args + "'\n\n")

if rm_script_args == '':
rm_script_args = ' --none'
# Write user script
filename = config.get('SCRIPT_FILE_NAMES', 'user_script')
append_file_to_output(root_dir + filename)

# Write rm script
if optimize == 'true':
filename = config.get('SCRIPT_FILE_NAMES', 'rm_script')
# Write tail script
filename = config.get('SCRIPT_FILE_NAMES', 'tail_script')
append_file_to_output(root_dir + filename)
append_str_to_output("RM_SCRIPT_ARGS=" + "'" + rm_script_args + "'\n\n")

# Write user script
filename = config.get('SCRIPT_FILE_NAMES', 'user_script')
append_file_to_output(root_dir + filename)

# Write tail script
filename = config.get('SCRIPT_FILE_NAMES', 'tail_script')
append_file_to_output(root_dir + filename)

suffix = '_nushell' if nutshell else ''

# Write contextualization script
if cloud == 'opennebula':
filename = config.get('SCRIPT_FILE_NAMES', 'opennebula_script')
filename = config.get('SCRIPT_FILE_NAMES', 'opennebula_script'+suffix)
elif cloud == 'ec2':
filename = config.get('SCRIPT_FILE_NAMES', 'ec2_script')
filename = config.get('SCRIPT_FILE_NAMES', 'ec2_script'+suffix)
elif cloud == 'openstack':
filename = config.get('SCRIPT_FILE_NAMES', 'ec2_script')
append_file_to_output(root_dir + filename)

# Write resize script
if optimize == 'true':
filename = config.get('SCRIPT_FILE_NAMES', 'resize_script')
append_file_to_output(root_dir + filename)
if not nutshell:
if optimize == 'true':
if container:
filename = config.get('SCRIPT_FILE_NAMES', 'resize_container_script')
else:
filename = config.get('SCRIPT_FILE_NAMES', 'resize_script')
append_file_to_output(root_dir + filename)

close_output_file()

print "\nPlease run create-img-conpaas.sh as root"
close_output_file()

print "\nPlease run " +output_filename+ " as root"

Loading

0 comments on commit 83632f3

Please sign in to comment.