oneview-sdk 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/CHANGELOG.md +81 -2
  4. data/README.md +118 -113
  5. data/Rakefile +11 -0
  6. data/lib/oneview-sdk/cli.rb +21 -15
  7. data/lib/oneview-sdk/client.rb +34 -21
  8. data/lib/oneview-sdk/config_loader.rb +12 -1
  9. data/lib/oneview-sdk/exceptions.rb +55 -0
  10. data/lib/oneview-sdk/resource/connection_template.rb +48 -0
  11. data/lib/oneview-sdk/resource/datacenter.rb +77 -0
  12. data/lib/oneview-sdk/resource/enclosure.rb +46 -24
  13. data/lib/oneview-sdk/resource/enclosure_group.rb +20 -36
  14. data/lib/oneview-sdk/resource/ethernet_network.rb +19 -23
  15. data/lib/oneview-sdk/resource/fabric.rb +41 -0
  16. data/lib/oneview-sdk/resource/fc_network.rb +15 -16
  17. data/lib/oneview-sdk/resource/fcoe_network.rb +15 -12
  18. data/lib/oneview-sdk/resource/firmware_bundle.rb +23 -24
  19. data/lib/oneview-sdk/resource/firmware_driver.rb +21 -9
  20. data/lib/oneview-sdk/resource/interconnect.rb +29 -9
  21. data/lib/oneview-sdk/resource/lig_uplink_set.rb +22 -28
  22. data/lib/oneview-sdk/resource/logical_downlink.rb +53 -0
  23. data/lib/oneview-sdk/resource/logical_enclosure.rb +35 -33
  24. data/lib/oneview-sdk/resource/logical_interconnect.rb +29 -65
  25. data/lib/oneview-sdk/resource/logical_interconnect_group.rb +26 -6
  26. data/lib/oneview-sdk/resource/logical_switch.rb +184 -0
  27. data/lib/oneview-sdk/resource/logical_switch_group.rb +66 -0
  28. data/lib/oneview-sdk/resource/managed_san.rb +79 -0
  29. data/lib/oneview-sdk/resource/network_set.rb +64 -0
  30. data/lib/oneview-sdk/resource/power_device.rb +174 -0
  31. data/lib/oneview-sdk/resource/rack.rb +83 -0
  32. data/lib/oneview-sdk/resource/san_manager.rb +88 -0
  33. data/lib/oneview-sdk/resource/server_hardware.rb +139 -18
  34. data/lib/oneview-sdk/resource/server_hardware_type.rb +32 -1
  35. data/lib/oneview-sdk/resource/server_profile.rb +352 -9
  36. data/lib/oneview-sdk/resource/server_profile_template.rb +193 -4
  37. data/lib/oneview-sdk/resource/storage_pool.rb +42 -20
  38. data/lib/oneview-sdk/resource/storage_system.rb +64 -14
  39. data/lib/oneview-sdk/resource/switch.rb +86 -0
  40. data/lib/oneview-sdk/resource/unmanaged_device.rb +55 -0
  41. data/lib/oneview-sdk/resource/uplink_set.rb +24 -64
  42. data/lib/oneview-sdk/resource/volume.rb +29 -29
  43. data/lib/oneview-sdk/resource/volume_attachment.rb +79 -0
  44. data/lib/oneview-sdk/resource/volume_snapshot.rb +20 -1
  45. data/lib/oneview-sdk/resource/volume_template.rb +22 -33
  46. data/lib/oneview-sdk/resource.rb +66 -28
  47. data/lib/oneview-sdk/rest.rb +69 -24
  48. data/lib/oneview-sdk/ssl_helper.rb +20 -9
  49. data/lib/oneview-sdk/version.rb +12 -1
  50. data/lib/oneview-sdk.rb +12 -0
  51. data/oneview-sdk.gemspec +11 -0
  52. metadata +17 -2
@@ -0,0 +1,55 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
12
+ # Contains all the custom Exception classes
13
+ module OneviewSDK
14
+ class ConnectionError < StandardError # Cannot connect to client/resource
15
+ end
16
+
17
+ class InvalidURL < StandardError # URL is invalid
18
+ end
19
+
20
+ class InvalidClient < StandardError # Client configuration is invalid
21
+ end
22
+
23
+ class InvalidResource < StandardError # Failed resource validations
24
+ end
25
+
26
+ class IncompleteResource < StandardError # Missing required resource data to complete action
27
+ end
28
+
29
+ class MethodUnavailable < StandardError # Resource does not support this method
30
+ end
31
+
32
+ class UnsupportedVersion < StandardError # Resource not supported on this API version
33
+ end
34
+
35
+ class InvalidRequest < StandardError # Could not make request
36
+ end
37
+
38
+ class BadRequest < StandardError # 400
39
+ end
40
+
41
+ class Unauthorized < StandardError # 401
42
+ end
43
+
44
+ class NotFound < StandardError # 404
45
+ end
46
+
47
+ class RequestError < StandardError # Other bad response codes
48
+ end
49
+
50
+ class TaskError < StandardError # Task ended in a bad state
51
+ end
52
+
53
+ class InvalidFormat < StandardError # File format is invalid
54
+ end
55
+ end
@@ -0,0 +1,48 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
12
+ module OneviewSDK
13
+ # Connection template resource implementation
14
+ class ConnectionTemplate < Resource
15
+ BASE_URI = '/rest/connection-templates'.freeze
16
+
17
+ # Create a resource object, associate it with a client, and set its properties.
18
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
19
+ # @param [Hash] params The options for this resource (key-value pairs)
20
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
21
+ def initialize(client, params = {}, api_ver = nil)
22
+ super
23
+ # Default values:
24
+ @data['bandwidth'] ||= {}
25
+ @data['type'] ||= 'connection-template'
26
+ end
27
+
28
+ # Method is not available
29
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
30
+ def create
31
+ unavailable_method
32
+ end
33
+
34
+ # Method is not available
35
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
36
+ def delete
37
+ unavailable_method
38
+ end
39
+
40
+ # Get the default network connection template
41
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
42
+ # @return [OneviewSDK::ConnectionTemplate] Connection template
43
+ def self.get_default(client)
44
+ response = client.rest_get(BASE_URI + '/defaultConnectionTemplate')
45
+ OneviewSDK::ConnectionTemplate.new(client, client.response_handler(response))
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,77 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ # specific language governing permissions and limitations under the License.
11
+
12
+ module OneviewSDK
13
+ # Datacenter resource implementation
14
+ class Datacenter < Resource
15
+ BASE_URI = '/rest/datacenters'.freeze
16
+
17
+ # Add the resource on OneView using the current data
18
+ # @note Calls the refresh method to set additional data
19
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
20
+ # @raise [StandardError] if the resource creation fails
21
+ # @return [OneviewSDK::Datacenter] self
22
+ alias add create
23
+
24
+ # Remove resource from OneView
25
+ # @return [true] if resource was removed successfully
26
+ alias remove delete
27
+
28
+ # Create a resource object, associate it with a client, and set its properties.
29
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
30
+ # @param [Hash] params The options for this resource (key-value pairs)
31
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
32
+ def initialize(client, params = {}, api_ver = nil)
33
+ super
34
+ # Default values:
35
+ @data['contents'] ||= []
36
+ end
37
+
38
+ # Method is not available
39
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
40
+ def create
41
+ unavailable_method
42
+ end
43
+
44
+ # Method is not available
45
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
46
+ def delete
47
+ unavailable_method
48
+ end
49
+
50
+ # Adds an existing rack to the datacenter
51
+ # @param [OneviewSDK::Rack] rack rack
52
+ # @param [Decimal] pos_x x position
53
+ # @param [Decimal] pos_y y position
54
+ # @param [Decimal] rotation Rotation degrees (0-359) around the center of the resource
55
+ def add_rack(rack, pos_x, pos_y, rotation = 0)
56
+ @data['contents'] << {
57
+ 'resourceUri' => rack['uri'],
58
+ 'x' => pos_x,
59
+ 'y' => pos_y,
60
+ 'rotation' => rotation
61
+ }
62
+ end
63
+
64
+ # Removes a rack from the datacenter
65
+ # @param [OneviewSDK::Rack] rack rack
66
+ def remove_rack(rack)
67
+ @data['contents'].reject! { |resource| resource['resourceUri'] == rack['uri'] }
68
+ end
69
+
70
+ # Gets a list of the visual content objects
71
+ # @return [Hash]
72
+ def get_visual_content
73
+ response = @client.rest_get(@data['uri'] + '/visualContent')
74
+ @client.response_handler(response)
75
+ end
76
+ end
77
+ end
@@ -1,3 +1,14 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
1
12
  require 'time'
2
13
  require 'date'
3
14
 
@@ -6,31 +17,40 @@ module OneviewSDK
6
17
  class Enclosure < Resource
7
18
  BASE_URI = '/rest/enclosures'.freeze
8
19
 
20
+ # Remove resource from OneView
21
+ # @return [true] if resource was removed successfully
22
+ alias remove delete
23
+
24
+ # Create a resource object, associate it with a client, and set its properties.
25
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
26
+ # @param [Hash] params The options for this resource (key-value pairs)
27
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
9
28
  def initialize(client, params = {}, api_ver = nil)
10
29
  super
11
30
  # Default values:
12
31
  @data['type'] ||= 'EnclosureV200'
13
32
  end
14
33
 
15
- # @!group Validates
16
34
 
17
- VALID_LICENSING_INTENTS = %w(NotApplicable OneView OneViewNoiLO OneViewStandard).freeze
18
- def validate_licensingIntent(value)
19
- fail 'Invalid licensingIntent' unless VALID_LICENSING_INTENTS.include?(value) || value.nil?
35
+ # Method is not available
36
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
37
+ def create
38
+ unavailable_method
20
39
  end
21
40
 
22
- VALID_REFRESH_STATES = %w(NotRefreshing RefreshFailed RefreshPending Refreshing).freeze
23
- def validate_refreshState(value)
24
- fail 'Invalid refreshState' unless VALID_REFRESH_STATES.include?(value)
41
+ # Method is not available
42
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
43
+ def delete
44
+ unavailable_method
25
45
  end
26
46
 
27
- # @!endgroup
28
-
29
47
  # Claim/configure the enclosure and its components to the appliance
30
- def create
48
+ # @note Calls the refresh method to set additional data
49
+ # @return [OneviewSDK::Enclosure] self
50
+ def add
31
51
  ensure_client
32
52
  required_attributes = %w(enclosureGroupUri hostname username password licensingIntent)
33
- required_attributes.each { |k| fail "Missing required attribute: '#{k}'" unless @data.key?(k) }
53
+ required_attributes.each { |k| fail IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) }
34
54
 
35
55
  optional_attrs = %w(enclosureUri firmwareBaselineUri force forceInstallFirmware state unmanagedEnclosure updateFirmwareOn)
36
56
  temp_data = @data.select { |k, _v| required_attributes.include?(k) || optional_attrs.include?(k) }
@@ -44,7 +64,9 @@ module OneviewSDK
44
64
  self
45
65
  end
46
66
 
47
- # Override update operation because only the name and rackName can be updated (& it uses PATCH).
67
+ # Overrides the update operation because only the name and rackName can be updated (and it uses PATCH).
68
+ # @param [Hash] attributes attributes to be updated
69
+ # @return [OneviewSDK::Enclosure] self
48
70
  def update(attributes = {})
49
71
  set_all(attributes)
50
72
  ensure_client && ensure_uri
@@ -62,7 +84,7 @@ module OneviewSDK
62
84
  self
63
85
  end
64
86
 
65
- # Reapply enclosure configuration
87
+ # Reapplies the enclosure configuration
66
88
  def configuration
67
89
  ensure_client && ensure_uri
68
90
  response = @client.rest_put(@data['uri'] + '/configuration', {}, @api_version)
@@ -71,13 +93,12 @@ module OneviewSDK
71
93
  end
72
94
 
73
95
 
74
- # Refresh enclosure along with all of its components
96
+ # Refreshes the enclosure along with all of its components
75
97
  # @param [String] state NotRefreshing, RefreshFailed, RefreshPending, Refreshing
76
98
  # @param [Hash] options Optional force fields for refreshing the enclosure
77
99
  def set_refresh_state(state, options = {})
78
100
  ensure_client && ensure_uri
79
101
  s = state.to_s rescue state
80
- validate_refreshState(s) # Validate refreshState
81
102
  requestBody = {
82
103
  'body' => {
83
104
  refreshState: s,
@@ -89,7 +110,7 @@ module OneviewSDK
89
110
  set_all(new_data)
90
111
  end
91
112
 
92
- # Get enclosure script content
113
+ # Gets the enclosure script content
93
114
  # @return [String] Script content
94
115
  def script
95
116
  ensure_client && ensure_uri
@@ -97,7 +118,8 @@ module OneviewSDK
97
118
  @client.response_handler(response)
98
119
  end
99
120
 
100
- # Get settings that describe the environmental configuration
121
+ # Gets the enclosure settings that describe the environmental configuration
122
+ # @return [Hash] The enclosure envirnomental configuration
101
123
  def environmental_configuration
102
124
  ensure_client && ensure_uri
103
125
  response = @client.rest_get(@data['uri'] + '/environmentalConfiguration', @api_version)
@@ -133,37 +155,37 @@ module OneviewSDK
133
155
  @client.response_handler(response)
134
156
  end
135
157
 
136
- # Update specific attributes of a given enclosure resource
158
+ # Updates specific attributes of a given enclosure resource
137
159
  # @param [String] operation operation to be performed
138
160
  # @param [String] path path
139
161
  # @param [String] value value
140
- def update_attribute(operation, path, value)
162
+ def patch(operation, path, value)
141
163
  ensure_client && ensure_uri
142
164
  response = @client.rest_patch(@data['uri'], { 'body' => [{ op: operation, path: path, value: value }] }, @api_version)
143
165
  @client.response_handler(response)
144
166
  end
145
167
 
146
- # Associates one Enclosure Group to the enclosure to be added
168
+ # Associates an enclosure group to the enclosure
147
169
  # @param [OneviewSDK<Resource>] eg Enclosure Group associated
148
170
  def set_enclosure_group(eg)
149
171
  eg.retrieve! unless eg['uri']
150
172
  @data['enclosureGroupUri'] = eg['uri']
151
173
  end
152
174
 
153
-
154
175
  private
155
176
 
156
- # Convert Date, Time, or String objects to iso8601 string
177
+ # Converts Date, Time, or String objects to iso8601 string
178
+ # @raise [InvalidResource] if time is not formatted correctly
157
179
  def convert_time(t)
158
180
  case t
159
181
  when nil then nil
160
182
  when Date then t.to_time.utc.iso8601(3)
161
183
  when Time then t.utc.iso8601(3)
162
184
  when String then Time.parse(t).utc.iso8601(3)
163
- else fail "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
185
+ else fail InvalidResource, "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
164
186
  end
165
187
  rescue StandardError => e
166
- raise "Failed to parse time value '#{t}'. #{e.message}"
188
+ raise InvalidResource, "Failed to parse time value '#{t}'. #{e.message}"
167
189
  end
168
190
  end
169
191
  end
@@ -1,8 +1,23 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
1
12
  module OneviewSDK
2
13
  # Enclosure group resource implementation
3
14
  class EnclosureGroup < Resource
4
15
  BASE_URI = '/rest/enclosure-groups'.freeze
5
16
 
17
+ # Create a resource object, associate it with a client, and set its properties.
18
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
19
+ # @param [Hash] params The options for this resource (key-value pairs)
20
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
6
21
  def initialize(client, params = {}, api_ver = nil)
7
22
  super
8
23
  # Default values:
@@ -11,47 +26,16 @@ module OneviewSDK
11
26
  create_interconnect_bay_mapping unless @data['interconnectBayMappings']
12
27
  end
13
28
 
14
- # @!group Validates
15
-
16
- VALID_INTERCONNECT_BAY_MAPPING_COUNTS = (1..8).freeze
17
- def validate_interconnectBayMappingCount(value)
18
- fail 'Interconnect Bay Mapping Count out of range 1..8' unless VALID_INTERCONNECT_BAY_MAPPING_COUNTS.include?(value)
19
- end
20
-
21
- VALID_IP_ADDRESSING_MODES = %w(DHCP External IpPool).freeze
22
- def validate_ipAddressingMode(value)
23
- return if !@data['enclosureTypeUri'] || /c7000/ =~ @data['enclosureTypeUri']
24
- is_not_a_c7000_without_ip_addressing_mode = !(/c7000/ =~ @data['enclosureTypeUri']) && !value
25
- fail "Invalid ip AddressingMode: #{value}" if !VALID_IP_ADDRESSING_MODES.include?(value) || is_not_a_c7000_without_ip_addressing_mode
26
- end
27
-
28
- VALID_PORT_MAPPING_COUNTS = (0..8).freeze
29
- def validate_portMappingCount(value)
30
- fail 'Port Mapping Count out of range 0..8' unless VALID_PORT_MAPPING_COUNTS.include?(value)
31
- end
32
-
33
- VALID_POWER_MODES = ['RedundantPowerFeed', 'RedundantPowerSupply', nil].freeze
34
- def validate_powerMode(value)
35
- fail 'Invalid powerMode' unless VALID_POWER_MODES.include?(value)
36
- end
37
-
38
- VALID_STACKING_MODES = %w(Enclosure MultiEnclosure None SwitchPairs).freeze
39
- def validate_stackingMode(value)
40
- fail 'Invalid stackingMode' unless VALID_STACKING_MODES.include?(value)
41
- end
42
-
43
- # @!endgroup
44
-
45
29
  # Get the script executed by enclosures in this enclosure group
46
- # @return [String] script for this enclosure group
30
+ # @return [String] The script for this enclosure group
47
31
  def get_script
48
32
  ensure_client && ensure_uri
49
33
  response = @client.rest_get(@data['uri'] + '/script', @api_version)
50
34
  @client.response_handler(response)
51
35
  end
52
36
 
53
- # Change the script executed by enclosures in this enclosure group
54
- # @param [String] body script to be executed
37
+ # Changes the script executed by the enclosures in this enclosure group
38
+ # @param [String] body The script to be executed
55
39
  # @return true if set successfully
56
40
  def set_script(body)
57
41
  ensure_client && ensure_uri
@@ -60,7 +44,7 @@ module OneviewSDK
60
44
  true
61
45
  end
62
46
 
63
- # Add logical interconnect group
47
+ # Adds the logical interconnect group
64
48
  # @param [OneviewSDK::LogicalInterconnectGroup] lig Logical Interconnect Group
65
49
  def add_logical_interconnect_group(lig)
66
50
  lig.retrieve! unless lig['uri']
@@ -71,7 +55,7 @@ module OneviewSDK
71
55
  end
72
56
  end
73
57
 
74
- # Create interconnect bay mapping
58
+ # Creates the interconnect bay mapping
75
59
  def create_interconnect_bay_mapping
76
60
  @data['interconnectBayMappings'] = []
77
61
  1.upto(@data['interconnectBayMappingCount']) do |bay_number|
@@ -1,8 +1,23 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
1
12
  module OneviewSDK
2
13
  # Ethernet network resource implementation
3
14
  class EthernetNetwork < Resource
4
15
  BASE_URI = '/rest/ethernet-networks'.freeze
5
16
 
17
+ # Create a resource object, associate it with a client, and set its properties.
18
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
19
+ # @param [Hash] params The options for this resource (key-value pairs)
20
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
6
21
  def initialize(client, params = {}, api_ver = nil)
7
22
  super
8
23
  # Default values:
@@ -10,26 +25,8 @@ module OneviewSDK
10
25
  @data['type'] ||= 'ethernet-networkV3'
11
26
  end
12
27
 
13
- # @!group Validates
14
-
15
- VALID_ETHERNET_NETWORK_TYPES = %w(NotApplicable Tagged Tunnel Unknown Untagged).freeze
16
- # Validate ethernetNetworkType
17
- # @param [String] value Notapplicable, Tagged, Tunnel, Unknown, Untagged
18
- def validate_ethernetNetworkType(value)
19
- fail 'Invalid network type' unless VALID_ETHERNET_NETWORK_TYPES.include?(value)
20
- end
21
-
22
- VALID_PURPOSES = %w(FaultTolerance General Management VMMigration).freeze
23
- # Validate purpose
24
- # @param [String] value FaultTolerance, General, Management, VMMigration
25
- def validate_purpose(value)
26
- fail 'Invalid ethernet purpose' unless VALID_PURPOSES.include?(value)
27
- end
28
-
29
- # @!endgroup
30
-
31
- # Bulk create ethernet networks
32
- # @param [Client] client client to connect with OneView
28
+ # Bulk create the ethernet networks
29
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
33
30
  # @param [Hash] options information necessary to create networks
34
31
  # @return [Array] list of ethernet networks created
35
32
  def self.bulk_create(client, options)
@@ -42,19 +39,18 @@ module OneviewSDK
42
39
  OneviewSDK::EthernetNetwork.get_all(client).select { |network| network_names.include?(network['name']) }
43
40
  end
44
41
 
45
- # Get associatedProfiles
42
+ # Gets the associated profiles
46
43
  def get_associated_profiles
47
44
  ensure_client && ensure_uri
48
45
  response = @client.rest_get("#{@data['uri']}/associatedProfiles", @api_version)
49
46
  response.body
50
47
  end
51
48
 
52
- # Get associatedUplinkGroups
49
+ # Gets the associated uplink groups
53
50
  def get_associated_uplink_groups
54
51
  ensure_client && ensure_uri
55
52
  response = @client.rest_get("#{@data['uri']}/associatedUplinkGroups", @api_version)
56
53
  response.body
57
54
  end
58
-
59
55
  end
60
56
  end
@@ -0,0 +1,41 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
12
+ module OneviewSDK
13
+ # FC network resource implementation
14
+ class Fabric < Resource
15
+ BASE_URI = '/rest/fabrics'.freeze
16
+
17
+ # Method is not available
18
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
19
+ def create
20
+ unavailable_method
21
+ end
22
+
23
+ # Method is not available
24
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
25
+ def update
26
+ unavailable_method
27
+ end
28
+
29
+ # Method is not available
30
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
31
+ def delete
32
+ unavailable_method
33
+ end
34
+
35
+ # Method is not available
36
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
37
+ def refresh
38
+ unavailable_method
39
+ end
40
+ end
41
+ end
@@ -1,8 +1,23 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
1
12
  module OneviewSDK
2
13
  # FC network resource implementation
3
14
  class FCNetwork < Resource
4
15
  BASE_URI = '/rest/fc-networks'.freeze
5
16
 
17
+ # Create a resource object, associate it with a client, and set its properties.
18
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
19
+ # @param [Hash] params The options for this resource (key-value pairs)
20
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
6
21
  def initialize(client, params = {}, api_ver = nil)
7
22
  super
8
23
  # Default values
@@ -11,21 +26,5 @@ module OneviewSDK
11
26
  @data['linkStabilityTime'] ||= 30
12
27
  @data['fabricType'] ||= 'FabricAttach'
13
28
  end
14
-
15
- # @!group Validates
16
-
17
- VALID_FABRIC_TYPES = %w(DirectAttach FabricAttach).freeze
18
- def validate_fabricType(value)
19
- fail 'Invalid fabric type' unless VALID_FABRIC_TYPES.include?(value)
20
- end
21
-
22
- VALID_LINK_STABILITY_TIMES = (1..1800).freeze
23
- def validate_linkStabilityTime(value)
24
- return unless @data['fabricType'] && @data['fabricType'] == 'FabricAttach'
25
- fail 'Link stability time out of range 1..1800' unless VALID_LINK_STABILITY_TIMES.include?(value)
26
- end
27
-
28
- # @!endgroup
29
-
30
29
  end
31
30
  end
@@ -1,25 +1,28 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
1
12
  module OneviewSDK
2
13
  # FCoE network resource implementation
3
14
  class FCoENetwork < Resource
4
15
  BASE_URI = '/rest/fcoe-networks'.freeze
5
16
 
17
+ # Create a resource object, associate it with a client, and set its properties.
18
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
19
+ # @param [Hash] params The options for this resource (key-value pairs)
20
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
6
21
  def initialize(client, params = {}, api_ver = nil)
7
22
  super
8
23
  # Default values:
9
24
  @data['connectionTemplateUri'] ||= nil
10
25
  @data['type'] ||= 'fcoe-network'
11
26
  end
12
-
13
- # @!group Validates
14
-
15
- VALID_VLAN_IDS = (1..4094).freeze
16
- # Validate vlanId
17
- # @param [Fixnum] value 1..4094
18
- def validate_vlanId(value)
19
- fail 'vlanId out of range 1..4094' unless VALID_VLAN_IDS.include?(value)
20
- end
21
-
22
- # @!endgroup
23
-
24
27
  end
25
28
  end