Class: Provider::ChefServer::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/providers/chefserver/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/providers/chefserver/client.rb', line 5

def initialize(name)
	@name = name
	@logger = Veronic::Deployer.new().logger
end

Instance Method Details

#destroy(name = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/providers/chefserver/client.rb', line 10

def destroy(name=nil)
	@logger.info "Destroying client #{@name} from chef-server ..."
	knife = Chef::Knife.new()
	knife.config[:yes] = true
	if self.exists?
		knife.delete_object(Chef::ApiClient, @name)
		@logger.info "Client #{@name} destroy from chef-server"
	else
		@logger.info "Unabled to find client #{@name}"
	end
end

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
# File 'lib/providers/chefserver/client.rb', line 22

def exists?
	begin
		Chef::ApiClient.load(@name)
	rescue					
		return false
	end		
	return true
end