Class: CollinsShell::Provision
- Inherits:
-
Thor
- Object
- Thor
- CollinsShell::Provision
- Includes:
- ThorHelper, Util
- Defined in:
- lib/collins_shell/provision.rb
Constant Summary
Constants included from Util
Constants included from ThorHelper
ThorHelper::COLLINS_OPTIONS, ThorHelper::PAGE_OPTIONS
Instance Method Summary collapse
Methods included from Util
#asset_exec, #asset_get, #call_collins, #finalize_exec, #format_asset_tags, #format_asset_value, #get_selector, #is_array?, #print_find_results, #run_command_in_thread, #say_status, #thread_mgr
Methods included from ThorHelper
#appropriate_answer?, #batch_selector_operation, #collins_config_from_file, #ensure_password, #get_collins_client, #get_collins_config, #get_password, included, #require_valid_collins_config, #require_yes, #say_error, #say_success, #selector_or_tag, #try_config_merge, #use_collins_options, #use_nuke_option, #use_page_options, #use_selector_option, #use_tag_option
Instance Method Details
#host(tag, profile, contact) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/collins_shell/provision.rb', line 61 def host tag, profile, contact verify_profile(profile) if .verify config = get_collins_config if config[:timeout] < 180 then cclient = get_collins_client :timeout => 180 else cclient = get_collins_client end asset = asset_get tag, if .confirm then printer = CollinsShell::AssetPrinter.new asset, self, :detailed => false puts printer require_yes "You are about to provision asset #{tag} as a #{profile}. ARE YOU SURE?", :red end progress_printer = Thread.new { loop { print "." sleep(1) } } status = call_collins cclient, "provision host" do |client| say_status("starting", "Provisioning has started", :white) client.provision tag, profile, contact, :activate => .activate, :pool => .pool, :primary_role => .primary_role, :secondary_role => .secondary_role, :suffix => .suffix end progress_printer.terminate puts() if status then say_success("Successfully provisioned asset") asset = asset_get tag, printer = CollinsShell::AssetPrinter.new asset, self, :detailed => false puts printer asset_exec asset, .exec, .confirm else say_error("Failed to provision asset") end end |
#list ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/collins_shell/provision.rb', line 15 def list table = Terminal::Table.new table.title = set_color("Provisioning Profiles", :bold, :magenta) table << [ "Profile", "Label", "Prefix", "Pool", split("Primary Role"), split("Secondary Role"), split("Suffix Allowed?"), split("Requires Primary Role?"), split("Requires Secondary Role?"), split("Requires Pool?") ] table << :separator data = call_collins get_collins_client, '/api/provision/profiles' do |client| profs = client.provisioning_profiles last = profs.size - 1 profs.each_with_index do |profile, idx| table << [ profile.profile, split(profile.label), profile.prefix, optional_string(profile.pool), optional_string(profile.primary_role), optional_string(profile.secondary_role), centered(profile.suffix_allowed?), centered(profile.requires_primary_role?), centered(profile.requires_secondary_role?), centered(profile.requires_pool?) ] if idx != last && too_wide? then table << :separator end end end puts table end |