Class: RbVmomi::VIM::DistributedVirtualSwitch

Inherits:
Object
  • Object
show all
Defined in:
lib/rvc/extensions/DistributedVirtualSwitch.rb

Overview

Copyright © 2011 VMware, Inc. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.folder?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 158

def self.folder?
  true
end

Instance Method Details

#childrenObject



140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 140

def children
  portgroups = RVC::FakeFolder.new(self, :portgroup_children)
  portgroups.define_singleton_method :display_info, lambda {
    vds = self.rvc_parent
    $shell.cmds.basic.table vds.portgroup, {}
  }

  {
    'portgroups' => portgroups,
    'respools' => RVC::FakeFolder.new(self, :respool_children),
    'hosts' => RVC::FakeFolder.new(self, :hosts_children),
  }
end

#display_infoObject



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 84

def display_info
  config, = collect(:config)
  puts "name: #{config.name}"
  puts "description: #{config.description}"
  puts "product: #{config.productInfo.vendor} #{config.productInfo.name} #{config.productInfo.version}"
  puts "ports: #{config.numPorts}"
  puts "standalone ports: #{config.numStandalonePorts}"
  puts "maximum ports: #{config.maxPorts}"
  puts "netIORM: #{config.networkResourceManagementEnabled}"
  puts "Default Port Configuration:"
  config.defaultPortConfig.dump_config self, "  ", false
end

#hosts_childrenObject



131
132
133
134
135
136
137
138
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 131

def hosts_children
  hosts = {}
  self.config.host.each do |hostinfo|
    host = hostinfo.config.host
    hosts[host.collect(:name).first] = host
  end
  hosts
end

#ls_text(r) ⇒ Object



154
155
156
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 154

def ls_text r
  " (vds)"
end

#portgroup_childrenObject



114
115
116
117
118
119
120
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 114

def portgroup_children
  portgroups = {}
  self.portgroup.each { |pg|
    portgroups[pg.name] = pg
  }
  portgroups
end

#respool_childrenObject



122
123
124
125
126
127
128
129
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 122

def respool_children
  respools = {}
  self.networkResourcePool.each do |pool|
    respools[pool.name] = pool
  end

  respools
end

#summarizeObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rvc/extensions/DistributedVirtualSwitch.rb', line 97

def summarize
  t = table(['portgroup name', 'num ports', 'vlan', 'resource pool'])
  self.portgroup.each { |pg|
    if pg.config.defaultPortConfig
       respool = translate_respool self, pg.config.defaultPortConfig.networkResourcePoolKey
       vlan = pg.config.defaultPortConfig.vlan
    end

    if pg.config.defaultPortConfig
       t << [pg.config.name, pg.config.numPorts, translate_vlan(vlan), respool]
    else
       t << [pg.config.name, pg.config.numPorts, nil, nil]
    end
  }
  puts t
end