Skip to content

Commit

Permalink
Added "Escalate Privilege" checkbox
Browse files Browse the repository at this point in the history
Added "Escalate Privilege" checkbox switch on both Provisioning & Retirement tabs in form and on Summary screen to display the selected values. Default value for the new checkbox is false.

https://bugzilla.redhat.com/show_bug.cgi?id=1445377
  • Loading branch information
h-kataria committed May 1, 2017
1 parent c27d8a1 commit 7523a3a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
provisioning_key: '',
provisioning_value: '',
provisioning_variables: {},
provisioning_become_enabled: false,
provisioning_editMode: false,
retirement_repository_id: '',
retirement_playbook_id: '',
Expand All @@ -33,6 +34,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
retirement_value: '',
retirement_variables: {},
retirement_editMode: false,
retirement_become_enabled: false,
};
getRemoveResourcesTypes();
vm.provisioning_cloud_type = '';
Expand Down Expand Up @@ -112,6 +114,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
vm.catalogItemModel.provisioning_dialog_name = configData.provision.new_dialog_name;
vm.catalogItemModel.provisioning_key = '';
vm.catalogItemModel.provisioning_value = '';
vm.catalogItemModel.provisioning_become_enabled = configData.provision.become_enabled
setExtraVars('provisioning_variables', configData.provision.extra_vars);

if (typeof configData.retirement.repository_id !== 'undefined') {
Expand All @@ -121,6 +124,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
vm.catalogItemModel.retirement_remove_resources = configData.retirement.remove_resources;
vm.catalogItemModel.retirement_machine_credential_id = configData.retirement.credential_id;
}
vm.catalogItemModel.retirement_become_enabled = configData.retirement.become_enabled
vm.catalogItemModel.retirement_network_credential_id = configData.retirement.network_credential_id;
vm.catalogItemModel.retirement_cloud_credential_id = setIfDefined(configData.retirement.cloud_credential_id);
vm.catalogItemModel.retirement_inventory = configData.retirement.hosts;
Expand Down Expand Up @@ -205,7 +209,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
}
}
}

catalog_item['config_info']['provision']['become_enabled'] = configData.provisioning_become_enabled;
if (configData.provisioning_network_credential_id !== '')
catalog_item['config_info']['provision']['network_credential_id'] = configData.provisioning_network_credential_id;

Expand All @@ -229,6 +233,9 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
retirement['playbook_id'] = configData.retirement_playbook_id;
retirement['credential_id'] = configData.retirement_machine_credential_id;
}
if (vm.catalogItemModel.retirement_playbook_id !== undefined && configData.retirement_playbook_id !== '') {
catalog_item['config_info']['retirement']['become_enabled'] = configData.retirement_become_enabled;
}
if (configData.retirement_network_credential_id !== '')
catalog_item['config_info']['retirement']['network_credential_id'] = configData.retirement_network_credential_id;

Expand Down Expand Up @@ -425,6 +432,12 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
return vm.catalogItemModel.retirement_repository_id !== '';
}

vm.retirement_playbook_selected = function(prefix) {
if (prefix === "provisioning")
return true;
return vm.catalogItemModel.retirement_playbook_id !== '';
}

vm.removeKeyValue = function(prefix, key) {
delete vm.catalogItemModel[prefix + "_variables"][key];
$scope.checkFormPristine();
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,7 @@ def fetch_playbook_details
playbook_details[:provisioning][:network_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::NetworkCredential, provision[:network_credential_id]) if provision[:network_credential_id]
playbook_details[:provisioning][:cloud_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential, provision[:cloud_credential_id]) if provision[:cloud_credential_id]
fetch_dialog(playbook_details, provision[:dialog_id], :provisioning)
playbook_details[:provisioning][:become_enabled] = provision[:become_enabled] == true ? _('Yes') : _('No')

if @record.config_info[:retirement]
retirement = @record.config_info[:retirement]
Expand All @@ -1813,6 +1814,7 @@ def fetch_playbook_details
playbook_details[:retirement][:network_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::NetworkCredential, retirement[:network_credential_id]) if retirement[:network_credential_id]
playbook_details[:retirement][:cloud_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential, retirement[:cloud_credential_id]) if retirement[:cloud_credential_id]
end
playbook_details[:retirement][:become_enabled] = retirement[:become_enabled] == true ? _('Yes') : _('No')
end
playbook_details
end
Expand Down
10 changes: 10 additions & 0 deletions app/views/catalog/_sandt_tree_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@
= _('Hosts')
.col-md-9
= h(@record.config_info[:provision][:hosts])
.form-group
%label.col-md-3.control-label
= _('Escalate Privilege')
.col-md-9
= h(provisioning[:become_enabled])
.col-md-12.col-lg-6
.form-horizontal.static
.form-group
Expand Down Expand Up @@ -297,6 +302,11 @@
= _('Hosts')
.col-md-9
= h(@record.config_info[:retirement][:hosts])
.form-group
%label.col-md-3.control-label
= _('Escalate Privilege')
.col-md-9
= h(retirement[:become_enabled])
.form-group
%label.col-md-3.control-label
= _('Remove Resources')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,18 @@
"checkchange" => true}
%span.help-block{"ng-show" => "angularForm.#{prefix}_inventory.$error.miqrequired"}
= _("Required")

#escalate_privilege{"ng-if" => "vm.retirement_playbook_selected('#{prefix}')"}
.form-group
%label.col-md-3.control-label
= _("Escalate Privilege")
.col-md-9
%input#become_enabled{"bs-switch" => "",
"type" => "checkbox",
"name" => "#{prefix}_become_enabled",
"ng-model" => "#{ng_model}.#{prefix}_become_enabled",
"switch-on-text" => _("Yes"),
"switch-off-text" => _("No"),
"checkchange" => ""}
- if prefix == "retirement"
.form-group
%label.col-md-3.control-label{"for" => "catalog_id"}
Expand Down
12 changes: 8 additions & 4 deletions spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,15 @@
:playbook => playbook.name,
:machine_credential => auth.name,
:dialog => "Some Label",
:dialog_id => dialog.id
:dialog_id => dialog.id,
:become_enabled => "No"
},
:retirement => {
:remove_resources => nil,
:repository => repository.name,
:playbook => playbook.name,
:machine_credential => auth.name
:machine_credential => auth.name,
:become_enabled => "No"
}
}
expect(playbook_details).to eq(st_details)
Expand Down Expand Up @@ -829,13 +831,15 @@
:provisioning => {
:repository => nil,
:playbook => playbook.name,
:machine_credential => auth.name
:machine_credential => auth.name,
:become_enabled => "No"
},
:retirement => {
:remove_resources => nil,
:repository => repository.name,
:playbook => nil,
:machine_credential => auth.name
:machine_credential => auth.name,
:become_enabled => "No"
}
}
expect(playbook_details).to eq(st_details)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('catalogItemFormController', function() {
'var1': {'default': 'default_val1'},
'var2': {'default': 'default_val2'}
},
become_enabled: undefined,
network_credential_id: undefined
},
retirement: {
Expand Down

0 comments on commit 7523a3a

Please sign in to comment.