Module: ChefUtils::DSL::Virtualization
- Extended by:
- Virtualization
- Includes:
- Internal
- Included in:
- ChefUtils, Virtualization
- Defined in:
- lib/chef-utils/dsl/virtualization.rb
Instance Method Summary collapse
-
#guest?(node = __getnode) ⇒ Boolean
(also: #virtual?)
Determine if the current node is running under any virtualization environment.
-
#hypervisor?(node = __getnode) ⇒ Boolean
Determine if the current node supports running guests under any virtualization environment.
-
#kvm?(node = __getnode) ⇒ Boolean
Determine if the current node is a KVM guest.
-
#kvm_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a KVM host.
-
#lxc?(node = __getnode) ⇒ Boolean
Determine if the current node is running in a linux container.
-
#lxc_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a linux container host.
-
#openvz?(node = __getnode) ⇒ Boolean
Determine if the current node is an openvz guest.
-
#openvz_host?(node = __getnode) ⇒ Boolean
Determine if the current node is an openvz host.
-
#parallels?(node = __getnode) ⇒ Boolean
Determine if the current node is running under Parallels Desktop.
-
#parallels_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a Parallels Desktop host.
-
#physical?(node = __getnode) ⇒ Boolean
Determine if the current node is NOT running under any virtualization environment (bare-metal or hypervisor on metal).
-
#vagrant?(node = __getnode) ⇒ Boolean
Determine if the current node is running as a vagrant guest.
-
#vbox?(node = __getnode) ⇒ Boolean
(also: #virtualbox?)
Determine if the current node is a VirtualBox guest.
-
#vbox_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a VirtualBox host.
-
#vmware?(node = __getnode) ⇒ Boolean
Determine if the current node is a VMWare guest.
-
#vmware_host?(node = __getnode) ⇒ Boolean
Determine if the current node is VMware host.
Instance Method Details
#guest?(node = __getnode) ⇒ Boolean Also known as: virtual?
Determine if the current node is running under any virtualization environment
171 172 173 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 171 def guest?(node = __getnode) node.dig("virtualization", "role") == "guest" end |
#hypervisor?(node = __getnode) ⇒ Boolean
Determine if the current node supports running guests under any virtualization environment
185 186 187 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 185 def hypervisor?(node = __getnode) node.dig("virtualization", "role") == "host" end |
#kvm?(node = __getnode) ⇒ Boolean
Determine if the current node is a KVM guest.
32 33 34 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 32 def kvm?(node = __getnode) node.dig("virtualization", "system") == "kvm" && node.dig("virtualization", "role") == "guest" end |
#kvm_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a KVM host.
43 44 45 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 43 def kvm_host?(node = __getnode) node.dig("virtualization", "system") == "kvm" && node.dig("virtualization", "role") == "host" end |
#lxc?(node = __getnode) ⇒ Boolean
Determine if the current node is running in a linux container.
54 55 56 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 54 def lxc?(node = __getnode) node.dig("virtualization", "system") == "lxc" && node.dig("virtualization", "role") == "guest" end |
#lxc_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a linux container host.
65 66 67 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 65 def lxc_host?(node = __getnode) node.dig("virtualization", "system") == "lxc" && node.dig("virtualization", "role") == "host" end |
#openvz?(node = __getnode) ⇒ Boolean
Determine if the current node is an openvz guest.
149 150 151 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 149 def openvz?(node = __getnode) node.dig("virtualization", "system") == "openvz" && node.dig("virtualization", "role") == "guest" end |
#openvz_host?(node = __getnode) ⇒ Boolean
Determine if the current node is an openvz host.
160 161 162 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 160 def openvz_host?(node = __getnode) node.dig("virtualization", "system") == "openvz" && node.dig("virtualization", "role") == "host" end |
#parallels?(node = __getnode) ⇒ Boolean
Determine if the current node is running under Parallels Desktop.
78 79 80 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 78 def parallels?(node = __getnode) node.dig("virtualization", "system") == "parallels" && node.dig("virtualization", "role") == "guest" end |
#parallels_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a Parallels Desktop host.
91 92 93 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 91 def parallels_host?(node = __getnode) node.dig("virtualization", "system") == "parallels" && node.dig("virtualization", "role") == "host" end |
#physical?(node = __getnode) ⇒ Boolean
Determine if the current node is NOT running under any virtualization environment (bare-metal or hypervisor on metal)
196 197 198 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 196 def physical?(node = __getnode) !virtual?(node) end |
#vagrant?(node = __getnode) ⇒ Boolean
Determine if the current node is running as a vagrant guest.
Note that this API is equivalent to just looking for the vagrant user or the vagrantup.com domain in the hostname, which is the best API we have.
212 213 214 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 212 def vagrant?(node = __getnode) vagrant_key?(node) || vagrant_domain?(node) || vagrant_user?(node) end |
#vbox?(node = __getnode) ⇒ Boolean Also known as: virtualbox?
Determine if the current node is a VirtualBox guest.
102 103 104 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 102 def vbox?(node = __getnode) node.dig("virtualization", "system") == "vbox" && node.dig("virtualization", "role") == "guest" end |
#vbox_host?(node = __getnode) ⇒ Boolean
Determine if the current node is a VirtualBox host.
113 114 115 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 113 def vbox_host?(node = __getnode) node.dig("virtualization", "system") == "vbox" && node.dig("virtualization", "role") == "host" end |
#vmware?(node = __getnode) ⇒ Boolean
Determine if the current node is a VMWare guest.
127 128 129 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 127 def vmware?(node = __getnode) node.dig("virtualization", "system") == "vmware" && node.dig("virtualization", "role") == "guest" end |
#vmware_host?(node = __getnode) ⇒ Boolean
Determine if the current node is VMware host.
138 139 140 |
# File 'lib/chef-utils/dsl/virtualization.rb', line 138 def vmware_host?(node = __getnode) node.dig("virtualization", "system") == "vmware" && node.dig("virtualization", "role") == "host" end |