Module: Vmesh
- Defined in:
- lib/vmesh/vsphere.rb,
lib/vmesh.rb,
lib/vmesh/list.rb,
lib/vmesh/create.rb,
lib/vmesh/logger.rb,
lib/vmesh/machine.rb,
lib/vmesh/version.rb,
lib/vmesh/datastore.rb,
lib/vmesh/datacenter.rb,
lib/vmesh/custom_spec.rb,
lib/vmesh/ping_helper.rb,
lib/vmesh/commands/list.rb,
lib/vmesh/commands/create.rb,
lib/vmesh/server_defaults.rb
Overview
VM Manager Class to hand all things VSphere
Defined Under Namespace
Classes: CustomSpec, Datacenter, Datastore, Machine, VSphere
Constant Summary
collapse
- VERSION =
'0.1.11'
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
18
19
20
|
# File 'lib/vmesh.rb', line 18
def self.logger
@logger ||= Logger.new STDOUT
end
|
Class Method Details
.list_under(folder, show_directories_only, recurse = false, currently_in = '') ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/vmesh/commands/list.rb', line 24
def self.list_under(folder, show_directories_only, recurse = false, currently_in = '')
currently_in = '' if currently_in == '/vm'
folder.childEntity.each do |x|
name = x.to_s.split('(').first
case name
when "Folder"
puts "#{currently_in}/#{x.name}/"
list_under(x, show_directories_only, recurse, "#{currently_in}/#{x.name}" ) if recurse
when "VirtualMachine"
puts "#{currently_in}/#{x.name}" unless show_directories_only
else
puts "# Unrecognized Entity " + x.to_s
end
end
end
|
.parse_vm_target(vm_target) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/vmesh/commands/create.rb', line 57
def self.parse_vm_target(vm_target)
vm_details = vm_target.match(/(.+)\/(.+)/)
vm = Hash.new
vm[:folder] = '/'
vm[:name] = vm_target
if vm_details
vm[:folder] = vm_details[1]
vm[:name] = vm_details[2]
end
vm
end
|
.pingecho(host, timeout = 5, service = "echo") ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/vmesh/ping_helper.rb', line 5
def self.pingecho(host, timeout=5, service="echo")
begin
timeout(timeout) do
s = TCPSocket.new(host, service)
s.close
end
rescue Errno::ECONNREFUSED
return true
rescue Timeout::Error, StandardError
return false
end
return true
end
|
.template ⇒ Object
22
23
24
|
# File 'lib/vmesh/server_defaults.rb', line 22
def self.template
@template
end
|
Instance Method Details
#create(vim, datacenter, template_name, new_machine_name, ip_address) ⇒ Object
2
3
4
5
6
7
8
9
10
|
# File 'lib/vmesh/create.rb', line 2
def create(vim, datacenter, template_name, new_machine_name, ip_address)
template = Vmesh::Machine::get vim, datacenter, template_name
spec = Vmesh::CustomSpec::get vim.serviceContent.customizationSpecManager
spec.destination_ip_address ip_address
vm.clone new_machine_name, spec
end
|
#list ⇒ Object
2
3
|
# File 'lib/vmesh/list.rb', line 2
def list
end
|