Class: OneviewSDK::LogicalSwitch
- Defined in:
- lib/oneview-sdk/resource/logical_switch.rb
Overview
Logical switch resource implementation
Defined Under Namespace
Classes: CredentialsSNMPV1, CredentialsSNMPV3, CredentialsSSH
Constant Summary collapse
- BASE_URI =
'/rest/logical-switches'.freeze
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 ⇒ 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 ⇒ Resource
Updates this object using the data that exists on OneView.
-
#set_logical_switch_group(logical_switch_group) ⇒ Object
Sets the logical switch group.
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #delete, #each, #eql?, #exists?, find_by, from_file, get_all, #like?, #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.
23 24 25 26 27 28 |
# File 'lib/oneview-sdk/resource/logical_switch.rb', line 23 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.
17 18 19 |
# File 'lib/oneview-sdk/resource/logical_switch.rb', line 17 def logical_switch_credentials @logical_switch_credentials end |
Instance Method Details
#create ⇒ OneviewSDK::LogicalSwitch
Create method
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/oneview-sdk/resource/logical_switch.rb', line 34 def create 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 response = @client.rest_post(self.class::BASE_URI, { 'body' => request_body }, @api_version) body = @client.response_handler(response) set_all(body) self end |
#refresh ⇒ Resource
Will overwrite any data that differs from OneView
Updates this object using the data that exists on OneView
49 50 51 52 |
# File 'lib/oneview-sdk/resource/logical_switch.rb', line 49 def refresh 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
91 92 93 |
# File 'lib/oneview-sdk/resource/logical_switch.rb', line 91 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
77 78 79 80 81 82 83 84 |
# File 'lib/oneview-sdk/resource/logical_switch.rb', line 77 def set_switch_credentials(host, ssh_credentials, snmp_credentials) fail TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSSH>' if ssh_credentials.class != OneviewSDK::LogicalSwitch::CredentialsSSH fail TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSNMP>' unless snmp_credentials.respond_to?('version') fail 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 |