Class: OneviewSDK::EthernetNetwork
- Defined in:
- lib/oneview-sdk/resource/ethernet_network.rb
Overview
Ethernet network resource implementation
Validates collapse
- VALID_ETHERNET_NETWORK_TYPES =
%w(NotApplicable Tagged Tunnel Unknown Untagged).freeze
- VALID_PURPOSES =
%w(FaultTolerance General Management VMMigration).freeze
Constant Summary collapse
- BASE_URI =
'/rest/ethernet-networks'.freeze
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Validates collapse
-
#validate_ethernetNetworkType(value) ⇒ Object
Validate ethernetNetworkType.
-
#validate_purpose(value) ⇒ Object
Validate purpose.
Class Method Summary collapse
-
.bulk_create(client, options) ⇒ Array
Bulk create ethernet networks.
Instance Method Summary collapse
-
#get_associated_profiles ⇒ Object
Get associatedProfiles.
-
#get_associated_uplink_groups ⇒ Object
Get associatedUplinkGroups.
-
#initialize(client, params = {}, api_ver = nil) ⇒ EthernetNetwork
constructor
A new instance of EthernetNetwork.
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) ⇒ EthernetNetwork
Returns a new instance of EthernetNetwork.
6 7 8 9 10 11 |
# File 'lib/oneview-sdk/resource/ethernet_network.rb', line 6 def initialize(client, params = {}, api_ver = nil) super # Default values: @data['ethernetNetworkType'] ||= 'Tagged' @data['type'] ||= 'ethernet-networkV3' end |
Class Method Details
.bulk_create(client, options) ⇒ Array
Bulk create ethernet networks
35 36 37 38 39 40 41 42 43 |
# File 'lib/oneview-sdk/resource/ethernet_network.rb', line 35 def self.bulk_create(client, ) range = [:vlanIdRange].split('-').map(&:to_i) [:type] = 'bulk-ethernet-network' response = client.rest_post(BASE_URI + '/bulk', { 'body' => }, client.api_version) client.response_handler(response) network_names = [] range[0].upto(range[1]) { |i| network_names << "#{[:namePrefix]}_#{i}" } OneviewSDK::EthernetNetwork.get_all(client).select { |network| network_names.include?(network['name']) } end |
Instance Method Details
#get_associated_profiles ⇒ Object
Get associatedProfiles
46 47 48 49 50 |
# File 'lib/oneview-sdk/resource/ethernet_network.rb', line 46 def get_associated_profiles ensure_client && ensure_uri response = @client.rest_get("#{@data['uri']}/associatedProfiles", @api_version) response.body end |
#get_associated_uplink_groups ⇒ Object
Get associatedUplinkGroups
53 54 55 56 57 |
# File 'lib/oneview-sdk/resource/ethernet_network.rb', line 53 def get_associated_uplink_groups ensure_client && ensure_uri response = @client.rest_get("#{@data['uri']}/associatedUplinkGroups", @api_version) response.body end |
#validate_ethernetNetworkType(value) ⇒ Object
Validate ethernetNetworkType
18 19 20 |
# File 'lib/oneview-sdk/resource/ethernet_network.rb', line 18 def validate_ethernetNetworkType(value) fail 'Invalid network type' unless VALID_ETHERNET_NETWORK_TYPES.include?(value) end |
#validate_purpose(value) ⇒ Object
Validate purpose
25 26 27 |
# File 'lib/oneview-sdk/resource/ethernet_network.rb', line 25 def validate_purpose(value) fail 'Invalid ethernet purpose' unless VALID_PURPOSES.include?(value) end |