#!/usr/bin/env ruby # (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. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # 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 'thor' require 'require_relative' require_relative '../lib/boot.rb' include Boot require_relative '../lib/down.rb' include Down require_relative '../lib/setup.rb' include Setup class Forj < Thor desc 'help', 'Display forj cli help' def help puts 'forj cli commands' puts ' -action:' puts ' boot: boot a Maestro box and instruct it to provision the blueprint' puts ' -blueprint: which blueprint to use' puts ' -on: just because :)' puts ' -cloud_provider: cloud provider type to be used to provision the forge.' puts ' - hpcloud: uses HP public cloud http://hpcloud.com/' puts ' - openstack: OpenStack based private or public cloud' puts ' - more to come' puts ' -as: just because :)' puts ' -name: name for the maestro box' puts ' -test: this will delete everything after it finish to install the forge' puts ' down: delete the Maestro box and all systems installed by the blueprint' puts ' -name: name for the maestro box' puts ' setup: set the credentials for forj cli' puts '' puts ' -credentials:' puts ' hpcloud:' puts ' access_key: access key from hpcloud' puts ' secret_key: secret key from hpcloud' puts ' auth_uri: identity endpoint' puts ' tenant_id: id for the tenant you want to use' puts ' availability_zone: which availability zone will be deployed' puts '' puts ' openstack:' puts ' openstack_username: your openstack username' puts ' openstack_api_key: your openstack password' puts ' openstack_auth_url: your openstack identity endpoint' puts '' end desc 'boot', 'boot a Maestro box and instruct it to provision the blueprint' method_option :build_conf_dir, :aliases => '-c', :desc => 'build config dir to use' method_option :branch, :aliases => '-b', :desc => 'branch to use' method_option :test_box, :aliases => '-t', :desc => 'test box' def boot(blueprint, on, cloud_provider, as, name, test=false) build_conf_dir = options[:build_conf_dir] branch = options[:branch] unless branch branch = 'master' end if options[:build_conf_dir] Boot.boot(blueprint, cloud_provider, name, build_conf_dir, branch, test) else Boot.boot(blueprint, cloud_provider, name, nil, nil, test) end end desc 'down', 'delete the Maestro box and all systems installed by the blueprint' def down(name) Down.down(name) end desc 'ssh', '' def ssh puts 'ssh' end desc 'setup', 'set the credentials for forj cli' def setup Setup.setup end end Forj.start