Class: OneviewSDK::ServerProfile
- Defined in:
- lib/oneview-sdk/resource/server_profile.rb
Overview
Server profile resource implementation
Constant Summary collapse
- BASE_URI =
'/rest/server-profiles'.freeze
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Instance Method Summary collapse
-
#available_hardware ⇒ Array<OneviewSDK::ServerHardware>
Get available server hardware for this template.
-
#initialize(client, params = {}, api_ver = nil) ⇒ ServerProfile
constructor
A new instance of ServerProfile.
- #validate_serverProfileTemplateUri ⇒ Object
- #validate_templateCompliance ⇒ Object
Methods inherited from Resource
#==, #[], #[]=, #create, #create!, #delete, #each, #eql?, #exists?, find_by, from_file, get_all, #like?, #refresh, #retrieve!, schema, #schema, #set, #set_all, #to_file, #update
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ ServerProfile
Returns a new instance of ServerProfile.
6 7 8 9 10 |
# File 'lib/oneview-sdk/resource/server_profile.rb', line 6 def initialize(client, params = {}, api_ver = nil) super # Default values @data['type'] ||= 'ServerProfileV5' end |
Instance Method Details
#available_hardware ⇒ Array<OneviewSDK::ServerHardware>
Get available server hardware for this template
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/oneview-sdk/resource/server_profile.rb', line 15 def available_hardware ensure_client fail 'Must set @data[\'serverHardwareTypeUri\']' unless @data['serverHardwareTypeUri'] fail 'Must set @data[\'enclosureGroupUri\']' unless @data['enclosureGroupUri'] params = { state: 'NoProfileApplied', serverHardwareTypeUri: @data['serverHardwareTypeUri'], serverGroupUri: @data['enclosureGroupUri'] } OneviewSDK::ServerHardware.find_by(@client, params) rescue StandardError => e raise "Failed to get available hardware. Message: #{e.}" end |
#validate_serverProfileTemplateUri ⇒ Object
29 30 31 |
# File 'lib/oneview-sdk/resource/server_profile.rb', line 29 def validate_serverProfileTemplateUri(*) fail "Templates only exist on api version >= 200. Resource version: #{@api_version}" if @api_version < 200 end |
#validate_templateCompliance ⇒ Object
33 34 35 |
# File 'lib/oneview-sdk/resource/server_profile.rb', line 33 def validate_templateCompliance(*) fail "Templates only exist on api version >= 200. Resource version: #{@api_version}" if @api_version < 200 end |