diff --git a/lib/hammer_cli_katello/activation_key.rb b/lib/hammer_cli_katello/activation_key.rb index 870d2cd1..7a02e79e 100644 --- a/lib/hammer_cli_katello/activation_key.rb +++ b/lib/hammer_cli_katello/activation_key.rb @@ -176,71 +176,6 @@ class DeleteCommand < HammerCLIKatello::DeleteCommand build_options end - class SubscriptionsCommand < HammerCLIKatello::ListCommand - resource :subscriptions, :index - desc _("List associated subscriptions") - command_name "subscriptions" - - output do - field :id, _("Id") - field :product_name, _("Name") - field :format_consumed, _("Attached") - field :quantity_attached, _("Quantity") - field :start_date, _("Start Date"), Fields::Date - field :end_date, _("End Date"), Fields::Date - field :support_level, _("Support") - field :contract_number, _("Contract") - field :account_number, _("Account") - end - - def extend_data(data) - data["format_consumed"] = _("#{data['consumed']} out of "\ - "#{data['quantity'] == -1 ? 'Unlimited' : data['quantity']}") - data - end - - option '--id', "ACTIVATION_KEY_ID", _("ID of the activation key"), - attribute_name: :option_activation_key_id - option '--name', "ACTIVATION_KEY_NAME", _("Activation key name to search by"), - attribute_name: :option_activation_key_name - - validate_options :before, 'IdResolution' do - any(:option_activation_key_id, :option_activation_key_name).required - end - - build_options - end - - class AddSubscriptionsCommand < HammerCLIKatello::SingleResourceCommand - action :add_subscriptions - - desc "Add subscription" - command_name "add-subscription" - - build_options - - success_message _("Subscription added to activation key.") - failure_message _("Could not add subscription to activation key") - end - - class RemoveSubscriptionCommand < HammerCLIKatello::SingleResourceCommand - action :remove_subscriptions - - desc _("Remove subscription") - command_name "remove-subscription" - - option "--subscription-id", "SUBSCRIPTION_ID", _("ID of subscription"), - :attribute_name => :option_subscription_id, :required => true - - build_options do |o| - o.expand.except(:subscriptions) - o.without(:subscriptions) - end - - success_message _("Subscription removed from activation key.") - failure_message _("Could not remove subscription from activation key") - end - class ProductContentCommand < HammerCLIKatello::ProductContentBase::ProductContentCommand resource :activation_keys, :product_content setup diff --git a/lib/hammer_cli_katello/host_extensions.rb b/lib/hammer_cli_katello/host_extensions.rb index 73333846..87da69f9 100644 --- a/lib/hammer_cli_katello/host_extensions.rb +++ b/lib/hammer_cli_katello/host_extensions.rb @@ -118,7 +118,6 @@ module HostExtensions field :uuid, _('Uuid') field :last_checkin, _('Last Checkin') field :release_version, _('Release Version') - field :autoheal, _('Autoheal') field :registered_through, _('Registered To') field :registered_at, _('Registered At') collection :activation_keys, _('Registered by Activation Keys'), :hide_blank => true do diff --git a/lib/hammer_cli_katello/host_subscription.rb b/lib/hammer_cli_katello/host_subscription.rb index ec8a024c..bf39915e 100644 --- a/lib/hammer_cli_katello/host_subscription.rb +++ b/lib/hammer_cli_katello/host_subscription.rb @@ -32,71 +32,6 @@ class CreateCommand < HammerCLIKatello::SingleResourceCommand extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new) end - class AddSubscriptions < HammerCLIKatello::SingleResourceCommand - resource :host_subscriptions, :add_subscriptions - command_name "attach" - success_message _("Subscription attached to the host successfully.") - failure_message _("Failed to attach subscriptions to the host") - - option "--subscription-id", "SUBSCRIPTION_ID", _("ID of subscription"), - :attribute_name => :option_subscription_id, :required => true - - option "--quantity", "Quantity", _("Quantity of this subscriptions to add. Defaults to 1"), - :attribute_name => :option_quantity, :required => false - - def request_params - params = super - params[:subscriptions] = [ - { - :id => option_subscription_id, - :quantity => option_quantity || 1 - } - ] - params - end - - build_options do |o| - o.expand.except(:subscriptions) - o.without(:subscriptions) - end - end - - class AutoAttachSubscriptions < HammerCLIKatello::SingleResourceCommand - resource :host_subscriptions, :auto_attach - command_name "auto-attach" - success_message _("Auto attached subscriptions to the host successfully.") - failure_message _("Failed to auto attach subscriptions to the host") - - build_options - end - - class RemoveSubscriptions < HammerCLIKatello::SingleResourceCommand - resource :host_subscriptions, :remove_subscriptions - command_name "remove" - success_message _("Subscription removed from the host successfully.") - failure_message _("Failed to remove subscriptions from the host") - - option "--subscription-id", "SUBSCRIPTION_ID", _("ID of subscription"), - :attribute_name => :option_subscription_id, :required => true - - option "--quantity", "Quantity", - _("Remove the first instance of a subscription with matching id and quantity"), - :attribute_name => :option_quantity, :required => false - - def request_params - params = super - subs = { :id => option_subscription_id } - subs[:quantity] = option_quantity if option_quantity - params[:subscriptions] = [subs] - params - end - - build_options do |o| - o.expand.except(:subscriptions) - o.without(:subscriptions) - end - end - class ProductContentCommand < HammerCLIKatello::ProductContentBase::ProductContentCommand resource :host_subscriptions, :product_content setup diff --git a/test/functional/activation_key/subscriptions_test.rb b/test/functional/activation_key/subscriptions_test.rb deleted file mode 100644 index 057f75c3..00000000 --- a/test/functional/activation_key/subscriptions_test.rb +++ /dev/null @@ -1,74 +0,0 @@ -require_relative '../test_helper' -require 'hammer_cli_katello/activation_key' - -module HammerCLIKatello - describe ActivationKeyCommand::SubscriptionsCommand do - it 'requires organization options' do - expected_error = "Could not find organization" - result = run_cmd(%w(activation-key subscriptions --name test)) - assert_equal(result.err[/#{expected_error}/], expected_error) - end - - it 'allows organization name' do - api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" } - .returns(index_response([{'id' => 1}])) - - api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 } - - run_cmd(%w(activation-key subscriptions --id 1 --organization org1)) - end - - it 'allows organization label' do - api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" } - .returns(index_response([{'id' => 1}])) - - api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 } - - run_cmd(%w(activation-key subscriptions --id 1 --organization-label org1)) - end - - it 'lists subscriptions available for the activation key' do - api_expects(:subscriptions, :index) do |p| - p['available_for'] == 'activation_key' - end - run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1 - --available-for activation_key)) - end - - it 'lists subscriptions used by the activation key' do - api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == '1' } - run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1)) - end - - it 'allows activation_key_name' do - api_expects(:activation_keys, :index) { |p| p['name'] == 'ak1' } - .returns(index_response([{'id' => 1}])) - api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 } - run_cmd(%w(activation-key subscriptions --organization-id 1 --name ak1)) - end - - it 'allows a subscription to be added to an activation key' do - api_expects(:activation_keys, :add_subscriptions) do |p| - p['id'] == 1 && p['subscription_id'] == 3 - end - run_cmd(%w(activation-key add-subscription --id 1 --subscription-id 3)) - end - - it 'allows a subscription to be added by name to an activation key with org label' do - api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" } - .returns(index_response([{'id' => 1}])) - api_expects(:subscriptions, :index) { |p| p['name'] == 'sub' } - .returns(index_response([{'name' => 'sub'}])) - api_expects(:activation_keys, :add_subscriptions) { |p| p['id'] == 1 } - run_cmd(%w(activation-key add-subscription --id 1 --subscription sub - --organization-label org1)) - end - - it 'allows multiple subscriptions to be added to an activation key' do - api_expects(:activation_keys, :add_subscriptions) do |p| - p['id'] == 1 && p['subscriptions'] == [{'id' => '3'}, {'id' => '4'}] - end - run_cmd(%w(activation-key add-subscription --id 1 --subscriptions id=3,id=4)) - end - end -end diff --git a/test/functional/host/extensions/data/host.json b/test/functional/host/extensions/data/host.json index e8062b21..896db72f 100644 --- a/test/functional/host/extensions/data/host.json +++ b/test/functional/host/extensions/data/host.json @@ -61,8 +61,6 @@ "model_name":"Standard PC (i440FX + PIIX, 1996)", "errata_status":1, "errata_status_label":"Could not calculate errata status, ensure host is registered and katello-agent is installed", - "subscription_status":0, - "subscription_status_label":"Fully entitled", "name":"robot.example.com", "id":1, "hostgroup_name":null, @@ -117,7 +115,6 @@ "release_version":"7Server", "purpose_usage":"Production", "purpose_role":"Role", - "autoheal":true, "registered_at":"2016-05-26 10:46:22 -0400", "activation_keys":[ diff --git a/test/functional/host/extensions/data/host_list.json b/test/functional/host/extensions/data/host_list.json index 89b04ac7..c5a0f075 100644 --- a/test/functional/host/extensions/data/host_list.json +++ b/test/functional/host/extensions/data/host_list.json @@ -72,8 +72,6 @@ "model_name":"Standard PC (i440FX + PIIX, 1996)", "errata_status":1, "errata_status_label":"Could not calculate errata status, ensure host is registered and katello-agent is installed", - "subscription_status":0, - "subscription_status_label":"Fully entitled", "traces_status":0, "traces_status_label":"updated", "name":"robot.example.com", @@ -137,7 +135,6 @@ "last_checkin":"2016-05-26 10:46:18 -0400", "service_level":null, "release_version":"{\"releaseVer\"=>nil}", - "autoheal":true, "registered_at":"2016-05-26 10:46:22 -0400" }, "content_host_id":2 diff --git a/test/functional/host/subscription/attach_test.rb b/test/functional/host/subscription/attach_test.rb deleted file mode 100644 index e0d47358..00000000 --- a/test/functional/host/subscription/attach_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -require File.join(File.dirname(__FILE__), '../../test_helper') -require File.join(File.dirname(__FILE__), '../host_helpers') - -describe 'host subscription attach' do - include HostHelpers - - before do - @cmd = %w(host subscription attach) - end - it "attach a subscription to a host No Quantity" do - params = ['--host-id=3', '--subscription-id=100'] - ex = api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par| - par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' && - par[:subscriptions][0][:quantity].to_s == '1' - end - ex.returns({}) - - expected_result = success_result( - 'Subscription attached to the host successfully. -' - ) - - result = run_cmd(@cmd + params) - assert_cmd(expected_result, result) - end - - it "attach a subscription to a host with Quantity" do - params = ['--host-id=3', '--subscription-id=100', "--quantity=10"] - ex = api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par| - par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' && - par[:subscriptions][0][:quantity].to_s == '10' - end - ex.returns({}) - - expected_result = success_result( - 'Subscription attached to the host successfully. -' - ) - - result = run_cmd(@cmd + params) - assert_cmd(expected_result, result) - end - - it "resolves id from name" do - params = ['--host=boo', '--subscription-id=100'] - api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par| - par['host_id'].to_s == "3" && par[:subscriptions][0][:id].to_s == '100' && - par[:subscriptions][0][:quantity].to_s == '1' - end - expect_host_search('boo', '3') - - run_cmd(@cmd + params) - end -end diff --git a/test/functional/host/subscription/auto_attach_test.rb b/test/functional/host/subscription/auto_attach_test.rb deleted file mode 100644 index b6b337d6..00000000 --- a/test/functional/host/subscription/auto_attach_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require File.join(File.dirname(__FILE__), '../../test_helper') -require File.join(File.dirname(__FILE__), '../host_helpers') - -describe 'host subscription auto-attach' do - include HostHelpers - - before do - @cmd = %w(host subscription auto-attach) - end - it "auto-attach to a host" do - params = ['--host-id=3'] - ex = api_expects(:host_subscriptions, :auto_attach, "auto-attach subs host") do |par| - par['host_id'] == 3 - end - ex.returns({}) - - expected_result = success_result( - 'Auto attached subscriptions to the host successfully. -' - ) - - result = run_cmd(@cmd + params) - assert_cmd(expected_result, result) - end - - it "resolves id from name" do - params = ['--host=boo'] - api_expects(:host_subscriptions, :auto_attach, "auto-attach subs host") do |par| - par['host_id'].to_s == "3" - end - expect_host_search('boo', '3') - - run_cmd(@cmd + params) - end -end diff --git a/test/functional/host/subscription/remove_test.rb b/test/functional/host/subscription/remove_test.rb deleted file mode 100644 index 642a2f74..00000000 --- a/test/functional/host/subscription/remove_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require File.join(File.dirname(__FILE__), '../../test_helper') -require File.join(File.dirname(__FILE__), '../host_helpers') - -describe 'host subscription remove' do - include HostHelpers - - before do - @cmd = %w(host subscription remove) - end - it "remove a subscription to a host No Quantity" do - params = ['--host-id=3', '--subscription-id=100'] - ex = api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par| - par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' - end - ex.returns({}) - - expected_result = success_result( - 'Subscription removed from the host successfully. -' - ) - - result = run_cmd(@cmd + params) - assert_cmd(expected_result, result) - end - - it "remove a subscription to a host with Quantity" do - params = ['--host-id=3', '--subscription-id=100', "--quantity=10"] - ex = api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par| - par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' && - par[:subscriptions][0][:quantity].to_s == '10' - end - ex.returns({}) - - expected_result = success_result( - 'Subscription removed from the host successfully. -' - ) - - result = run_cmd(@cmd + params) - assert_cmd(expected_result, result) - end - - it "resolves id from name" do - params = ['--host=boo', '--subscription-id=100'] - api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par| - par['host_id'].to_s == "3" && par[:subscriptions][0][:id].to_s == '100' - end - expect_host_search('boo', '3') - - run_cmd(@cmd + params) - end -end