lib/boot.rb in forj-0.0.30 vs lib/boot.rb in forj-0.0.31
- old
+ new
@@ -36,69 +36,97 @@
#
module Boot
def boot(blueprint, cloud_provider, name,
build, build_config_dir, build_config,
branch, git_repo, boothook, box_name,
- key_name, key_path,
+ key_name, key_path, region, catalog,
test = false)
begin
initial_msg = 'booting %s on %s' % [blueprint , cloud_provider]
Logging.info(initial_msg)
puts (initial_msg)
forj_dir = File.expand_path(File.dirname(__FILE__))
Dir.chdir(forj_dir)
- definitions = YamlParse.get_values('catalog.yaml')
+ if catalog
+ definitions = YamlParse.get_values(catalog)
+ else
+ definitions = YamlParse.get_values('catalog.yaml')
+ end
+
maestro_url = definitions['default']['maestro']
Repositories.clone_repo(maestro_url)
+ infra_exists = nil
- 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)
+ begin
+ if File.directory?(definitions[blueprint]['infra'])
+ infra_exists = true
+ else
+ Repositories.create_infra
+ end
+ rescue => e
+ infra_exists = false
+ puts e.message
+ end
- security_group = SecurityGroup.create_security_group(blueprint)
- key_name = 'nova' unless key_name
- key_path = '~/.ssh/nova' unless key_path
+ network = Network.get_or_create_network(definitions[blueprint]['network'])
+ begin
+ subnet = Network.get_or_create_subnet(network.id, name)
+ router = Network.get_router(definitions[blueprint]['router'])
+ Network.create_router_interface(subnet.id, router)
+ rescue => e
+ puts e.message
+ end
+
+ security_group = SecurityGroup.get_or_create_security_group(definitions[blueprint]['security_group'])
+
+ key_name = definitions[blueprint]['keypair_name'] unless key_name
+ key_path = definitions[blueprint]['keypair_path'] unless key_path
SecurityGroup.upload_existing_key(key_name, key_path)
- ports = definitions['redstone']['ports']
+ ports = definitions[blueprint]['ports']
ports.each do|port|
- Network.create_security_group_rule(security_group.id, 'tcp', port, port)
+ Network.get_or_create_rule(security_group.id, 'tcp', port, port)
end
ENV['FORJ_HPC_NETID'] = network.id
ENV['FORJ_SECURITY_GROUP'] = security_group.name
ENV['FORJ_KEYPAIR'] = key_name
- ENV['FORJ_HPC_NOVA_KEYPUB'] = key_name
+ ENV['FORJ_HPC_KEYPUB'] = key_path
+ if region
+ ENV['FORJ_REGION'] = region
+ end
# run build.sh to boot maestro
current_dir = Dir.pwd
home = Helpers.get_home_path
build_path = home + '/.forj/maestro/build'
Dir.chdir(build_path)
build = 'bin/build.sh' unless build
- build_config_dir = '~/.forj/maestro/build/conf' unless build_config_dir
+ if infra_exists
+ build_config_dir = definitions[blueprint]['infra'] unless build_config_dir
+ else
+ build_config_dir = definitions[blueprint]['build_config_dir'] unless build_config_dir
+ end
- build_config = 'box' unless build_config
+ build_config = definitions[blueprint]['build_config'] unless build_config
- branch = 'master' unless branch
+ branch = definitions[blueprint]['branch'] unless branch
- git_repo = 'review:forj-oss/maestro' unless git_repo
+ box_name = definitions[blueprint]['box_name'] unless box_name
- box_name = 'maestro' unless box_name
+ meta = '--meta blueprint=%s --meta HPCLOUD_PRIV=~/.cache/forj/master.forj-13.5.g64' % [blueprint]
- boothook = '~/.forj/maestro/build/bin/build-tools/boothook.sh' unless boothook
+ command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --debug-box %s' % [build, name, box_name, build_config_dir, build_config, branch, meta]
- command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --gitRepo %s --boothook %s' % [build, name, box_name, build_config_dir, build_config, branch, git_repo, boothook]
-
+ Logging.info('using build.sh for %s' % [name])
Kernel.system(command)
Dir.chdir(current_dir)
if test
puts 'test flag is on, deleting objects'