Class: OneviewSDK::ServerProfile

Inherits:
Resource
  • Object
show all
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

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_hardwareArray<OneviewSDK::ServerHardware>

Get available server hardware for this template

Returns:

  • (Array<OneviewSDK::ServerHardware>)

    Array of ServerHardware resources that matches this profile’s server hardware type and enclosure group and who’s state is ‘NoProfileApplied’



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.message}"
end

#validate_serverProfileTemplateUriObject



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_templateComplianceObject



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