Class: GreenAndSecure::BlockList

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

Instance Method Summary collapse

Instance Method Details

#current_serverObject



46
47
48
49
50
51
52
53
54
# File 'lib/chef/knife/block.rb', line 46

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

#runObject

list the available environments



65
66
67
68
69
70
71
72
73
74
# File 'lib/chef/knife/block.rb', line 65

def run
    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



57
58
59
60
61
62
# File 'lib/chef/knife/block.rb', line 57

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