Skip to content

Commit

Permalink
added button in service edit mode which enables user to check what cu…
Browse files Browse the repository at this point in the history
…rrently attached resources will comply with the selected capabilities.

also added a fix to the raw_update method: capabilities and resources will only be sent if they were edited.
  • Loading branch information
OrGur1987 committed Apr 20, 2023
1 parent 76687fc commit ed2d981
Showing 1 changed file with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ManageIQ::Providers::Autosde::StorageManager::StorageService < ::StorageSe
supports :create
supports :delete
supports :update
supports :check_compliant_resources

def self.raw_create_storage_service(ext_management_system, options = {})
capability_value_list = options.slice(*ext_management_system.capabilities.keys).values
Expand Down Expand Up @@ -46,13 +47,28 @@ def raw_delete_storage_service
end

def raw_update_storage_service(options = {})
capability_value_list = options.slice(*ext_management_system.capabilities.keys).values
capability_value_list.delete("-1")
# send resources only if edited
current_resources = storage_resources.ids
selected_resources = options["storage_resource_id"].to_a.pluck("value").map {|id| id.to_i}
resources = current_resources.sort == selected_resources.sort ? nil :
ext_management_system.storage_resources.find(options["storage_resource_id"].to_a.pluck("value")).pluck(:ems_ref)

# send capability_value_list only if edited
selected_capabilities_refs = options.slice(*ext_management_system.capabilities.keys).values
selected_capabilities_refs.delete("-1") # get rid of the N/A option
current_capabilities = ext_management_system.capabilities.slice(*capabilities.keys)
current_capabilities_refs = []
capabilities.each do |key, value|
current_capabilities[key].each do |cap|
current_capabilities_refs.push(cap["uuid"]) if cap["value"] == value
end
end
capability_value_list = current_capabilities_refs.sort == selected_capabilities_refs.sort ? nil : selected_capabilities_refs

update_details = ext_management_system.autosde_client.ServiceUpdate(
:name => options['name'],
:description => options['description'],
:resources => ext_management_system.storage_resources.find(options["storage_resource_id"].to_a.pluck("value")).pluck(:ems_ref),
:resources => resources,
:capability_id_list => capability_value_list
)

Expand All @@ -69,6 +85,17 @@ def raw_update_storage_service(options = {})
ext_management_system.class::EmsRefreshWorkflow.create_job(options).tap(&:signal_start)
end

def self.raw_check_compliant_resources(ext_management_system, options = {})
capability_value_list = options.slice(*ext_management_system.capabilities.keys).values
capability_value_list.delete("-1")

compliance_object = ext_management_system.autosde_client.ServiceResourcesCompliance(
:service => ext_management_system.storage_services.find(options["_id"]).ems_ref,
:capability_values => capability_value_list
)
ext_management_system.autosde_client.ServiceResourcesComplianceApi.service_resources_compliance_post(compliance_object)
end

def params_for_update
{
:fields => [
Expand Down

0 comments on commit ed2d981

Please sign in to comment.