Project

General

Profile

Revision 8c7ba4af

Added by Thomas McKay about 8 years ago

updates to csv

fixed lifecycle-env

ship it

View differences:

lib/hammer_cli_csv/base.rb
393 393
      result
394 394
    end
395 395

  
396
    def katello_environment(organization, options = {})
397
      @environments ||= {}
398
      @environments[organization] ||= {
396
    def lifecycle_environment(organization, options = {})
397
      @lifecycle_environments ||= {}
398
      @lifecycle_environments[organization] ||= {
399 399
      }
400 400

  
401 401
      if options[:name]
402 402
        return nil if options[:name].nil? || options[:name].empty?
403
        options[:id] = @environments[organization][options[:name]]
403
        options[:id] = @lifecycle_environments[organization][options[:name]]
404 404
        if !options[:id]
405 405
          @api.resource(:lifecycle_environments).call(:index, {
406 406
                                                        :per_page => 999999,
407 407
                                                        'organization_id' => foreman_organization(:name => organization),
408
                                                        'library' => true
409 408
                                                      })['results'].each do |environment|
410
            @environments[organization][environment['name']] = environment['id']
409
            @lifecycle_environments[organization][environment['name']] = environment['id']
411 410
          end
412
          options[:id] = @environments[organization][options[:name]]
411
          options[:id] = @lifecycle_environments[organization][options[:name]]
413 412
          raise "Lifecycle environment '#{options[:name]}' not found" if !options[:id]
414 413
        end
415 414
        result = options[:id]
416 415
      else
417 416
        return nil if options[:id].nil?
418
        options[:name] = @environments.key(options[:id])
417
        options[:name] = @lifecycle_environments.key(options[:id])
419 418
        if !options[:name]
420 419
          environment = @api.resource(:lifecycle_environments).call(:show, {'id' => options[:id]})
421 420
          raise "Lifecycle environment '#{options[:name]}' not found" if !environment || environment.empty?
422 421
          options[:name] = environment['name']
423
          @environments[options[:name]] = options[:id]
422
          @lifecycle_environments[options[:name]] = options[:id]
424 423
        end
425 424
        result = options[:name]
426 425
      end

Also available in: Unified diff