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



124
125
126
127
128
129
130
131
132
# File 'lib/chef/knife/block.rb', line 124

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



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/chef/knife/block.rb', line 144

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



136
137
138
139
140
141
# File 'lib/chef/knife/block.rb', line 136

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