Class: GreenAndSecure::BlockList

Inherits:
Chef::Knife show all
Defined in:
lib/chef/knife/block.rb

Instance Method Summary collapse

Methods inherited from Chef::Knife

#get_config_file

Instance Method Details

#current_serverObject



120
121
122
123
124
125
126
127
128
# File 'lib/chef/knife/block.rb', line 120

def current_server
  GreenAndSecure::check_block_setup

  @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                        GreenAndSecure::printable_server(File.readlink(GreenAndSecure::chef_config_base+"/knife.rb"))
                      else
                        nil
                      end
end

#runObject

list the available environments



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/chef/knife/block.rb', line 140

def run
  GreenAndSecure::check_block_setup
  puts "The available chef servers are:"
  servers.each do |server|
    if server == current_server then
      puts "\t* #{server} [ Currently Selected ]"
    else
      puts "\t* #{server}"
    end
  end
end

#serversObject



132
133
134
135
136
137
# File 'lib/chef/knife/block.rb', line 132

def servers
  ## get the list of available environments by searching ~/.chef for knife.rb files
  @servers ||= Dir.glob(GreenAndSecure::chef_config_base+"/knife-*.rb").sort.map do |fn|
    GreenAndSecure::printable_server(fn)
  end
end