Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4865 from adamruzicka/dynflow-system-update
Fixes #6184 - Dynflowizes system update
- Loading branch information
Showing
13 changed files
with
237 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/lib/actions/candlepin/consumer/refresh_subscriptions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Copyright 2014 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Actions | ||
module Candlepin | ||
module Consumer | ||
class RefreshSubscrpitions < Candlepin::Abstract | ||
input_format do | ||
param :uuid, String | ||
end | ||
|
||
def plan(system, sys_params) | ||
plan_self(:uuid => system.uuid) if sys_params[:autoheal] | ||
end | ||
|
||
def run | ||
::Katello::Resources::Candlepin::Consumer.refresh_entitlements(input[:uuid]) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# Copyright 2014 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Actions | ||
module Candlepin | ||
module Consumer | ||
class Update < Candlepin::Abstract | ||
def plan(system) | ||
plan_self(:uuid => system.uuid, | ||
:facts => system.facts, | ||
:guestIds => system.guestIds, | ||
:installedProducts => system.installedProducts, | ||
:autoheal => system.autoheal, | ||
:releaseVer => system.releaseVer, | ||
:serviceLevel => system.serviceLevel, | ||
:cp_environment_id => system.cp_environment_id, | ||
:capabilities => system.capabilities, | ||
:lastCheckin => system.lastCheckin) | ||
end | ||
|
||
def run | ||
::Katello::Resources::Candlepin::Consumer.update(input[:uuid], | ||
input[:facts], | ||
input[:guestIds], | ||
input[:installedProducts], | ||
input[:autoheal], | ||
input[:releaseVer], | ||
input[:serviceLevel], | ||
input[:cp_environment_id], | ||
input[:capabilities], | ||
input[:lastCheckin]) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# | ||
# Copyright 2014 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Actions | ||
module Katello | ||
module Foreman | ||
class HostUpdate < Actions::EntryAction | ||
input_format do | ||
param :system_id, Integer | ||
param :environment_id, Integer | ||
end | ||
|
||
def plan(system) | ||
if system.foreman_host && | ||
system.foreman_host.environment.lifecycle_environment && | ||
system.foreman_host.environment.content_view | ||
|
||
if puppet_env = system.content_view.puppet_env(system.environment).try(:puppet_environment) | ||
if puppet_env.id != system.foreman_host.environment_id | ||
plan_self(:system_id => system.id, :environment_id => puppet_env.id) | ||
end | ||
else | ||
fail Errors::NotFound, | ||
_("Couldn't find puppet environment associated with lifecycle environment '%{env}' and content view '%{view}'") % | ||
{ :env => system.environment.name, :view => system.content_view.name } | ||
end | ||
end | ||
end | ||
|
||
def run | ||
system = ::Katello::System.find(input[:system_id]) | ||
system.foreman_host.environment_id = input[:environment_id] | ||
system.foreman_host.save! | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Copyright 2014 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Actions | ||
module Katello | ||
module System | ||
class Update < Actions::EntryAction | ||
middleware.use ::Actions::Middleware::RemoteAction | ||
|
||
def plan(system, sys_params) | ||
system.disable_auto_reindex! | ||
action_subject system | ||
system.update_attributes!(sys_params) | ||
plan_action(::Actions::Katello::Foreman::HostUpdate, system) | ||
plan_action(::Actions::Pulp::Consumer::Update, system) if ::Katello.config.use_pulp | ||
plan_action(::Actions::Candlepin::Consumer::Update, system) if ::Katello.config.use_cp | ||
plan_action(ElasticSearch::Reindex, system) if ::Katello.config.use_elasticsearch | ||
plan_action(::Actions::Candlepin::Consumer::RefreshSubscrpitions, system, sys_params) if ::Katello.config.use_cp | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Copyright 2014 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Actions | ||
module Pulp | ||
module Consumer | ||
class Update < Pulp::Abstract | ||
input_format do | ||
param :uuid, String | ||
param :display_name, String | ||
end | ||
|
||
def plan(system) | ||
plan_self(:uuid => system.uuid, :display_name => system.name) | ||
end | ||
|
||
def run | ||
::Katello.pulp_server.extensions.consumer.update(input[:uuid], :display_name => input[:name]) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.