-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a7f4e7
commit 2c9aa8e
Showing
7 changed files
with
116 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Fog | ||
module Vsphere | ||
class Compute | ||
class NVMEController < Fog::Model | ||
attribute :type | ||
attribute :unit_number | ||
attribute :key, type: :integer | ||
attribute :server_id | ||
|
||
def initialize(attributes = {}) | ||
super | ||
self.key ||= 2000 | ||
self.type ||= "VirtualNVMEController" | ||
end | ||
|
||
def to_s | ||
"#{type} ##{key}:, unit_number: #{unit_number}" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
lib/fog/vsphere/requests/compute/list_vm_nvme_controllers.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Fog | ||
module Vsphere | ||
class Compute | ||
class Real | ||
def list_vm_nvme_controllers(vm_id) | ||
list_vm_nvme_controllers_raw(vm_id).map do |raw_controller| | ||
Fog::Vsphere::Compute::NVMEController.new(raw_controller) | ||
end | ||
end | ||
|
||
def list_vm_nvme_controllers_raw(vm_id) | ||
get_vm_ref(vm_id).config.hardware.device.grep(RbVmomi::VIM::VirtualNVMEController).map do |ctrl| | ||
{ | ||
type: ctrl.class.to_s, | ||
key: ctrl.key | ||
} | ||
end | ||
end | ||
end | ||
class Mock | ||
def list_vm_nvme_controllers(vm_id) | ||
raise Fog::Vsphere::Compute::NotFound, 'VM not Found' unless data[:servers].key?(vm_id) | ||
return [] unless data[:servers][vm_id].key?('nvme_controllers') | ||
data[:servers][vm_id]['nvme_controllers'].map { |h| h.merge(server_id: vm_id) } | ||
end | ||
end | ||
end | ||
end | ||
end |