class RbVmomi::VIM::EsxcliNamespace
Constants
- ESXCLI_PREFIX
Attributes
commands[R]
host[R]
instance[R]
name[R]
namespaces[R]
parent[R]
type[R]
type_info[R]
Public Class Methods
new(name, parent, host)
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 70 def initialize name, parent, host @name = name @parent = parent @host = host @type = nil @instance = nil @type_info = nil @namespaces = Hash.new { |h,k| h[k] = self.class.new k, self, host } @commands = {} @cached_cli_info = nil end
root(host)
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 54 def self.root host type_hash = host.dti.toRbvmomiTypeHash VIM.loader.add_types type_hash all_instances = host.dtm.DynamicTypeMgrQueryMoInstances instances = Hash[all_instances.select { |x| x.moType.start_with? ESXCLI_PREFIX }. map { |x| [x.moType,x.id] }] type_infos = Hash[host.dti.managedTypeInfo.map { |x| [x.name,x] }] new('root', nil, host).tap do |root| instances.each do |type,instance| path = type.split('.')[2..-1] ns = path.inject(root) { |b,v| b.namespaces[v] } ns.realize type, instance, type_infos[type] end end end
Public Instance Methods
cli_info()
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 100 def cli_info @cached_cli_info ||= if @host.direct? @host.cli_info_fetcher.VimCLIInfoFetchCLIInfo(:typeName => type_name) else @host.mme.execute(@host.cli_info_fetcher._ref, "vim.CLIInfo.FetchCLIInfo", :typeName => type_name) end end
method_missing(name, *args)
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 115 def method_missing name, *args name = name.to_s if @namespaces.member? name and args.empty? @namespaces[name] elsif @commands.member? name @commands[name].call *args else raise NoMethodError end end
obj()
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 110 def obj conn = @host._connection conn.type(@type_info.wsdlName).new(conn, @instance) end
pretty_print(q)
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 126 def pretty_print q q.text @name q.text ' ' q.group 2 do q.text '{' q.breakable items = (@namespaces.values+@commands.values).sort_by(&:name) q.seplist items, nil, :each do |v| if v.is_a? VIM::EsxcliNamespace q.pp v else q.text v.name end end end q.breakable q.text '}' end
realize(type, instance, type_info)
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 82 def realize type, instance, type_info fail if @type or @instance @type = type @instance = instance @type_info = type_info @type_info.method.each do |method_type_info| name = method_type_info.name @commands[name] = VIM::EsxcliCommand.new self, method_type_info end end
type_name()
click to toggle source
# File lib/rbvmomi/vim/HostSystem.rb, line 93 def type_name if @type then @type elsif @parent then "#{@parent.type_name}.#{@name}" else 'vim.EsxCLI' end end