Class: RbVmomi::VIM::DVPortSetting

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

Instance Method Summary collapse

Instance Method Details

#dump_config(vds, prefix, show_inheritance = true, show_uplinkinfo = true) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rvc/extensions/DVPortSetting.rb', line 24

def dump_config vds, prefix, show_inheritance = true, show_uplinkinfo = true
  @show_inheritance = show_inheritance

  # map network respool to human-readable name
  if self.networkResourcePoolKey
     poolName  = translate_respool vds, self.networkResourcePoolKey, show_inheritance
  end
  puts_policy "#{prefix}blocked:", self.blocked
  puts_policy("#{prefix}vlan:", self.vlan, "", nil) { |v| translate_vlan v }
  if self.networkResourcePoolKey
     puts        "#{prefix}network resource pool: #{poolName}"
  end
  p = self.inShapingPolicy
  if p
     puts        "#{prefix}Rx Shaper: "
     puts_policy "#{prefix}  enabled:", p.enabled
     avg_bw = p.averageBandwidth
     puts_policy("#{prefix}  average bw:", avg_bw, "b/sec"){|v|metric(v)}
     puts_policy("#{prefix}  peak bw:", p.peakBandwidth, "b/sec"){|v|metric(v)}
     puts_policy("#{prefix}  burst size:", p.burstSize, "B"){|v|metric(v)}
  end
  p = self.outShapingPolicy
  if p
     puts        "#{prefix}Tx Shaper:"
     puts_policy "#{prefix}  enabled:", p.enabled
     avg_bw = p.averageBandwidth
     puts_policy("#{prefix}  average bw:", avg_bw, "b/sec") { |v| metric(v) }
     puts_policy("#{prefix}  peak bw:", p.peakBandwidth, "b/sec") {|v| metric(v)}
     puts_policy("#{prefix}  burst size:", p.burstSize, "B") {|v| metric(v)}
  end
  if show_uplinkinfo
    p = self.uplinkTeamingPolicy
    if p
       puts        "#{prefix}Uplink Teaming Policy:"
       puts_policy "#{prefix}  policy:", p.policy  #XXX map the strings values
       puts_policy "#{prefix}  reverse policy:", p.reversePolicy
       puts_policy "#{prefix}  notify switches:", p.notifySwitches
       puts_policy "#{prefix}  rolling order:", p.rollingOrder
       c = p.failureCriteria
       if c
          puts        "#{prefix}  Failure Criteria: "
          puts_policy "#{prefix}    check speed:", c.checkSpeed
          puts_policy("#{prefix}    speed:", c.speed, "Mb/sec")# { |v| metric(v) }
          puts_policy "#{prefix}    check duplex:", c.checkDuplex
          puts_policy "#{prefix}    full duplex:", c.fullDuplex
          puts_policy "#{prefix}    check error percentage:",  c.checkErrorPercent
          puts_policy "#{prefix}    max error percentage:", c.percentage, "%"
          puts_policy "#{prefix}    check beacon:", c.checkBeacon
       end
       o = p.uplinkPortOrder
       if o
          puts        "#{prefix}  Uplink Port Order:"
          puts_policy("#{prefix}    active:", o,"", :activeUplinkPort){|v|v.join(',')}
          puts_policy("#{prefix}    standby:",o,"",:standbyUplinkPort){|v|v.join(',')}
       end
    end
  end
  p = self.securityPolicy
  if p
     puts        "#{prefix}Security:"
     puts_policy "#{prefix}  allow promiscuous mode:", p.allowPromiscuous
     puts_policy "#{prefix}  allow mac changes:", p.macChanges
     puts_policy "#{prefix}  allow forged transmits:", p.forgedTransmits
     puts_policy "#{prefix}enable ipfix monitoring:", self.ipfixEnabled
     puts_policy "#{prefix}forward all tx to uplink:", self.txUplink
  end
end

#puts_policy(prefix, policy, suffix = "", prop = :value, &b) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/rvc/extensions/DVPortSetting.rb', line 92

def puts_policy prefix, policy, suffix = "", prop = :value, &b
  b ||= lambda { |v| v }
  if policy
     if prop != nil
        v = policy.send(prop)
     else
        v = policy
     end
     print "#{prefix} #{b.call(v)}#{suffix}"
     if @show_inheritance and policy.inherited == false
        puts "*"
     else
        puts ""
     end
  end
end