-
-
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 26303a4
Showing
12 changed files
with
273 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,7 @@ Style/RescueModifier: | |
|
||
Metrics/MethodLength: | ||
Max: 45 | ||
|
||
Style/MutableConstant: | ||
Enabled: false | ||
|
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,24 @@ | ||
module Fog | ||
module Vsphere | ||
class Compute | ||
class NVMEController < Fog::Model | ||
attribute :type | ||
attribute :unit_number | ||
attribute :key, type: :integer | ||
attribute :server_id | ||
DEFAULT_KEY = 2000 | ||
DEFAULT_TYPE = "VirtualNVMEController" | ||
|
||
def initialize(attributes = {}) | ||
super | ||
self.key ||= DEFAULT_KEY | ||
self.type ||= DEFAULT_TYPE | ||
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
21 changes: 21 additions & 0 deletions
21
lib/fog/vsphere/requests/compute/get_vm_first_nvme_controller.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,21 @@ | ||
module Fog | ||
module Vsphere | ||
class Compute | ||
class Real | ||
def get_vm_first_nvme_controller(vm_id) | ||
ctrl = get_vm_ref(vm_id).config.hardware.device.find { |device| device.is_a?(RbVmomi::VIM::VirtualNVMEController) } | ||
raise Fog::Vsphere::Compute::NotFound, "No NVME controller found for #{vm_id}" unless ctrl | ||
{ | ||
type: ctrl&.class.to_s, | ||
device_info: ctrl&.deviceInfo, | ||
bus_number: ctrl&.busNumber, | ||
key: ctrl&.key | ||
} | ||
end | ||
end | ||
class Mock | ||
def get_vm_first_nvme_controller(vm_id); end | ||
end | ||
end | ||
end | ||
end |
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 |
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
Oops, something went wrong.