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

- old
+ new

@@ -1,6 +1,7 @@ #!/usr/bin/env ruby +# encoding: UTF-8 # (c) Copyright 2014 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,27 +15,28 @@ # See the License for the specific language governing permissions and # limitations under the License. require 'require_relative' -require_relative 'compute.rb' -include Compute require_relative 'network.rb' include Network require_relative 'yaml_parse.rb' include YamlParse require_relative 'security.rb' include SecurityGroup require_relative 'repositories.rb' include Repositories - +# +# Boot module +# module Boot - def boot(blueprint, cloud_provider, name, build_config_dir, branch, test=false) + def boot(blueprint, cloud_provider, name, build_config_dir, branch, test = false) begin - puts 'booting %s on %s' % [blueprint, cloud_provider] + puts format('booting %{blueprint} on %{cloud_provider}', + blueprint: blueprint , cloud_provider: cloud_provider) # get definitions from yaml forj_dir = File.expand_path(File.dirname(__FILE__)) Dir.chdir(forj_dir) definitions = YamlParse.get_values('../lib/catalog.yaml') @@ -44,14 +46,14 @@ # 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) + Network::create_router_interface(subnet.id, router) # create the security groups for the blueprint - security_group = SecurityGroup.create_security_group(blueprint) + security_group = SecurityGroup::create_security_group(blueprint) ports = definitions['redstone']['ports'] ports.each do|port| Network.create_security_group_rule(security_group.id, 'tcp', port, port) @@ -66,14 +68,16 @@ current_dir = Dir.pwd home = File.expand_path('~') build_path = home + '/.hpcloud/maestro/build' Dir.chdir(build_path) - 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] + if build_config_dir + command = format('bin/build.sh --build_ID maestro.%{name} --box-name maestro --build-conf-dir %{build_config_dir} --build-config box-13.5 --gitBranch %{branch}', name: name, build_config_dir: build_config_dir, branch: branch) + elsif name != 'redstone' + command = format('bin/build.sh --build_ID %{name} --box-name maestro --build-conf-dir ~/.hpcloud/maestro/build/conf --build-config box --blueprint %{blueprint_name}', name: name, blueprint_name: blueprint) else - command = 'bin/build.sh --build_ID %s --box-name maestro --build-conf-dir ~/.hpcloud/maestro/build/conf --build-config box' % [name] + command = format('bin/build.sh --build_ID %{name} --box-name maestro --build-conf-dir ~/.hpcloud/maestro/build/conf --build-config box', name: name) end Kernel.system(command) Dir.chdir(current_dir) @@ -84,12 +88,10 @@ Network.delete_network(network.name) end rescue SystemExit, Interrupt puts 'process interrupted by user' - rescue Exception => e + rescue StandardError => e puts e end - end - -end \ No newline at end of file +end