I am using Ruby to write a format disk script. I am using WMI to
differentiate local logical disks from virtual floppies, CD-roms, and
attached SAN disks. The differentiation is in the win32_DiskDrive
class, under the "caption" section. Since this script will be run on
VMs, HP, or Dell, I need it to look for multiple conditions, and I'm not
sure how to do it. Here is a section of code that works when only
looking for VM disks:
require 'ruby-wmi'
logical_disks = WMI::Win32_DiskDrive.find(:all, :conditions => {
:Caption => 'VMware Virtual disk SCSI Disk Device' } )
Can I add multiple conditions to it, such as two other potential
:Captions? Some way to do an 'or' in there so it will capture data from
either VMware Virtual Disks, or HP Logical Disks, or Dell Perc, etc?
on 2012-08-02 16:45
on 2012-08-02 22:28
On Thu, Aug 2, 2012 at 9:45 AM, Charlie B. <lists@ruby-forum.com> wrote: > I am using Ruby to write a format disk script. I am using WMI to > differentiate local logical disks from virtual floppies, CD-roms, and > attached SAN disks. The differentiation is in the win32_DiskDrive > class, under the "caption" section. Since this script will be run on > VMs, HP, or Dell, I need it to look for multiple conditions, and I'm not > sure how to do it. Here is a section of code that works when only > looking for VM disks: > You can use a string for :conditions. WMI::Win32_DiskDrive.find(:all, :conditions => "Caption = 'VMware Virtual disk SCSI Disk Device' OR Caption = 'HP drive' OR Caption = 'VMWare drive'" ) A few other options that occured to me are; WIn32_DiskDrive already eliminates non-disk drives. So, if I'm reading it right, you really only need to eliminate SAN drives. So, assuming your SAN disks have a model of PowerDevice by PowerPath, you could do: WMI::Win32_DiskDrive.find(:all, :conditions => "model !='PowerDevice by PowerPath'" ) or WMI::Win32_DiskDrive.all( :conditions => "NOT model LIKE '%PowerPath%'" )
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.