Module: Chef::Sugar::Virtualization

Extended by:
Virtualization
Included in:
Virtualization
Defined in:
lib/chef/sugar/virtualization.rb

Instance Method Summary collapse

Instance Method Details

#kvm?(node) ⇒ Boolean

Determine if the current node is running under KVM.

Parameters:

Returns:

  • (Boolean)

    true if the machine is currently running under KVM, false otherwise



31
32
33
# File 'lib/chef/sugar/virtualization.rb', line 31

def kvm?(node)
  node.key?('virtualization') && node['virtualization']['system'] == 'kvm'
end

#lxc?(node) ⇒ Boolean

Determine if the current node is running in a linux container.

Parameters:

Returns:

  • (Boolean)

    true if the machine is currently running in a container, false otherwise



44
45
46
# File 'lib/chef/sugar/virtualization.rb', line 44

def lxc?(node)
  node.key?('virtualization') && node['virtualization']['system'] == 'lxc'
end

#openvz?(node) ⇒ Boolean

Determine if the current node is running under openvz.

Parameters:

Returns:

  • (Boolean)

    true if the machine is currently running under openvz, false otherwise



96
97
98
# File 'lib/chef/sugar/virtualization.rb', line 96

def openvz?(node)
  node.key?('virtualization') && node['virtualization']['system'] == 'openvz'
end

#parallels?(node) ⇒ Boolean

Determine if the current node is running under Parallels Desktop.

Parameters:

Returns:

  • (Boolean)

    true if the machine is currently running under Parallels Desktop, false otherwise



57
58
59
# File 'lib/chef/sugar/virtualization.rb', line 57

def parallels?(node)
  node.key?('virtualization') && node['virtualization']['system'] == 'parallels'
end

#physical?(node) ⇒ Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/chef/sugar/virtualization.rb', line 104

def physical?(node)
  !virtual?(node)
end

#virtual?(node) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/chef/sugar/virtualization.rb', line 100

def virtual?(node)
  openvz?(node) || vmware?(node) || virtualbox?(node) || parallels?(node) || lxc?(node) || kvm?(node)
end

#virtualbox?(node) ⇒ Boolean

Determine if the current node is running under VirtualBox.

Parameters:

Returns:

  • (Boolean)

    true if the machine is currently running under VirtualBox, false otherwise



70
71
72
# File 'lib/chef/sugar/virtualization.rb', line 70

def virtualbox?(node)
  node.key?('virtualization') && node['virtualization']['system'] == 'vbox'
end

#vmware?(node) ⇒ Boolean

Determine if the current node is running under VMware.

Parameters:

Returns:

  • (Boolean)

    true if the machine is currently running under VMware, false otherwise



83
84
85
# File 'lib/chef/sugar/virtualization.rb', line 83

def vmware?(node)
  node.key?('virtualization') && node['virtualization']['system'] == 'vmware'
end