rbvmomi 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbvmomi/#vim.rb# +155 -0
- data/lib/rbvmomi/version.rb +1 -1
- data/lib/rbvmomi/vmodl.rb +49 -0
- data/vmodl.db +0 -0
- metadata +5 -35
- data/.gitignore +0 -13
- data/.travis.yml +0 -11
- data/.yardopts +0 -6
- data/CONTRIBUTORS.md +0 -44
- data/Gemfile +0 -10
- data/Rakefile +0 -16
- data/devel/analyze-vim-declarations.rb +0 -217
- data/devel/analyze-xml.rb +0 -49
- data/devel/benchmark.rb +0 -121
- data/devel/collisions.rb +0 -22
- data/devel/merge-internal-vmodl.rb +0 -63
- data/devel/merge-manual-vmodl.rb +0 -36
- data/examples/annotate.rb +0 -57
- data/examples/cached_ovf_deploy.rb +0 -124
- data/examples/clone_vm.rb +0 -88
- data/examples/create_vm-1.9.rb +0 -97
- data/examples/create_vm.rb +0 -97
- data/examples/delete_disk_from_vm.rb +0 -57
- data/examples/extraConfig.rb +0 -57
- data/examples/lease_tool.rb +0 -106
- data/examples/logbundle.rb +0 -66
- data/examples/logtail.rb +0 -63
- data/examples/nfs_datastore.rb +0 -99
- data/examples/power.rb +0 -62
- data/examples/readme-1.rb +0 -38
- data/examples/readme-2.rb +0 -54
- data/examples/run.sh +0 -41
- data/examples/screenshot.rb +0 -51
- data/examples/vdf.rb +0 -84
- data/examples/vm_drs_behavior.rb +0 -80
- data/rbvmomi.gemspec +0 -33
data/examples/vdf.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
# Translation of vGhetto vdf, originally by William Lam
|
5
|
-
require 'optimist'
|
6
|
-
require 'rbvmomi'
|
7
|
-
require 'rbvmomi/optimist'
|
8
|
-
|
9
|
-
VIM = RbVmomi::VIM
|
10
|
-
|
11
|
-
opts = Optimist.options do
|
12
|
-
banner <<-EOS
|
13
|
-
Display utilization of each datastore in the datacenter.
|
14
|
-
|
15
|
-
Usage:
|
16
|
-
vdf.rb [options]
|
17
|
-
|
18
|
-
VIM connection options:
|
19
|
-
EOS
|
20
|
-
|
21
|
-
rbvmomi_connection_opts
|
22
|
-
|
23
|
-
text <<-EOS
|
24
|
-
|
25
|
-
Datacenter selection:
|
26
|
-
EOS
|
27
|
-
|
28
|
-
rbvmomi_datacenter_opt
|
29
|
-
|
30
|
-
text <<-EOS
|
31
|
-
|
32
|
-
Other options:
|
33
|
-
EOS
|
34
|
-
end
|
35
|
-
|
36
|
-
Optimist.die("must specify host") unless opts[:host]
|
37
|
-
|
38
|
-
vim = VIM.connect opts
|
39
|
-
|
40
|
-
dc = vim.serviceInstance.find_datacenter(opts[:datacenter]) or abort "datacenter not found"
|
41
|
-
|
42
|
-
def si n
|
43
|
-
['', 'K', 'M', 'G', 'T', 'P'].each_with_index do |x,i|
|
44
|
-
v = n.to_f/(1000**i)
|
45
|
-
return v,x if v < 1000 or x == 'P'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def unit n, u, p
|
50
|
-
"%.*g%s%s" % [p, si(n), u].flatten
|
51
|
-
end
|
52
|
-
|
53
|
-
def b n
|
54
|
-
unit(n,'B',3)
|
55
|
-
end
|
56
|
-
|
57
|
-
puts "Filesystem#{' '*53}Size Used Avail Use% Mounted on"
|
58
|
-
fmt = "%-62s %-8s %-8s %-8s %-8s %s"
|
59
|
-
|
60
|
-
if false
|
61
|
-
# simple version
|
62
|
-
dc.datastore.sort_by { |ds| ds.info.url }.each do |ds|
|
63
|
-
s = ds.summary
|
64
|
-
next unless s.accessible
|
65
|
-
size = s.capacity
|
66
|
-
free = s.freeSpace
|
67
|
-
used = size - free
|
68
|
-
pct_used = used*100.0/size
|
69
|
-
puts(fmt % [ds.info.url, b(size), b(used), b(free), unit(pct_used,'%',3), ds.name])
|
70
|
-
end
|
71
|
-
else
|
72
|
-
# fast version
|
73
|
-
paths = %w(name info.url summary.accessible summary.capacity summary.freeSpace)
|
74
|
-
propSet = [{ :type => 'Datastore', :pathSet => paths }]
|
75
|
-
filterSpec = { :objectSet => dc.datastore.map { |ds| { :obj => ds } }, :propSet => propSet }
|
76
|
-
data = vim.propertyCollector.RetrieveProperties(:specSet => [filterSpec])
|
77
|
-
data.select { |d| d['summary.accessible'] }.sort_by { |d| d['info.url'] }.each do |d|
|
78
|
-
size = d['summary.capacity']
|
79
|
-
free = d['summary.freeSpace']
|
80
|
-
used = size - free
|
81
|
-
pct_used = used*100.0/size
|
82
|
-
puts(fmt % [d['info.url'], b(size), b(used), b(free), unit(pct_used,'%',3), d['name']])
|
83
|
-
end
|
84
|
-
end
|
data/examples/vm_drs_behavior.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'optimist'
|
7
|
-
require 'rbvmomi'
|
8
|
-
require 'rbvmomi/optimist'
|
9
|
-
|
10
|
-
VIM = RbVmomi::VIM
|
11
|
-
CMDS = %w(get set)
|
12
|
-
BEHAVIOR = %w(fullyAutomated manual partiallyAutomated default)
|
13
|
-
|
14
|
-
opts = Optimist.options do
|
15
|
-
banner <<-EOS
|
16
|
-
Configure VM DRS behavior.
|
17
|
-
|
18
|
-
Usage:
|
19
|
-
vm_drs_behavior.rb [options] VM get
|
20
|
-
vm_drs_behavior.rb [options] VM set #{BEHAVIOR.join('|')}
|
21
|
-
|
22
|
-
Commands: #{CMDS * ' '}
|
23
|
-
|
24
|
-
VIM connection options:
|
25
|
-
EOS
|
26
|
-
|
27
|
-
rbvmomi_connection_opts
|
28
|
-
|
29
|
-
text <<-EOS
|
30
|
-
|
31
|
-
VM location options:
|
32
|
-
EOS
|
33
|
-
|
34
|
-
rbvmomi_datacenter_opt
|
35
|
-
|
36
|
-
text <<-EOS
|
37
|
-
|
38
|
-
Other options:
|
39
|
-
EOS
|
40
|
-
|
41
|
-
stop_on CMDS
|
42
|
-
end
|
43
|
-
|
44
|
-
Optimist.die("must specify host") unless opts[:host]
|
45
|
-
|
46
|
-
vm_name = ARGV[0] or Optimist.die("no VM name given")
|
47
|
-
cmd = ARGV[1] or Optimist.die("no command given")
|
48
|
-
abort "invalid command" unless CMDS.member? cmd
|
49
|
-
|
50
|
-
vim = VIM.connect opts
|
51
|
-
dc = vim.serviceInstance.find_datacenter(opts[:datacenter]) or abort "datacenter not found"
|
52
|
-
vm = dc.find_vm(vm_name) or abort "VM not found"
|
53
|
-
|
54
|
-
cluster = vm.runtime.host.parent
|
55
|
-
config = cluster.configurationEx.drsVmConfig.select {|c| c.key.name == vm.name }.first
|
56
|
-
default = cluster.configurationEx.drsConfig.defaultVmBehavior
|
57
|
-
|
58
|
-
case cmd
|
59
|
-
when 'get'
|
60
|
-
if config
|
61
|
-
behavior = config.behavior
|
62
|
-
else
|
63
|
-
behavior = "#{default} (default)"
|
64
|
-
end
|
65
|
-
puts "#{vm.name} is #{behavior}"
|
66
|
-
when 'set'
|
67
|
-
behavior = ARGV[2] or Optimist.die("no behavior given")
|
68
|
-
abort "invalid behavior" unless BEHAVIOR.member? behavior
|
69
|
-
|
70
|
-
if behavior == "default"
|
71
|
-
behavior = default
|
72
|
-
end
|
73
|
-
vm_spec =
|
74
|
-
VIM.ClusterDrsVmConfigSpec(:operation => VIM.ArrayUpdateOperation(config ? "edit" : "add"),
|
75
|
-
:info => VIM.ClusterDrsVmConfigInfo(:key => vm,
|
76
|
-
:behavior => VIM.DrsBehavior(behavior)))
|
77
|
-
spec = VIM.ClusterConfigSpecEx(:drsVmConfigSpec => [vm_spec])
|
78
|
-
cluster.ReconfigureComputeResource_Task(:spec => spec, :modify => true).wait_for_completion
|
79
|
-
end
|
80
|
-
|
data/rbvmomi.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016-2017 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
5
|
-
|
6
|
-
require 'rbvmomi/version'
|
7
|
-
|
8
|
-
Gem::Specification.new do |spec|
|
9
|
-
spec.name = 'rbvmomi'
|
10
|
-
spec.summary = 'Ruby interface to the VMware vSphere API'
|
11
|
-
spec.version = RbVmomi::VERSION
|
12
|
-
|
13
|
-
spec.authors = ['Rich Lane', 'Christian Dickmann']
|
14
|
-
spec.email = 'jrg@vmware.com'
|
15
|
-
spec.homepage = 'https://github.com/vmware/rbvmomi'
|
16
|
-
spec.license = 'MIT'
|
17
|
-
|
18
|
-
spec.bindir = 'exe'
|
19
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^test\//) }
|
20
|
-
spec.executables << 'rbvmomish'
|
21
|
-
|
22
|
-
spec.add_runtime_dependency('builder', '~> 3.0')
|
23
|
-
spec.add_runtime_dependency('json', '>= 1.8')
|
24
|
-
spec.add_runtime_dependency('nokogiri', '~> 1.5')
|
25
|
-
spec.add_runtime_dependency('optimist', '~> 3.0')
|
26
|
-
|
27
|
-
spec.add_development_dependency('rake', '~> 10.5')
|
28
|
-
spec.add_development_dependency('simplecov', '~> 0.12.0')
|
29
|
-
spec.add_development_dependency('yard', '~> 0.9.5')
|
30
|
-
spec.add_development_dependency('test-unit', '>= 2.5')
|
31
|
-
|
32
|
-
spec.required_ruby_version = '>= 1.8.7'
|
33
|
-
end
|