lib/boot.rb in forj-0.0.18 vs lib/boot.rb in forj-0.0.19

- old
+ new

@@ -28,57 +28,68 @@ include Repositories module Boot def boot(blueprint, cloud_provider, name, build_config_dir, branch, test=false) - puts 'booting %s on %s' % [blueprint, cloud_provider] - # boot maestro + begin - # get definitions from yaml - forj_dir = File.expand_path(File.dirname(__FILE__)) - Dir.chdir(forj_dir) - definitions = YamlParse.get_values('../lib/catalog.yaml') + puts 'booting %s on %s' % [blueprint, cloud_provider] - # clone the maestro repo - Repositories.clone_repo + # get definitions from yaml + forj_dir = File.expand_path(File.dirname(__FILE__)) + Dir.chdir(forj_dir) + definitions = YamlParse.get_values('../lib/catalog.yaml') - # upload the keypair - SecurityGroup.upload_keypair(definitions[blueprint]['keypair']) + # clone the maestro repo + Repositories.clone_repo - # create the network where maestro will land - network = Network.create_network(name) - subnet = Network.create_subnet(network.id, name) - router = Network.get_router(definitions[blueprint]['router']) - Network.create_router_interface(subnet.id, router) + # create the network where maestro will land + network = Network.create_network(name) + subnet = Network.create_subnet(network.id, name) + router = Network.get_router(definitions[blueprint]['router']) + Network.create_router_interface(subnet.id, router) - # create the security groups for the blueprint - security_group = SecurityGroup.create_security_group(blueprint) + # create the security groups for the blueprint + security_group = SecurityGroup.create_security_group(blueprint) - for port in definitions[blueprint]['ports'] do - Network.create_security_group_rule(security_group.id, 'tcp', port, port) - end + ports = definitions['redstone']['ports'] - # run build.sh to boot maestro - current_dir = Dir.pwd - home = File.expand_path('~') - build_path = home + '/.hpcloud/maestro/build' - Dir.chdir(build_path) + ports.each do|port| + Network.create_security_group_rule(security_group.id, 'tcp', port, port) + end - if build_config_dir != nil - command = './bin/build.sh --build_ID maestro.10 --box-name maestro --build-conf-dir %s --build-config box --setBranch %s' % [build_config_dir, branch] - else - command = './bin/build.sh --build_ID maestro.10 --box-name maestro --build-config box' - end + ENV['FORJ_HPC_NETID'] = network.id + ENV['FORJ_SECURITY_GROUP'] = security_group.name + ENV['FORJ_KEYPAIR'] = definitions[blueprint]['keypair'] + ENV['FORJ_HPC_NOVA_KEYPUB'] = definitions[blueprint]['keypair'] + # run build.sh to boot maestro + current_dir = Dir.pwd + home = File.expand_path('~') + build_path = home + '/.hpcloud/maestro/build' + Dir.chdir(build_path) - Kernel.system(command) - Dir.chdir(current_dir) + if build_config_dir != nil + command = 'bin/build.sh --build_ID maestro.%s --box-name maestro --build-conf-dir %s --build-config box-13.5 --gitBranch %s' % [name, build_config_dir, branch] + else + command = 'bin/build.sh --build_ID %s --box-name maestro --build-conf-dir ~/.hpcloud/maestro/build/conf --build-config box' % [name] + end - if test - puts 'test flag is on, deleting objects' - Network.delete_router_interface(subnet.id, router) - Network.delete_subnet(subnet.id) - Network.delete_network(network.name) - #Network.delete_security_group(security_group.id) + Kernel.system(command) + Dir.chdir(current_dir) + + if test + puts 'test flag is on, deleting objects' + Network.delete_router_interface(subnet.id, router) + Network.delete_subnet(subnet.id) + Network.delete_network(network.name) + end + + rescue SystemExit, Interrupt + puts 'process interrupted by user' + rescue Exception => e + puts e end + end + end \ No newline at end of file