Class: Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/satops/operator.rb

Constant Summary collapse

REDHAT =
"Red Hat, Inc."

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ Channel

Returns a new instance of Channel.



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/satops/operator.rb', line 370

def initialize(channel)
  @id=channel['id']
  @label=channel['label']
  @name=channel['name']
  @arch_name=channel['arch_name']
  @summary=channel['summary']
  @provider_name= channel['provider_name']
  @packages=channel['packages']
  @systems=channel['systems']
  @is_globally_subscribable=channel['isGloballySubscribable']
  @subscribers=channel['subscribers']
  @managers=channel['managers']
  @description=channel['description']
  @checksum_label=channel['checksum_label']
  @last_modified=channel['last_modified']
  @maintainer_name=channel['maintainer_name']
  @maintainer_email=channel['maintainer_email']
  @maintainer_phone=channel['maintainer_phone']
  @support_policy=channel['support_policy']
  @gpg_key_url=channel['gpg_key_url']
  @gpg_key_id=channel['gpg_key_id']
  @gpg_key_fp=channel['gpg_key_fp']
  @yumrepo_source_url=channel['yumrepo_source_url']
  @yumrepo_label=channel['yumrepo_label']
  @yumrepo_last_sync=channel['yumrepo_last_sync']
  @end_of_life=channel['end_of_life']
  @parent_channel_label=channel['parent_channel_label']
  @clone_original=channel['clone_original']
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



347
348
349
# File 'lib/satops/operator.rb', line 347

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



347
348
349
# File 'lib/satops/operator.rb', line 347

def label
  @label
end

Class Method Details

.reader(sat, channel) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/satops/operator.rb', line 350

def self.reader(sat, channel)
  channel.merge!(sat.channelSoftware.getDetails(channel['label']))
  channel.merge!({'isGloballySubscribable'=>sat.channelSoftware.isGloballySubscribable(channel['label'])})
  unless channel['isGloballySubscribable']
    subscribers={}
    Helpers.filter(sat.user.listUsers, 'login').each do ||
      subscribers.merge!({ => sat.channelSoftware.isUserSubscribable(channel['label'], )})
    end
    channel.merge!({'subscribers'=>subscribers})
  end
  unless channel['provider_name'] == REDHAT
    managers={}
    Helpers.filter(sat.user.listUsers, 'login').each do ||
      managers.merge!({ =>  sat.channelSoftware.isUserManageable(channel['label'], )})
    end
    channel.merge!({'managers'=>managers})
  end
  channel
end

Instance Method Details

#create(sat) ⇒ Object



400
401
402
# File 'lib/satops/operator.rb', line 400

def create(sat)
  # Software Channels must created via ISS (satellite-sync)
end

#delete(sat) ⇒ Object



404
405
406
# File 'lib/satops/operator.rb', line 404

def delete(sat)
  sat.channelSoftware.delete(@label)
end

#update(sat) ⇒ Object



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/satops/operator.rb', line 408

def update(sat)
  # Update details for non Red Hat channels
  if @provider_name != REDHAT
    # Non mandatory fields that could be nil need to be empty
    @maintainer_name='' unless @maintainer_name
    @maintainer_email='' unless @maintainer_email
    @maintainer_phone='' unless @maintainer_phone
    # Find target channel id
    id=sat.channelSoftware.getDetails(@label)['id']
    sat.channelSoftware.setDetails(id, {'checksum_label' => @checksum_label, 'name' => @name, 'summary' => @summary, 'description' => @description, 'maintainer_name' => @maintainer_name, 'maintainer_email' => @maintainer_email, 'maintainer_phone' => @maintainer_phone, 'gpg_key_url' => @gpg_key_url, 'gpg_key_id' => @gpg_key_id, 'gpg_key_fp' => @gpg_key_fp})

    # Managers
    if @managers
      @managers.each do |, value|
        sat.channelSoftware.setUserManageable(@label, , value)
      end
    end
  end

  # Globally Subscribable
  sat.channelSoftware.setGloballySubscribable(@label, @is_globally_subscribable)

  # Per User subscriptions
  if !@is_globally_subscribable && @subscribers
    @subscribers.each do |, value|
      sat.channelSoftware.setUserSubscribable(@label, , value)
    end
  end

  # To Do : Repos
end