Revision 963411f5
Added by Adam Price over 10 years ago
app/controllers/katello/api/v2/subscriptions_controller.rb | ||
---|---|---|
temp_file.close
|
||
end
|
||
|
||
task = async_task(::Actions::Headpin::Provider::ManifestImport, @provider,
|
||
File.expand_path(temp_file.path), params[:force])
|
||
task = async_task(::Actions::Headpin::Provider::ManifestImport, @provider, File.expand_path(temp_file.path), params[:force])
|
||
respond_for_async :resource => task
|
||
end
|
||
|
||
... | ... | |
details = @provider.organization.owner_details
|
||
upstream = details['upstreamConsumer'].blank? ? {} : details['upstreamConsumer']
|
||
|
||
@provider.refresh_manifest(upstream, :async => true, :notify => false)
|
||
respond_for_async :resource => @provider.manifest_task
|
||
task = async_task(::Actions::Headpin::Provider::ManifestRefresh, @provider, upstream)
|
||
respond_for_async :resource => task
|
||
end
|
||
|
||
api :POST, "/organizations/:organization_id/subscriptions/delete_manifest", "Delete manifest from Red Hat provider"
|
||
param :organization_id, :identifier, :desc => "Organization id", :required => true
|
||
def delete_manifest
|
||
@provider.delete_manifest(:async => true, :notify => false)
|
||
respond_for_async :resource => @provider.manifest_task
|
||
task = async_task(::Actions::Headpin::Provider::ManifestDelete, @provider)
|
||
respond_for_async :resource => task
|
||
end
|
||
|
||
protected
|
app/lib/actions/headpin/provider/manifest_delete.rb | ||
---|---|---|
#
|
||
# 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 Headpin
|
||
module Provider
|
||
class ManifestDelete < Actions::AbstractAsyncTask
|
||
|
||
def plan(provider)
|
||
action_subject provider
|
||
end
|
||
|
||
input_format do
|
||
param :provider, Hash do
|
||
param :id
|
||
end
|
||
end
|
||
|
||
def humanized_name
|
||
_("Delete Manifest")
|
||
end
|
||
|
||
def run
|
||
provider = ::Katello::Provider.find(input[:provider][:id])
|
||
provider.delete_manifest(:async => false, :notify => false)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
||
end
|
app/lib/actions/headpin/provider/manifest_refresh.rb | ||
---|---|---|
#
|
||
# 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 Headpin
|
||
module Provider
|
||
class ManifestRefresh < Actions::AbstractAsyncTask
|
||
|
||
def plan(provider, upstream)
|
||
action_subject provider
|
||
plan_self :upstream => upstream
|
||
end
|
||
|
||
input_format do
|
||
param :provider, Hash do
|
||
param :id
|
||
end
|
||
param :upstream
|
||
end
|
||
|
||
def humanized_name
|
||
_("Refresh Manifest")
|
||
end
|
||
|
||
def run
|
||
provider = ::Katello::Provider.find(input[:provider][:id])
|
||
provider.refresh_manifest(input[:upstream], :async => false, :notify => false)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
||
end
|
test/controllers/api/v2/subscriptions_controller_test.rb | ||
---|---|---|
|
||
def test_refresh_manfiest
|
||
Provider.any_instance.stubs(:refresh_manifest)
|
||
Provider.any_instance.stubs(:organization).returns(Organization.new())
|
||
Provider.any_instance.stubs(:organization).returns(@organization)
|
||
Organization.any_instance.stubs(:owner_details).returns("upstreamConsumer" => "JarJarBinks")
|
||
Provider.any_instance.stubs(:manifest_task).returns(TaskStatus.new())
|
||
assert_async_task(::Actions::Headpin::Provider::ManifestRefresh) do |provider, upstream|
|
||
assert_equal(@organization.redhat_provider.id, provider.id)
|
||
assert_equal("JarJarBinks", upstream)
|
||
end
|
||
put :refresh_manifest, :organization_id => @organization.label
|
||
assert_response :success
|
||
end
|
||
... | ... | |
|
||
def test_delete_manifest
|
||
Provider.any_instance.stubs(:delete_manifest)
|
||
Provider.any_instance.stubs(:manifest_task).returns(TaskStatus.new())
|
||
assert_async_task(::Actions::Headpin::Provider::ManifestDelete) do |provider|
|
||
assert_equal(@organization.redhat_provider.id, provider.id)
|
||
end
|
||
post :delete_manifest, :organization_id => @organization.label
|
||
assert_response :success
|
||
end
|
Also available in: Unified diff
subscriptions - manifest refresh and delete into dynflow actions