lib/boot.rb in forj-0.0.33 vs lib/boot.rb in forj-0.0.34

- old
+ new

@@ -14,12 +14,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - require_relative 'network.rb' include Network require_relative 'yaml_parse.rb' include YamlParse require_relative 'security.rb' @@ -29,39 +27,36 @@ require_relative 'log.rb' include Logging require_relative 'helpers.rb' include Helpers + # # Boot module # module Boot def boot(blueprint, cloud_provider, name, build, infra_dir, build_config, branch, git_repo, boothook, box_name, - key_name, key_path, region, catalog, + key_name, key_path, region, config, test = false) begin initial_msg = 'booting %s on %s (~/.forj/forj.log)' % [blueprint , cloud_provider] Logging.info(initial_msg) - puts ('INFO: Reading default configuration...') forj_dir = File.expand_path(File.dirname(__FILE__)) Dir.chdir(forj_dir) - #TODO: Consider defaults.yaml as default variables, and load more from ~/.forj/forj-config.yaml, to change defaults on user need. - if catalog - definitions = YamlParse.get_values(catalog) - else - definitions = YamlParse.get_values('defaults.yaml') - end - + puts ('INFO: Reading default configuration...') + oConfig=ForjConfig.new(config) + hConfig=oConfig.yConfig['default'] + # Initialize defaults - maestro_url = definitions['default']['maestro_url'] + maestro_url = hConfig['maestro_url'] - infra_dir = definitions['default']['infra_repo'] unless infra_dir + infra_dir = hConfig['infra_repo'] unless infra_dir # Ask information if needed. bBuildInfra=false if not Dir.exist?(File.expand_path(infra_dir)) sAsk = 'Your \'%s\' infra directory doesn\'t exist. Do you want to create a new one from Maestro(repo github)/templates/infra (yes/no)?' % [infra_dir] @@ -75,35 +70,35 @@ end # Step Maestro Clone puts('INFO: cloning maestro repo from \'%s\'...' % maestro_url) Repositories.clone_repo(maestro_url) - + if bBuildInfra puts('INFO: Building your infra... in \'%s\'' % [infra_dir]) Repositories.create_infra end - puts('INFO: Configuring network \'%s\'' % [definitions['default']['network']]) - network = Network.get_or_create_network(definitions['default']['network']) + puts('INFO: Configuring network \'%s\'' % [hConfig['network']]) + network = Network.get_or_create_network(hConfig['network']) begin subnet = Network.get_or_create_subnet(network.id, name) - router = Network.get_router(definitions['default']['router']) + router = Network.get_router(hConfig['router']) Network.create_router_interface(subnet.id, router) rescue => e puts e.message end - puts('INFO: Configuring keypair \'%s\'' % [definitions['default']['keypair_name']]) - key_name = definitions['default']['keypair_name'] unless key_name - key_path = definitions['default']['keypair_path'] unless key_path + puts('INFO: Configuring keypair \'%s\'' % [hConfig['keypair_name']]) + key_name = hConfig['keypair_name'] unless key_name + key_path = hConfig['keypair_path'] unless key_path SecurityGroup.upload_existing_key(key_name, key_path) - puts('INFO: Configuring Security Group \'%s\'' % [definitions['default']['security_group']]) - security_group = SecurityGroup.get_or_create_security_group(definitions['default']['security_group']) - ports = definitions['default']['ports'] + puts('INFO: Configuring Security Group \'%s\'' % [hConfig['security_group']]) + security_group = SecurityGroup.get_or_create_security_group(hConfig['security_group']) + ports = hConfig['ports'] ports.each do|port| Network.get_or_create_rule(security_group.id, 'tcp', port, port) end @@ -122,22 +117,22 @@ build_path = home + '/.forj/maestro/build' Dir.chdir(build_path) build = 'bin/build.sh' unless build - build_config = definitions['default']['build_config'] unless build_config + build_config = hConfig['build_config'] unless build_config - branch = definitions['default']['branch'] unless branch + branch = hConfig['branch'] unless branch - box_name = definitions['default']['box_name'] unless box_name + box_name = hConfig['box_name'] unless box_name - meta = '--meta blueprint=%s --meta HPCLOUD_PRIV=~/.cache/forj/master.forj-13.5.g64' % [blueprint] + meta = '--meta blueprint=%s ' % [blueprint] command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --debug-box %s' % [build, name, box_name, infra_dir, build_config, branch, meta] Logging.info('Calling build.sh') Logging.info(command) - + Kernel.system(command) Dir.chdir(current_dir) if test puts 'test flag is on, deleting objects'