Class: Bosh::Director::Api::InstanceManager
- Defined in:
- lib/bosh/director/api/instance_manager.rb
Instance Method Summary collapse
-
#agent_client_for(instance) ⇒ AgentClient
Agent client to talk to instance.
- #fetch_logs(user, deployment_name, job, index, options = {}) ⇒ Object
-
#filter_by(filter) ⇒ Array
List of instances that matched the filter.
- #find_by_name(deployment_name, job, index) ⇒ Models::Instance
-
#find_instance(instance_id) ⇒ Models::Instance
Instance.
- #ssh(user, options) ⇒ Object
Instance Method Details
#agent_client_for(instance) ⇒ AgentClient
Returns Agent client to talk to instance.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bosh/director/api/instance_manager.rb', line 28 def agent_client_for(instance) vm = instance.vm if vm.nil? raise InstanceVmMissing, "`#{instance.job}/#{instance.index}' doesn't reference a VM" end if vm.agent_id.nil? raise VmAgentIdMissing, "VM `#{vm.cid}' doesn't have an agent id" end AgentClient.with_defaults(vm.agent_id) end |
#fetch_logs(user, deployment_name, job, index, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bosh/director/api/instance_manager.rb', line 42 def fetch_logs(user, deployment_name, job, index, = {}) if deployment_name.nil? || job.nil? || index.nil? raise DirectorError, 'deployment, job and index parameters are required' end instance = find_by_name(deployment_name, job, index) JobQueue.new.enqueue(user, Jobs::FetchLogs, 'fetch logs', [instance.id, ]) end |
#filter_by(filter) ⇒ Array
Returns List of instances that matched the filter.
22 23 24 |
# File 'lib/bosh/director/api/instance_manager.rb', line 22 def filter_by(filter) InstanceLookup.new.by_filter(filter) end |
#find_by_name(deployment_name, job, index) ⇒ Models::Instance
15 16 17 |
# File 'lib/bosh/director/api/instance_manager.rb', line 15 def find_by_name(deployment_name, job, index) InstanceLookup.new.by_attributes(deployment_name, job, index) end |
#find_instance(instance_id) ⇒ Models::Instance
Returns Instance.
7 8 9 |
# File 'lib/bosh/director/api/instance_manager.rb', line 7 def find_instance(instance_id) InstanceLookup.new.by_id(instance_id) end |
#ssh(user, options) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/bosh/director/api/instance_manager.rb', line 53 def ssh(user, ) description = "ssh: #{['command']}:#{['target']}" deployment = DeploymentLookup.new.by_name(['deployment_name']) JobQueue.new.enqueue(user, Jobs::Ssh, description, [deployment.id, ]) end |