Skip to content

Commit

Permalink
Fixes #36649 - Remove katello-agent out of legacy UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chris1984 committed Aug 17, 2023
1 parent 4e3d804 commit 24fe5bb
Show file tree
Hide file tree
Showing 29 changed files with 72 additions and 352 deletions.
3 changes: 2 additions & 1 deletion engines/bastion_katello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ The only real difference, as far as the user is concerned, is that the applicati
# Running tests:

```
sudo yum -y install npm chromium-headless chromium
sudo dnf -y install epel-release epel-next-release
sudo dnf -y install npm chromium-headless chromium
cd ./engines/bastion_katello
sudo npm install -g grunt-cli
npm install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@
angular.module('Bastion.content-hosts').controller('ContentHostsBulkErrataModalController',
['$scope', '$http', '$location', '$window', '$timeout', '$uibModalInstance', 'HostBulkAction', 'HostCollection', 'Nutupane', 'CurrentOrganization', 'Erratum', 'Notification', 'BastionConfig', 'hostIds', 'newHostDetailsUI',
function ($scope, $http, $location, $window, $timeout, $uibModalInstance, HostBulkAction, HostCollection, Nutupane, CurrentOrganization, Erratum, Notification, BastionConfig, hostIds, newHostDetailsUI) {
function installParams() {
var params = hostIds;
params['content_type'] = 'errata';
params.content = _.map($scope.table.getSelected(), 'errata_id');

if ($scope.nutupane.table.allResultsSelected) {
params['install_all'] = true;
} else {
params['install_all'] = false;
}

params['organization_id'] = CurrentOrganization;
return params;
}

function fetchErratum(errataId) {
$scope.erratum = Erratum.get({id: errataId, 'organization_id': CurrentOrganization});
}
Expand All @@ -55,8 +40,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkErrataModalC
$scope.table.initialLoad = false;
$scope.initialLoad = true;
$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.remoteExecutionByDefault = BastionConfig.remoteExecutionByDefault;
$scope.katelloAgentPresent = BastionConfig.katelloAgentPresent;
$scope.allHostsSelected = hostIds.allResultsSelected;
$scope.hostToolingEnabled = BastionConfig.hostToolingEnabled;
$scope.newHostDetailsUI = newHostDetailsUI;
Expand Down Expand Up @@ -92,43 +75,19 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkErrataModalC
};

$scope.installErrata = function () {
if ($scope.remoteExecutionByDefault) {
$scope.installErrataViaRemoteExecution();

} else {
$scope.installErrataViaKatelloAgent(false);
}
};

$scope.installErrataViaKatelloAgent = function () {
var params = installParams();
HostBulkAction.installContent(params,
function (data) {
$scope.nutupane.invalidate();
$scope.ok();
$scope.transitionTo('content-hosts.bulk-task', {taskId: data.id});
},
function (response) {
angular.forEach(response.data.errors, function (error) {
Notification.setErrorMessage(error);
});
});
$scope.installErrataViaRemoteExecution();
};

$scope.selectedErrataIds = function () {
return $scope.nutupane.getAllSelectedResults('errata_id');
return $scope.table.getSelected();
};

$scope.installErrataViaRemoteExecution = function(customize) {
var errataIds = $scope.selectedErrataIds();
$scope.errataActionFormValues.bulkErrataIds = angular.toJson(errataIds);

$scope.errataActionFormValues.remoteAction = 'errata_install';
$scope.errataActionFormValues.bulkErrataIds = angular.toJson(errataIds);
$scope.errataActionFormValues.customize = customize;

$timeout(function () {
angular.element('#errataActionForm').submit();
}, 0);
};

$scope.ok = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkModuleStream
$scope.moduleStreamsNutupane.primaryOnly = true;
$scope.table = $scope.moduleStreamsNutupane.table;
$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.remoteExecutionByDefault = BastionConfig.remoteExecutionByDefault;

$scope.moduleStreamActionFormValues = {
authenticityToken: $window.AUTH_TOKEN.replace(/"/g, ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkPackagesModa
['$scope', '$location', '$timeout', '$window', '$uibModalInstance', 'HostBulkAction', 'CurrentOrganization', 'translate', 'Notification', 'BastionConfig', 'hostIds',
function ($scope, $location, $timeout, $window, $uibModalInstance, HostBulkAction, CurrentOrganization, translate, Notification, BastionConfig, hostIds) {

function successMessage(type) {
var messages = {
install: translate("Successfully scheduled package installation"),
update: translate("Successfully scheduled package update"),
remove: translate("Successfully scheduled package removal"),
"update all": translate("Successfully scheduled an update of all packages")
};
return messages[type];
}

function installParams() {
var params = hostIds;
params['content_type'] = $scope.content.contentType;
if ($scope.content.action === "update all") {
params['update_all'] = true;
params.content = null;
} else {
params.content = $scope.content.content.split(/ *, */);
}
params['organization_id'] = CurrentOrganization;
return params;
}

$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.remoteExecutionByDefault = BastionConfig.remoteExecutionByDefault;
$scope.katelloAgentPresent = BastionConfig.katelloAgentPresent;
$scope.hostToolingEnabled = BastionConfig.hostToolingEnabled;

$scope.packageActionFormValues = {
Expand Down Expand Up @@ -74,46 +49,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkPackagesModa
};

$scope.performContentAction = function () {
if ($scope.remoteExecutionByDefault) {
$scope.performViaRemoteExecution();
} else {
$scope.performViaKatelloAgent();
}
};

$scope.performViaKatelloAgent = function (action, actionInput) {
var success, error, params;

if (action) {
$scope.content.action = action;
}

if (actionInput) {
$scope.content.actionInput = actionInput;
}

$scope.content.confirm = false;

success = function () {
Notification.setSuccessMessage(successMessage($scope.content.action));
};

error = function (response) {
angular.forEach(response.data.errors, function (responseError) {
Notification.setErrorMessage(responseError);
});
};

params = installParams();
if ($scope.content.action === "install") {
HostBulkAction.installContent(params, success, error);
} else if ($scope.content.action === "update") {
HostBulkAction.updateContent(params, success, error);
} else if ($scope.content.action === "remove") {
HostBulkAction.removeContent(params, success, error);
} else if ($scope.content.action === "update all") {
HostBulkAction.updateContent(params, success, error);
}
$scope.performViaRemoteExecution();
};

$scope.performViaRemoteExecution = function(action, customize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ <h4 data-block="modal-header">Content Host Errata Management</h4>
</div>
</div>

<div ng-show="katelloAgentPresent" data-extend-template="common/views/katello-agent-notice.html"></div>
<div bst-feature-flag="remote_actions">
<p bst-alert="warning" ng-hide="hostToolingEnabled">
<span translate>
Performing host package actions is disabled because Katello is not configured for Remote Execution or Katello Agent.
Performing host package actions is disabled because Katello is not configured for Remote Execution.
</span>
</p>
</div>
Expand All @@ -58,7 +57,6 @@ <h4 data-block="modal-header">Content Host Errata Management</h4>
</button>

<ul uib-dropdown-menu class="dropdown-menu-right" role="menu" aria-labelledby="use-remote-execution">
<li ng-show="katelloAgentPresent" role="presentation"><a ng-click="installErrataViaKatelloAgent()" role="menuitem" translate>via Katello agent</a></li>
<li role="presentation"><a ng-click="installErrataViaRemoteExecution(false)" role="menuitem" translate>via remote execution</a></li>
<li role="presentation"><a ng-click="installErrataViaRemoteExecution(true)" role="menuitem" translate>via remote execution - customize first</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ <h4 data-block="modal-header" translate>Update Packages</h4>
</div>
</div>

<div ng-show="katelloAgentPresent" data-extend-template="common/views/katello-agent-notice.html"></div>
<div bst-feature-flag="remote_actions">
<p bst-alert="warning" ng-hide="hostToolingEnabled">
<span translate>
Performing host package actions is disabled because Katello is not configured for Remote Execution or Katello Agent.
Performing host package actions is disabled because Katello is not configured for Remote Execution.
</span>
</p>
<p bst-alert="warning">
Expand All @@ -38,7 +37,6 @@ <h4 data-block="modal-header" translate>Update Packages</h4>
<span class="caret"></span>
</button>
<ul uib-dropdown-menu role="menu" aria-labelledby="install-use-remote-execution">
<li ng-show="katelloAgentPresent" role="presentation"><a ng-click="performViaKatelloAgent('update all', content)" role="menuitem" tabindex="-1" href="#" translate>via Katello Agent</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('update all', false)" role="menuitem" tabindex="-1" href="#" translate>via remote execution</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('update all', true)" role="menuitem" tabindex="-1" href="#" translate>via remote execution - customize first</a></li>
</ul>
Expand Down Expand Up @@ -99,7 +97,6 @@ <h4 data-block="modal-header" translate>Update Packages</h4>
<span class="caret"></span>
</button>
<ul uib-dropdown-menu role="menu" aria-labelledby="install-use-remote-execution">
<li ng-show="katelloAgentPresent" role="presentation"><a ng-click="performViaKatelloAgent('install', content)" role="menuitem" tabindex="-1" href="#" translate>via Katello Agent</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('install', false)" role="menuitem" tabindex="-1" href="#" translate>via remote execution</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('install', true)" role="menuitem" tabindex="-1" href="#" translate>via remote execution - customize first</a></li>
</ul>
Expand All @@ -121,7 +118,6 @@ <h4 data-block="modal-header" translate>Update Packages</h4>
<span class="caret"></span>
</button>
<ul uib-dropdown-menu role="menu" aria-labelledby="update-use-remote-execution">
<li ng-show="katelloAgentPresent" role="presentation"><a ng-click="performViaKatelloAgent('update', content)" role="menuitem" tabindex="-1" href="#" translate>via Katello Agent</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('update', false)" role="menuitem" tabindex="-1" href="#" translate>via remote execution</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('update', true)" role="menuitem" tabindex="-1" href="#" translate>via remote execution - customize first</a></li>
</ul>
Expand All @@ -142,7 +138,6 @@ <h4 data-block="modal-header" translate>Update Packages</h4>
<span class="caret"></span>
</button>
<ul uib-dropdown-menu role="menu" aria-labelledby="remove-use-remote-execution">
<li ng-show="katelloAgentPresent" role="presentation"><a ng-click="performViaKatelloAgent('remove', content)" role="menuitem" tabindex="-1" href="#" translate>via Katello Agent</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('remove', false)" role="menuitem" tabindex="-1" href="#" translate>via remote execution</a></li>
<li role="presentation"><a ng-click="performViaRemoteExecution('remove', true)" role="menuitem" tabindex="-1" href="#" translate>via remote execution - customize first</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
* @requires ContentHostsHelper
* @requires simpleContentAccessEnabled
* @requires newHostDetailsUI
* @requires BastionConfig
*
* @description
* Provides the functionality specific to Content Hosts for use with the Nutupane UI pattern.
* Defines the columns to display and the transform function for how to generate each row
* within the table.
*/
angular.module('Bastion.content-hosts').controller('ContentHostsController',
['$scope', '$q', '$state', '$location', '$uibModal', 'translate', 'Nutupane', 'Host', 'HostBulkAction', 'Notification', 'CurrentOrganization', 'ContentHostsHelper', 'ContentHostsModalHelper', '$httpParamSerializer', 'simpleContentAccessEnabled', 'newHostDetailsUI', 'BastionConfig',
function ($scope, $q, $state, $location, $uibModal, translate, Nutupane, Host, HostBulkAction, Notification, CurrentOrganization, ContentHostsHelper, ContentHostsModalHelper, $httpParamSerializer, simpleContentAccessEnabled, newHostDetailsUI, BastionConfig) {
['$scope', '$q', '$state', '$location', '$uibModal', 'translate', 'Nutupane', 'Host', 'HostBulkAction', 'Notification', 'CurrentOrganization', 'ContentHostsHelper', 'ContentHostsModalHelper', '$httpParamSerializer', 'simpleContentAccessEnabled', 'newHostDetailsUI',
function ($scope, $q, $state, $location, $uibModal, translate, Nutupane, Host, HostBulkAction, Notification, CurrentOrganization, ContentHostsHelper, ContentHostsModalHelper, $httpParamSerializer, simpleContentAccessEnabled, newHostDetailsUI) {
var nutupane, params, query;

if ($location.search().search) {
Expand Down Expand Up @@ -52,7 +51,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostsController',
$scope.nutupane = nutupane;
$scope.simpleContentAccessEnabled = simpleContentAccessEnabled;
$scope.newHostDetailsUI = newHostDetailsUI;
$scope.katelloAgentPresent = BastionConfig.katelloAgentPresent;

// @TODO begin hack necessary because of foreman API bug http://projects.theforeman.org/issues/13877
$scope.table.sortBy = function (column) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostDebsApplicableCon
return $scope.getSelectedDebs().join(' ');
};

$scope.performDefaultUpdateAction = function () {
$scope.performRexUpdate = function () {
$scope.performViaRemoteExecution('packageUpdate', $scope.getRemoteExecutionCommand(), false);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostErrataController'
};

$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.remoteExecutionByDefault = BastionConfig.remoteExecutionByDefault;
$scope.katelloAgentPresent = BastionConfig.katelloAgentPresent;
$scope.hostToolingEnabled = BastionConfig.hostToolingEnabled;
$scope.errataActionFormValues = {
authenticityToken: $window.AUTH_TOKEN.replace(/&quot;/g, '')
Expand Down Expand Up @@ -124,15 +122,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostErrataController'
return $scope.nutupane.getAllSelectedResults('errata_id');
};

$scope.performViaKatelloAgent = function () {
var errataIds = $scope.selectedErrataIds();
HostErratum.apply({id: $scope.host.id, 'bulk_errata_ids': angular.toJson(errataIds)},
function (task) {
$scope.table.selectAll(false);
$scope.transitionTo('content-host.tasks.details', {taskId: task.id});
});
};

$scope.performViaRemoteExecution = function(customize) {
var errataIds = $scope.selectedErrataIds();

Expand All @@ -148,11 +137,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostErrataController'
};

$scope.applySelected = function () {
if ($scope.remoteExecutionByDefault) {
$scope.performViaRemoteExecution(false);
} else {
$scope.performViaKatelloAgent();
}
$scope.performViaRemoteExecution(false);
};

$scope.nutupane.enableSelectAllResults();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostModuleStreamsCont
$scope.table = $scope.moduleStreamsNutupane.table;

$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.remoteExecutionByDefault = BastionConfig.remoteExecutionByDefault;
$scope.moduleStreamActionFormValues = {
authenticityToken: $window.AUTH_TOKEN.replace(/&quot;/g, ''),
remoteAction: 'module_stream_action'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
angular.module('Bastion.content-hosts').controller('ContentHostPackagesActionsController',
['$scope', '$location', 'BastionConfig', function ($scope, $location, BastionConfig) {
var packageName = $location.search().package_name;
$scope.katelloAgentPresent = BastionConfig.katelloAgentPresent;
$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.hostToolingEnabled = BastionConfig.hostToolingEnabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostPackagesApplicabl
function ($scope, $timeout, $window, Package, HostPackage, translate, Nutupane, BastionConfig) {
var packagesNutupane, openEventInfo;

$scope.katelloAgentPresent = BastionConfig.katelloAgentPresent;
$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent;
$scope.hostToolingEnabled = BastionConfig.hostToolingEnabled;

Expand All @@ -35,16 +34,8 @@ angular.module('Bastion.content-hosts').controller('ContentHostPackagesApplicabl
return $scope.getSelectedPackages().join(' ');
};

$scope.getKatelloAgentCommand = function () {
return $scope.getSelectedPackages().join(',');
};

$scope.performDefaultUpdateAction = function () {
if ($scope.remoteExecutionByDefault) {
$scope.performViaRemoteExecution('packageUpdate', $scope.getRemoteExecutionCommand(), false);
} else {
$scope.performViaKatelloAgent('packageUpdate', $scope.getKatelloAgentCommand());
}
$scope.performRexUpdate = function () {
$scope.performViaRemoteExecution('packageUpdate', $scope.getRemoteExecutionCommand(), false);
};

packagesNutupane = new Nutupane(Package, {'host_id': $scope.$stateParams.hostId, 'packages_restrict_upgradable': true});
Expand Down
Loading

0 comments on commit 24fe5bb

Please sign in to comment.