Project

General

Profile

Revision 611959a3

Added by Thomas McKay over 5 years ago

fixes #16281 - add --itemized-subscriptions to activation-keys

View differences:

lib/hammer_cli_csv/base.rb
799 799
      result
800 800
    end
801 801

  
802
    def katello_subscription(organization, options = {})
803
      @subscriptions ||= {}
804
      @subscriptions[organization] ||= {}
805

  
806
      if options[:name]
807
        return nil if options[:name].nil? || options[:name].empty?
808
        options[:id] = @subscriptions[organization][options[:name]]
809
        if !options[:id]
810
          results = @api.resource(:subscriptions).call(:index, {
811
              :per_page => 999999,
812
              'organization_id' => foreman_organization(:name => organization),
813
              'search' => "name = \"#{options[:name]}\""
814
          })
815
          raise "No subscriptions match '#{options[:name]}'" if results['subtotal'] == 0
816
          raise "Too many subscriptions match '#{options[:name]}'" if results['subtotal'] > 1
817
          subscription = results['results'][0]
818
          @subscriptions[organization][options[:name]] = subscription['id']
819
          options[:id] = @subscriptions[organization][options[:name]]
820
          raise "Subscription '#{options[:name]}' not found" if !options[:id]
821
        end
822
        result = options[:id]
823
      else
824
        return nil if options[:id].nil?
825
        options[:name] = @subscriptions.key(options[:id])
826
        if !options[:name]
827
          subscription = @api.resource(:subscriptions).call(:show, {'id' => options[:id]})
828
          raise "Subscription '#{options[:name]}' not found" if !subscription || subscription.empty?
829
          options[:name] = subscription['name']
830
          @subscriptions[options[:name]] = options[:id]
831
        end
832
        result = options[:name]
833
      end
834

  
835
      result
836
    end
837

  
838 802
    def katello_hostcollection(organization, options = {})
839 803
      @hostcollections ||= {}
840 804
      @hostcollections[organization] ||= {}

Also available in: Unified diff