Class: GreenAndSecure::BlockUse

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

Instance Method Summary collapse

Instance Method Details

#runObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/chef/knife/block.rb', line 81

def run
   	    unless name_args.size == 1
   	    	puts "Please specify a server"
   	    	server_list = GreenAndSecure::BlockList.new
   	    	server_list.run
   	    	exit 1
    end
   	    list = GreenAndSecure::BlockList.new
    new_server = name_args.first
      if File.exists?(::Chef::Knife::chef_config_dir+"/knife-#{new_server}.rb")
         if File.exists?(::Chef::Knife::chef_config_dir+"/knife.rb")
            File.unlink(::Chef::Knife::chef_config_dir+"/knife.rb")
         end
         File.symlink(::Chef::Knife::chef_config_dir+"/knife-#{new_server}.rb",
           ::Chef::Knife::chef_config_dir+"/knife.rb")
         puts "The knife configuration has been updated to use #{new_server}"
      else
         puts "Knife configuration for #{new_server} not found, aborting switch"
      end
end