Class: Puppet::Provider::PowerstoreFileSystem::PowerstoreFileSystem
- Inherits:
-
Object
- Object
- Puppet::Provider::PowerstoreFileSystem::PowerstoreFileSystem
- Defined in:
- lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb
Overview
class Puppet::Provider::PowerstoreFileSystem::PowerstoreFileSystem
Class Method Summary collapse
- .add_keys_to_request(request, hash) ⇒ Object
- .authenticate(_path_params, _query_params, _header_params, _body_params) ⇒ Object
- .build_key_values ⇒ Object
- .deep_delete(hash_item, tokens) ⇒ Object
- .fetch_all(context) ⇒ Object
- .fetch_all_as_hash(context) ⇒ Object
- .invoke_create(context, resource = nil, body_params = nil) ⇒ Object
- .invoke_delete(context, resource = nil, body_params = nil) ⇒ Object
- .invoke_get_one(context, resource = nil, body_params = nil) ⇒ Object
- .invoke_list_all(context, resource = nil, body_params = nil) ⇒ Object
- .invoke_update(context, resource = nil, body_params = nil) ⇒ Object
- .op_param(name, inquery, paramalias, namesnake) ⇒ Object
- .to_query(hash) ⇒ Object
Instance Method Summary collapse
- #build_create_hash(resource) ⇒ Object
-
#build_delete_hash(resource) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#build_hash(resource) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument.
- #build_update_hash(resource) ⇒ Object
- #canonicalize(_context, resources) ⇒ Object
- #create(context, name, should) ⇒ Object
- #delete(context, should) ⇒ Object
- #exists? ⇒ Boolean
- #get(context) ⇒ Object
- #set(context, changes, noop: false) ⇒ Object
- #update(context, name, should) ⇒ Object
Class Method Details
.add_keys_to_request(request, hash) ⇒ Object
456 457 458 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 456 def self.add_keys_to_request(request, hash) hash.each { |x, v| request[x] = v } if hash end |
.authenticate(_path_params, _query_params, _header_params, _body_params) ⇒ Object
445 446 447 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 445 def self.authenticate(_path_params, _query_params, _header_params, _body_params) true end |
.build_key_values ⇒ Object
168 169 170 171 172 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 168 def self.build_key_values key_values = {} key_values['api-version'] = 'assets' key_values end |
.deep_delete(hash_item, tokens) ⇒ Object
423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 423 def self.deep_delete(hash_item, tokens) if tokens.size == 1 if hash_item.is_a?(Array) hash_item.map! { |item| deep_delete(item, tokens) } else hash_item.delete(tokens[0]) unless hash_item.nil? || hash_item[tokens[0]].nil? end elsif hash_item.is_a?(Array) hash_item.map! { |item| deep_delete(item, tokens[1..-1]) } else hash_item[tokens.first] = deep_delete(hash_item[tokens.first], tokens[1..-1]) unless hash_item.nil? || hash_item[tokens[0]].nil? end hash_item end |
.fetch_all(context) ⇒ Object
438 439 440 441 442 443 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 438 def self.fetch_all(context) response = invoke_list_all(context) return unless response.is_a? Net::HTTPSuccess body = JSON.parse(response.body) body # ["value"] if body.is_a? Array # and body.key? "value" end |
.fetch_all_as_hash(context) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 369 def self.fetch_all_as_hash(context) items = fetch_all(context) if items items.map { |item| hash = { access_policy: item['access_policy'], access_policy_l10n: item['access_policy_l10n'], access_type: item['access_type'], access_type_l10n: item['access_type_l10n'], creation_timestamp: item['creation_timestamp'], creator_type: item['creator_type'], creator_type_l10n: item['creator_type_l10n'], default_hard_limit: item['default_hard_limit'], default_soft_limit: item['default_soft_limit'], description: item['description'], expiration_timestamp: item['expiration_timestamp'], filesystem_type: item['filesystem_type'], filesystem_type_l10n: item['filesystem_type_l10n'], folder_rename_policy: item['folder_rename_policy'], folder_rename_policy_l10n: item['folder_rename_policy_l10n'], grace_period: item['grace_period'], id: item['id'], is_async_m_time_enabled: item['is_async_MTime_enabled'], is_modified: item['is_modified'], is_quota_enabled: item['is_quota_enabled'], is_smb_no_notify_enabled: item['is_smb_no_notify_enabled'], is_smb_notify_on_access_enabled: item['is_smb_notify_on_access_enabled'], is_smb_notify_on_write_enabled: item['is_smb_notify_on_write_enabled'], is_smb_op_locks_enabled: item['is_smb_op_locks_enabled'], is_smb_sync_writes_enabled: item['is_smb_sync_writes_enabled'], last_refresh_timestamp: item['last_refresh_timestamp'], last_writable_timestamp: item['last_writable_timestamp'], locking_policy: item['locking_policy'], locking_policy_l10n: item['locking_policy_l10n'], name: item['name'], nas_server_id: item['nas_server_id'], parent_id: item['parent_id'], protection_policy_id: item['protection_policy_id'], size_total: item['size_total'], size_used: item['size_used'], smb_notify_on_change_dir_depth: item['smb_notify_on_change_dir_depth'], ensure: 'present', } Puppet.debug("Adding to collection: #{item}") hash }.compact else [] end rescue StandardError => ex Puppet.alert("ex is #{ex} and backtrace is #{ex.backtrace}") raise end |
.invoke_create(context, resource = nil, body_params = nil) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 215 def self.invoke_create(context, resource = nil, body_params = nil) key_values = build_key_values Puppet.info('Calling operation file_system_create') path_params = {} query_params = {} header_params = {} header_params['User-Agent'] = '' op_params = [ op_param('access_policy', 'body', 'access_policy', 'access_policy'), op_param('description', 'body', 'description', 'description'), op_param('folder_rename_policy', 'body', 'folder_rename_policy', 'folder_rename_policy'), op_param('is_async_MTime_enabled', 'body', 'is_async_m_time_enabled', 'is_async_m_time_enabled'), op_param('is_smb_no_notify_enabled', 'body', 'is_smb_no_notify_enabled', 'is_smb_no_notify_enabled'), op_param('is_smb_notify_on_access_enabled', 'body', 'is_smb_notify_on_access_enabled', 'is_smb_notify_on_access_enabled'), op_param('is_smb_notify_on_write_enabled', 'body', 'is_smb_notify_on_write_enabled', 'is_smb_notify_on_write_enabled'), op_param('is_smb_op_locks_enabled', 'body', 'is_smb_op_locks_enabled', 'is_smb_op_locks_enabled'), op_param('is_smb_sync_writes_enabled', 'body', 'is_smb_sync_writes_enabled', 'is_smb_sync_writes_enabled'), op_param('locking_policy', 'body', 'locking_policy', 'locking_policy'), op_param('name', 'body', 'name', 'name'), op_param('nas_server_id', 'body', 'nas_server_id', 'nas_server_id'), op_param('protection_policy_id', 'body', 'protection_policy_id', 'protection_policy_id'), op_param('size_total', 'body', 'size_total', 'size_total'), op_param('smb_notify_on_change_dir_depth', 'body', 'smb_notify_on_change_dir_depth', 'smb_notify_on_change_dir_depth'), ] op_params.each do |i| inquery = i[:inquery] name = i[:name] paramalias = i[:paramalias] name_snake = i[:namesnake] if inquery == 'query' query_params[name] = key_values[name] unless key_values[name].nil? query_params[name] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? query_params[name] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? else path_params[name_snake.to_sym] = key_values[name] unless key_values[name].nil? path_params[name_snake.to_sym] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? path_params[name_snake.to_sym] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? end end context.transport.call_op(path_params, query_params, header_params, body_params, '/file_system', 'Post', 'application/json') end |
.invoke_delete(context, resource = nil, body_params = nil) ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 307 def self.invoke_delete(context, resource = nil, body_params = nil) key_values = build_key_values Puppet.info('Calling operation file_system_delete') path_params = {} query_params = {} header_params = {} header_params['User-Agent'] = '' op_params = [ op_param('id', 'path', 'id', 'id'), ] op_params.each do |i| inquery = i[:inquery] name = i[:name] paramalias = i[:paramalias] name_snake = i[:namesnake] if inquery == 'query' query_params[name] = key_values[name] unless key_values[name].nil? query_params[name] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? query_params[name] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? else path_params[name_snake.to_sym] = key_values[name] unless key_values[name].nil? path_params[name_snake.to_sym] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? path_params[name_snake.to_sym] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? end end context.transport.call_op(path_params, query_params, header_params, body_params, '/file_system/%{id}', 'Delete', 'application/json') end |
.invoke_get_one(context, resource = nil, body_params = nil) ⇒ Object
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 339 def self.invoke_get_one(context, resource = nil, body_params = nil) key_values = build_key_values Puppet.info('Calling operation file_system_instance_query') path_params = {} query_params = {} header_params = {} header_params['User-Agent'] = '' op_params = [ op_param('id', 'path', 'id', 'id'), ] op_params.each do |i| inquery = i[:inquery] name = i[:name] paramalias = i[:paramalias] name_snake = i[:namesnake] if inquery == 'query' query_params[name] = key_values[name] unless key_values[name].nil? query_params[name] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? query_params[name] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? else path_params[name_snake.to_sym] = key_values[name] unless key_values[name].nil? path_params[name_snake.to_sym] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? path_params[name_snake.to_sym] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? end end context.transport.call_op(path_params, query_params, header_params, body_params, '/file_system/%{id}', 'Get', 'application/json') end |
.invoke_list_all(context, resource = nil, body_params = nil) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 186 def self.invoke_list_all(context, resource = nil, body_params = nil) key_values = build_key_values Puppet.info('Calling operation file_system_collection_query') path_params = {} query_params = {} header_params = {} header_params['User-Agent'] = '' op_params = [ ] op_params.each do |i| inquery = i[:inquery] name = i[:name] paramalias = i[:paramalias] name_snake = i[:namesnake] if inquery == 'query' query_params[name] = key_values[name] unless key_values[name].nil? query_params[name] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? query_params[name] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? else path_params[name_snake.to_sym] = key_values[name] unless key_values[name].nil? path_params[name_snake.to_sym] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? path_params[name_snake.to_sym] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? end end context.transport.call_op(path_params, query_params, header_params, body_params, '/file_system', 'Get', 'application/json') end |
.invoke_update(context, resource = nil, body_params = nil) ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 259 def self.invoke_update(context, resource = nil, body_params = nil) key_values = build_key_values Puppet.info('Calling operation file_system_modify') path_params = {} query_params = {} header_params = {} header_params['User-Agent'] = '' op_params = [ op_param('access_policy', 'body', 'access_policy', 'access_policy'), op_param('default_hard_limit', 'body', 'default_hard_limit', 'default_hard_limit'), op_param('default_soft_limit', 'body', 'default_soft_limit', 'default_soft_limit'), op_param('description', 'body', 'description', 'description'), op_param('expiration_timestamp', 'body', 'expiration_timestamp', 'expiration_timestamp'), op_param('folder_rename_policy', 'body', 'folder_rename_policy', 'folder_rename_policy'), op_param('grace_period', 'body', 'grace_period', 'grace_period'), op_param('id', 'path', 'id', 'id'), op_param('is_async_MTime_enabled', 'body', 'is_async_m_time_enabled', 'is_async_m_time_enabled'), op_param('is_quota_enabled', 'body', 'is_quota_enabled', 'is_quota_enabled'), op_param('is_smb_no_notify_enabled', 'body', 'is_smb_no_notify_enabled', 'is_smb_no_notify_enabled'), op_param('is_smb_notify_on_access_enabled', 'body', 'is_smb_notify_on_access_enabled', 'is_smb_notify_on_access_enabled'), op_param('is_smb_notify_on_write_enabled', 'body', 'is_smb_notify_on_write_enabled', 'is_smb_notify_on_write_enabled'), op_param('is_smb_op_locks_enabled', 'body', 'is_smb_op_locks_enabled', 'is_smb_op_locks_enabled'), op_param('is_smb_sync_writes_enabled', 'body', 'is_smb_sync_writes_enabled', 'is_smb_sync_writes_enabled'), op_param('locking_policy', 'body', 'locking_policy', 'locking_policy'), op_param('protection_policy_id', 'body', 'protection_policy_id', 'protection_policy_id'), op_param('size_total', 'body', 'size_total', 'size_total'), op_param('smb_notify_on_change_dir_depth', 'body', 'smb_notify_on_change_dir_depth', 'smb_notify_on_change_dir_depth'), ] op_params.each do |i| inquery = i[:inquery] name = i[:name] paramalias = i[:paramalias] name_snake = i[:namesnake] if inquery == 'query' query_params[name] = key_values[name] unless key_values[name].nil? query_params[name] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? query_params[name] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? else path_params[name_snake.to_sym] = key_values[name] unless key_values[name].nil? path_params[name_snake.to_sym] = ENV["powerstore_#{name_snake}"] unless ENV["powerstore_#{name_snake}"].nil? path_params[name_snake.to_sym] = resource[paramalias.to_sym] unless resource.nil? || resource[paramalias.to_sym].nil? end end context.transport.call_op(path_params, query_params, header_params, body_params, '/file_system/%{id}', 'Patch', 'application/json') end |
.op_param(name, inquery, paramalias, namesnake) ⇒ Object
468 469 470 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 468 def self.op_param(name, inquery, paramalias, namesnake) { name: name, inquery: inquery, paramalias: paramalias, namesnake: namesnake } end |
.to_query(hash) ⇒ Object
460 461 462 463 464 465 466 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 460 def self.to_query(hash) if hash return_value = hash.map { |x, v| "#{x}=#{v}" }.reduce { |x, v| "#{x}&#{v}" } return return_value unless return_value.nil? end '' end |
Instance Method Details
#build_create_hash(resource) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 79 def build_create_hash(resource) file_system = {} file_system['access_policy'] = resource[:access_policy] unless resource[:access_policy].nil? file_system['description'] = resource[:description] unless resource[:description].nil? file_system['folder_rename_policy'] = resource[:folder_rename_policy] unless resource[:folder_rename_policy].nil? file_system['is_async_MTime_enabled'] = resource[:is_async_m_time_enabled] unless resource[:is_async_m_time_enabled].nil? file_system['is_smb_no_notify_enabled'] = resource[:is_smb_no_notify_enabled] unless resource[:is_smb_no_notify_enabled].nil? file_system['is_smb_notify_on_access_enabled'] = resource[:is_smb_notify_on_access_enabled] unless resource[:is_smb_notify_on_access_enabled].nil? file_system['is_smb_notify_on_write_enabled'] = resource[:is_smb_notify_on_write_enabled] unless resource[:is_smb_notify_on_write_enabled].nil? file_system['is_smb_op_locks_enabled'] = resource[:is_smb_op_locks_enabled] unless resource[:is_smb_op_locks_enabled].nil? file_system['is_smb_sync_writes_enabled'] = resource[:is_smb_sync_writes_enabled] unless resource[:is_smb_sync_writes_enabled].nil? file_system['locking_policy'] = resource[:locking_policy] unless resource[:locking_policy].nil? file_system['name'] = resource[:name] unless resource[:name].nil? file_system['nas_server_id'] = resource[:nas_server_id] unless resource[:nas_server_id].nil? file_system['protection_policy_id'] = resource[:protection_policy_id] unless resource[:protection_policy_id].nil? file_system['size_total'] = resource[:size_total] unless resource[:size_total].nil? file_system['smb_notify_on_change_dir_depth'] = resource[:smb_notify_on_change_dir_depth] unless resource[:smb_notify_on_change_dir_depth].nil? file_system end |
#build_delete_hash(resource) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
121 122 123 124 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 121 def build_delete_hash(resource) file_system = {} file_system end |
#build_hash(resource) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 127 def build_hash(resource) file_system = {} file_system['access_policy'] = resource[:access_policy] unless resource[:access_policy].nil? file_system['access_policy_l10n'] = resource[:access_policy_l10n] unless resource[:access_policy_l10n].nil? file_system['access_type'] = resource[:access_type] unless resource[:access_type].nil? file_system['access_type_l10n'] = resource[:access_type_l10n] unless resource[:access_type_l10n].nil? file_system['creation_timestamp'] = resource[:creation_timestamp] unless resource[:creation_timestamp].nil? file_system['creator_type'] = resource[:creator_type] unless resource[:creator_type].nil? file_system['creator_type_l10n'] = resource[:creator_type_l10n] unless resource[:creator_type_l10n].nil? file_system['default_hard_limit'] = resource[:default_hard_limit] unless resource[:default_hard_limit].nil? file_system['default_soft_limit'] = resource[:default_soft_limit] unless resource[:default_soft_limit].nil? file_system['description'] = resource[:description] unless resource[:description].nil? file_system['expiration_timestamp'] = resource[:expiration_timestamp] unless resource[:expiration_timestamp].nil? file_system['filesystem_type'] = resource[:filesystem_type] unless resource[:filesystem_type].nil? file_system['filesystem_type_l10n'] = resource[:filesystem_type_l10n] unless resource[:filesystem_type_l10n].nil? file_system['folder_rename_policy'] = resource[:folder_rename_policy] unless resource[:folder_rename_policy].nil? file_system['folder_rename_policy_l10n'] = resource[:folder_rename_policy_l10n] unless resource[:folder_rename_policy_l10n].nil? file_system['grace_period'] = resource[:grace_period] unless resource[:grace_period].nil? file_system['id'] = resource[:id] unless resource[:id].nil? file_system['is_async_MTime_enabled'] = resource[:is_async_m_time_enabled] unless resource[:is_async_m_time_enabled].nil? file_system['is_modified'] = resource[:is_modified] unless resource[:is_modified].nil? file_system['is_quota_enabled'] = resource[:is_quota_enabled] unless resource[:is_quota_enabled].nil? file_system['is_smb_no_notify_enabled'] = resource[:is_smb_no_notify_enabled] unless resource[:is_smb_no_notify_enabled].nil? file_system['is_smb_notify_on_access_enabled'] = resource[:is_smb_notify_on_access_enabled] unless resource[:is_smb_notify_on_access_enabled].nil? file_system['is_smb_notify_on_write_enabled'] = resource[:is_smb_notify_on_write_enabled] unless resource[:is_smb_notify_on_write_enabled].nil? file_system['is_smb_op_locks_enabled'] = resource[:is_smb_op_locks_enabled] unless resource[:is_smb_op_locks_enabled].nil? file_system['is_smb_sync_writes_enabled'] = resource[:is_smb_sync_writes_enabled] unless resource[:is_smb_sync_writes_enabled].nil? file_system['last_refresh_timestamp'] = resource[:last_refresh_timestamp] unless resource[:last_refresh_timestamp].nil? file_system['last_writable_timestamp'] = resource[:last_writable_timestamp] unless resource[:last_writable_timestamp].nil? file_system['locking_policy'] = resource[:locking_policy] unless resource[:locking_policy].nil? file_system['locking_policy_l10n'] = resource[:locking_policy_l10n] unless resource[:locking_policy_l10n].nil? file_system['name'] = resource[:name] unless resource[:name].nil? file_system['nas_server_id'] = resource[:nas_server_id] unless resource[:nas_server_id].nil? file_system['parent_id'] = resource[:parent_id] unless resource[:parent_id].nil? file_system['protection_policy_id'] = resource[:protection_policy_id] unless resource[:protection_policy_id].nil? file_system['size_total'] = resource[:size_total] unless resource[:size_total].nil? file_system['size_used'] = resource[:size_used] unless resource[:size_used].nil? file_system['smb_notify_on_change_dir_depth'] = resource[:smb_notify_on_change_dir_depth] unless resource[:smb_notify_on_change_dir_depth].nil? file_system end |
#build_update_hash(resource) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 98 def build_update_hash(resource) file_system = {} file_system['access_policy'] = resource[:access_policy] unless resource[:access_policy].nil? file_system['default_hard_limit'] = resource[:default_hard_limit] unless resource[:default_hard_limit].nil? file_system['default_soft_limit'] = resource[:default_soft_limit] unless resource[:default_soft_limit].nil? file_system['description'] = resource[:description] unless resource[:description].nil? file_system['expiration_timestamp'] = resource[:expiration_timestamp] unless resource[:expiration_timestamp].nil? file_system['folder_rename_policy'] = resource[:folder_rename_policy] unless resource[:folder_rename_policy].nil? file_system['grace_period'] = resource[:grace_period] unless resource[:grace_period].nil? file_system['is_async_MTime_enabled'] = resource[:is_async_m_time_enabled] unless resource[:is_async_m_time_enabled].nil? file_system['is_quota_enabled'] = resource[:is_quota_enabled] unless resource[:is_quota_enabled].nil? file_system['is_smb_no_notify_enabled'] = resource[:is_smb_no_notify_enabled] unless resource[:is_smb_no_notify_enabled].nil? file_system['is_smb_notify_on_access_enabled'] = resource[:is_smb_notify_on_access_enabled] unless resource[:is_smb_notify_on_access_enabled].nil? file_system['is_smb_notify_on_write_enabled'] = resource[:is_smb_notify_on_write_enabled] unless resource[:is_smb_notify_on_write_enabled].nil? file_system['is_smb_op_locks_enabled'] = resource[:is_smb_op_locks_enabled] unless resource[:is_smb_op_locks_enabled].nil? file_system['is_smb_sync_writes_enabled'] = resource[:is_smb_sync_writes_enabled] unless resource[:is_smb_sync_writes_enabled].nil? file_system['locking_policy'] = resource[:locking_policy] unless resource[:locking_policy].nil? file_system['protection_policy_id'] = resource[:protection_policy_id] unless resource[:protection_policy_id].nil? file_system['size_total'] = resource[:size_total] unless resource[:size_total].nil? file_system['smb_notify_on_change_dir_depth'] = resource[:smb_notify_on_change_dir_depth] unless resource[:smb_notify_on_change_dir_depth].nil? file_system end |
#canonicalize(_context, resources) ⇒ Object
7 8 9 10 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 7 def canonicalize(_context, resources) # nout to do here but seems we need to implement it resources end |
#create(context, name, should) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 49 def create(context, name, should) context.creating(name) do new_hash = build_create_hash(should) new_hash.delete('id') response = self.class.invoke_create(context, should, new_hash) raise("Create failed. Response is #{response} and body is #{response.body}") unless response.is_a? Net::HTTPSuccess should[:ensure] = 'present' Puppet.info('Added :ensure to property hash') end rescue StandardError => ex Puppet.alert("Exception during create. The state of the resource is unknown. ex is #{ex} and backtrace is #{ex.backtrace}") raise end |
#delete(context, should) ⇒ Object
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 174 def delete(context, should) new_hash = build_delete_hash(should) response = self.class.invoke_delete(context, should, new_hash) raise("Delete failed. The state of the resource is unknown. Response is #{response} and body is #{response.body}") unless response.is_a? Net::HTTPSuccess should[:ensure] = 'absent' Puppet.info "Added 'absent' to property_hash" rescue StandardError => ex Puppet.alert("Exception during destroy. ex is #{ex} and backtrace is #{ex.backtrace}") raise end |
#exists? ⇒ Boolean
450 451 452 453 454 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 450 def exists? return_value = @property_hash[:ensure] && @property_hash[:ensure] != 'absent' Puppet.info("Checking if resource #{name} of type <no value> exists, returning #{return_value}") return_value end |
#get(context) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 12 def get(context) context.debug('Entered get') hash = self.class.fetch_all_as_hash(context) context.debug("Completed get, returning hash #{hash}") hash end |
#set(context, changes, noop: false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 19 def set(context, changes, noop: false) context.debug('Entered set') changes.each do |name, change| context.debug("set change with #{name} and #{change}") # FIXME: key[:name] below hardwires the unique key of the resource to be :name is = change.key?(:is) ? change[:is] : get(context).find { |key| key[:name] == name } should = change[:should] is = { name: name, ensure: 'absent' } if is.nil? should = { name: name, ensure: 'absent' } if should.nil? if is[:ensure].to_s == 'absent' && should[:ensure].to_s == 'present' create(context, name, should) unless noop elsif is[:ensure].to_s == 'present' && should[:ensure].to_s == 'absent' context.deleting(name) do # FIXME: hardwired should[:id] = is[:id] delete(context, should) unless noop end elsif is[:ensure].to_s == 'absent' && should[:ensure].to_s == 'absent' context.failed(name, message: 'Unexpected absent to absent change') elsif is[:ensure].to_s == 'present' && should[:ensure].to_s == 'present' # FIXME: hardwired should[:id] = is[:id] update(context, name, should) end end end |
#update(context, name, should) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/puppet/provider/powerstore_file_system/powerstore_file_system.rb', line 64 def update(context, name, should) context.updating(name) do new_hash = build_update_hash(should) new_hash.delete('id') response = self.class.invoke_update(context, should, new_hash) raise("Update failed. The state of the resource is unknown. Response is #{response} and body is #{response.body}") unless response.is_a? Net::HTTPSuccess should[:ensure] = 'present' Puppet.info('Added :ensure to property hash') end rescue StandardError => ex Puppet.alert("Exception during update. ex is #{ex} and backtrace is #{ex.backtrace}") raise end |