Class: OneviewSDK::API200::LogicalSwitch
- Defined in:
- lib/oneview-sdk/resource/api200/logical_switch.rb
Overview
Logical switch resource implementation
Direct Known Subclasses
Defined Under Namespace
Classes: CredentialsSNMPV1, CredentialsSNMPV3, CredentialsSSH
Constant Summary collapse
- BASE_URI =
'/rest/logical-switches'.freeze
Constants inherited from Resource
Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS
Instance Attribute Summary collapse
-
#logical_switch_credentials ⇒ Object
Returns the value of attribute logical_switch_credentials.
Attributes inherited from Resource
#api_version, #client, #data, #logger
Credentials collapse
-
#set_switch_credentials(host, ssh_credentials, snmp_credentials) ⇒ Array
Sets switch credentials.
Instance Method Summary collapse
-
#create(header = {}) ⇒ OneviewSDK::LogicalSwitch
Create method.
-
#initialize(client, params = {}, api_ver = nil) ⇒ LogicalSwitch
constructor
Create a resource object, associate it with a client, and set its properties.
-
#refresh_state ⇒ Object
Reclaims the top-of-rack switches in a logical switch.
-
#set_logical_switch_group(logical_switch_group) ⇒ Object
Sets the logical switch group.
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #deep_merge!, #delete, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ LogicalSwitch
Create a resource object, associate it with a client, and set its properties.
26 27 28 29 30 31 |
# File 'lib/oneview-sdk/resource/api200/logical_switch.rb', line 26 def initialize(client, params = {}, api_ver = nil) super # Default values @data['type'] ||= 'logical-switch' @logical_switch_credentials = {} end |
Instance Attribute Details
#logical_switch_credentials ⇒ Object
Returns the value of attribute logical_switch_credentials.
20 21 22 |
# File 'lib/oneview-sdk/resource/api200/logical_switch.rb', line 20 def logical_switch_credentials @logical_switch_credentials end |
Instance Method Details
#create(header = {}) ⇒ OneviewSDK::LogicalSwitch
Create method
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/oneview-sdk/resource/api200/logical_switch.rb', line 38 def create(header = {}) ensure_client request_body = {} request_body['logicalSwitchCredentials'] = generate_logical_switch_credentials request_body['logicalSwitch'] = @data.clone request_body['logicalSwitch']['switchCredentialConfiguration'] = generate_logical_switch_credential_configuration = DEFAULT_REQUEST_HEADER.merge(header).merge('body' => request_body) response = @client.rest_post(self.class::BASE_URI, , @api_version) body = @client.response_handler(response) set_all(body) self end |
#refresh_state ⇒ Object
Reclaims the top-of-rack switches in a logical switch.
52 53 54 55 |
# File 'lib/oneview-sdk/resource/api200/logical_switch.rb', line 52 def refresh_state response = @client.rest_put(@data['uri'] + '/refresh') @client.response_handler(response) end |
#set_logical_switch_group(logical_switch_group) ⇒ Object
Sets the logical switch group
94 95 96 |
# File 'lib/oneview-sdk/resource/api200/logical_switch.rb', line 94 def set_logical_switch_group(logical_switch_group) @data['logicalSwitchGroupUri'] = logical_switch_group['uri'] end |
#set_switch_credentials(host, ssh_credentials, snmp_credentials) ⇒ Array
Sets switch credentials
80 81 82 83 84 85 86 87 |
# File 'lib/oneview-sdk/resource/api200/logical_switch.rb', line 80 def set_switch_credentials(host, ssh_credentials, snmp_credentials) raise TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSSH>' if ssh_credentials.class != OneviewSDK::LogicalSwitch::CredentialsSSH raise TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSNMP>' unless snmp_credentials.respond_to?('version') raise TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSNMP>' if snmp_credentials.version != 'SNMPv1' && snmp_credentials.version != 'SNMPv3' @logical_switch_credentials[host] = [ssh_credentials.clone, snmp_credentials.clone] @logical_switch_credentials[host] end |