Class: Chef::Knife::ClientTarUpload
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::ClientTarUpload
- Defined in:
- lib/chef/knife/client_tar_upload.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.upload_clients(tar_file) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chef/knife/client_tar_upload.rb', line 25 def self.upload_clients(tar_file) ui.confirm "This command will only work when running on chef-server or by updating the couchdb_url in your knife config to point to your couchdb instance. Are you sure you want to continue" client_loader = Chef::Knife::Core::ObjectLoader.new(Chef::ApiClient, ui) current_clients = Chef::ApiClient.list.keys tar_file.api_clients.each do |api_client_path| client = client_loader.load_from("clients", api_client_path) # In order to 'update' a client we have to remove it first, so if the client exists destroy it if current_clients.include? client.name ApiClient.load(client.name).destroy end client.cdb_save ui.info("Updated Client : #{client.name}") end end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chef/knife/client_tar_upload.rb', line 12 def run #Get Arguments if @name_args.size != 1 ui.info("Please specify a tar path") show_usage exit 1 end tar_file = Chef::TarFile.new(@name_args.first) ClientTarUpload.upload_clients tar_file end |