class MotherBrain::CliGateway::SubCommand::Environment
Public Instance Methods
configure(environment, attributes_file)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 19 def configure(environment, attributes_file) attributes_file = File.expand_path(attributes_file) begin content = File.read(attributes_file) rescue Errno::ENOENT ui.say "No attributes file found at: '#{attributes_file}'" exit(1) end begin attributes = MultiJson.decode(content) rescue MultiJson::DecodeError => ex ui.say "Error decoding JSON from: '#{attributes_file}'" ui.say ex exit(1) end job = environment_manager.async_configure(environment, attributes: attributes, force: options[:force], node_filter: options[:only]) CliClient.new(job).display end
create(environment)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 115 def create(environment) ui.say "Creating empty environment #{environment}" begin environment_manager.create(environment) rescue => e ui.error e.message exit(1) end end
destroy(environment)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 56 def destroy(environment) options[:with] = options[:provisioner] # TODO: rename with to provisioner options[:yes] ||= options[:force] destroy_options = Hash.new.merge(options).deep_symbolize_keys if !options[:force] && ChefMutex.new(chef_environment: environment).locked? raise MB::ResourceLocked, "The environment \"#{environment}\" is locked. You may use --force to override this safeguard." end dialog = "This will destroy the '#{environment}' environment.\nAre you sure? (yes|no): " really_destroy = options[:yes] || ui.yes?(dialog) if really_destroy job = provisioner.async_destroy(environment, destroy_options) CliClient.new(job).display else ui.say("Aborting destruction of '#{environment}'") end end
examine(environment)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 127 def examine(environment) job = environment_manager.async_examine_nodes(environment) CliClient.new(job).display end
from(environment_file)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 103 def from(environment_file) ui.say "Creating environment from #{environment_file}" begin environment_manager.create_from_file(environment_file) rescue => e ui.error e.message exit(1) end end
list()
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 78 def list ui.say "\n" ui.say "** listing environments" ui.say "\n" environment_manager.list.each do |env| ui.say env.name end end
lock(environment)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 89 def lock(environment) job = lock_manager.async_lock(environment) CliClient.new(job).display end
unlock(environment)
click to toggle source
# File lib/mb/cli_gateway/sub_commands/environment.rb, line 96 def unlock(environment) job = lock_manager.async_unlock(environment) CliClient.new(job).display end