Class: Vagrant::Command::Base
- Inherits:
-
Object
- Object
- Vagrant::Command::Base
- Includes:
- Engineyard::Local::Command::Helpers
- Defined in:
- lib/engineyard-local/command/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #cookbook_status(scope = :partial, get_installed_version = true) ⇒ Object
-
#initialize(argv, env) ⇒ Base
constructor
A new instance of Base.
Methods included from Engineyard::Local::Command::Helpers
#insert_linebreaks, #merge_run_options, #run
Constructor Details
#initialize(argv, env) ⇒ Base
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/engineyard-local/command/base.rb', line 36 def initialize(argv, env) @argv = argv @env = env @logger = Log4r::Logger.new("vagrant::command::#{self.class.to_s.downcase}") @cookbook_status_already_checked ||= :not_checked begin with_target_vms() do |vm| if vm.created? && vm.state == :running @env.ui.info(cookbook_status, :prefix => false) unless Engineyard::Local.cookbook_version_verified? Engineyard::Local.cookbook_version_verified else cookbook_status(:partial, false) end end rescue Errors::NoEnvironmentError # Ignore this error. It will happen any time an ey-local/vagrant command is invoked # in a directory that is not yet setup with a Vagrant environment. end end |
Instance Method Details
#cookbook_status(scope = :partial, get_installed_version = true) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/engineyard-local/command/base.rb', line 6 def cookbook_status(scope = :partial, get_installed_version = true) installed_cookbook_version = [] la_brea_data = [] cb_status = '' begin run( Vagrant::Action::Builder.new do use( Engineyard::Local::Middleware::Cookbooks,:get_installed_version, installed_cookbook_version ) if get_installed_version use( Engineyard::Local::Middleware::Cookbooks,:get_la_brea_data, la_brea_data ) end ) rescue Exception cookbooks_status = "ERROR: Failure while determining cookbook status." end installed_cookbook_version = installed_cookbook_version.first la_brea_data = la_brea_data.first || {} if ( installed_cookbook_version == la_brea_data[:cookbooks_version] ) && ( scope == :full ) cb_status << I18n.t("vagrant.commands.status.cookbooks_current", :version => installed_cookbook_version) elsif ( installed_cookbook_version != la_brea_data[:cookbooks_version] ) cb_status << I18n.t("vagrant.commands.status.cookbooks_outdated", :version => installed_cookbook_version, :new_version => la_brea_data[:cookbooks_version], :changelog => Nokogiri::HTML(la_brea_data[:changelog]).text) end cb_status end |