Class: VdlConnection
- Inherits:
-
Object
- Object
- VdlConnection
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb
Overview
class VixDiskLib
Constant Summary collapse
- MAX_DISK_WARN =
9
Instance Attribute Summary collapse
-
#serverName ⇒ Object
readonly
Returns the value of attribute serverName.
-
#vddk ⇒ Object
readonly
Returns the value of attribute vddk.
-
#vdl_connection ⇒ Object
readonly
Returns the value of attribute vdl_connection.
Instance Method Summary collapse
- #__close_disk__(diskObj) ⇒ Object
- #disconnect ⇒ Object
- #dumpDisks ⇒ Object
- #getDisk(path, flags) ⇒ Object
-
#initialize(connect_parms, vddk) ⇒ VdlConnection
constructor
A new instance of VdlConnection.
Constructor Details
#initialize(connect_parms, vddk) ⇒ VdlConnection
Returns a new instance of VdlConnection.
93 94 95 96 97 98 99 100 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 93 def initialize(connect_parms, vddk) @serverName = connect_parms[:server_name] $vim_log.info "VdlConnection.initialize: #{@serverName}" if $vim_log @vdl_connection = VixDiskLibApi.connect(connect_parms) @disks = [] @disk_lock = Sync.new @vddk = vddk end |
Instance Attribute Details
#serverName ⇒ Object (readonly)
Returns the value of attribute serverName.
89 90 91 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 89 def serverName @serverName end |
#vddk ⇒ Object (readonly)
Returns the value of attribute vddk.
89 90 91 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 89 def vddk @vddk end |
#vdl_connection ⇒ Object (readonly)
Returns the value of attribute vdl_connection.
89 90 91 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 89 def vdl_connection @vdl_connection end |
Instance Method Details
#__close_disk__(diskObj) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 146 def __close_disk__(diskObj) @disk_lock.sync_lock(:EX) if (unlock = !@disk_lock.sync_exclusive?) @vddk.running = true VixDiskLibApi.close(diskObj.handle) if !@vdl_connection $vim_log.warn "VDLConnection.disconnect: server: #{@serverName} not connected" if $vim_log else @disks.delete(diskObj) nd = VdlWrapper.dec_server_disk_count $vim_log.warn "VdlConnection.__close_disk__: #{@serverName} open disks = #{nd}" if $vim_log end ensure @disk_lock.sync_unlock if unlock end |
#disconnect ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 102 def disconnect $vim_log.info "VdlConnection.disconnect: #{@serverName}" if $vim_log @disk_lock.synchronize(:EX) do if !@vdl_connection $vim_log.warn "VDLConnection.disconnect: server: #{@serverName} not connected" if $vim_log else __close_disks__ VdlWrapper.__disconnect__(self) @vdl_connection = nil @vddk.running = true @vddk.shutdown = true end end end |
#dumpDisks ⇒ Object
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 117 def dumpDisks raise VixDiskLibError, "VdlConnection.getDisk: server #{@serverName} not connected" unless @vdl_connection @vddk.running = true @disk_lock.sync_lock(:SH) if (unlock = !@disk_lock.sync_locked?) @disks.each do |d| $vim_log.warn " VdlDisk: #{d.path}, opened: #{d.timeStamp}" if $vim_log end ensure @disk_lock.sync_unlock if unlock end |
#getDisk(path, flags) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb', line 128 def getDisk(path, flags) @disk_lock.synchronize(:EX) do raise VixDiskLibError, "VdlConnection.getDisk: server #{@serverName} not connected" unless @vdl_connection @vddk.running = true disk = VdlDisk.new(self, path, flags) @disks << disk nd = VdlWrapper.inc_server_disk_count $vim_log.info "VdlConnection.getDisk: #{@serverName} open disks = #{nd}" if $vim_log if nd >= MAX_DISK_WARN && $vim_log $vim_log.warn "VdlConnection::getDisk: connection to server: #{@serverName}" $vim_log.warn "VdlConnection::getDisk: number of open disks = #{nd}" $vim_log.warn "VdlConnection::getDisk: subsequent open calls may fail" VdlWrapper.dumpDisks(@serverName) end return disk end end |