Class: Activationkey
- Inherits:
-
Object
- Object
- Activationkey
- Defined in:
- lib/satops/operator.rb
Instance Attribute Summary collapse
-
#child_channel_labels ⇒ Object
readonly
Returns the value of attribute child_channel_labels.
-
#config_channel_labels ⇒ Object
readonly
Returns the value of attribute config_channel_labels.
-
#entitlements ⇒ Object
readonly
Returns the value of attribute entitlements.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#server_group_ids ⇒ Object
readonly
Returns the value of attribute server_group_ids.
Class Method Summary collapse
Instance Method Summary collapse
- #common_update(sat, key) ⇒ Object
- #create(sat) ⇒ Object
- #delete(sat) ⇒ Object
-
#initialize(activation_key) ⇒ Activationkey
constructor
A new instance of Activationkey.
- #update(sat) ⇒ Object
Constructor Details
#initialize(activation_key) ⇒ Activationkey
Returns a new instance of Activationkey.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/satops/operator.rb', line 262 def initialize(activation_key) @key=activation_key['key'] @description=activation_key['description'] @base_channel_label=activation_key['base_channel_label'] @child_channel_labels=activation_key['child_channel_labels'] @config_channel_labels=activation_key['config_channel_labels'] @config_deployment=activation_key['config_deployment'] @entitlements=activation_key['entitlements'] @packages=activation_key['packages'] @server_group_ids=activation_key['server_group_ids'] @server_group_names=activation_key['server_group_names'] @universal_default=activation_key['universal_default'] @usage_limit=activation_key['usage_limit'] @disabled=activation_key['disabled'] end |
Instance Attribute Details
#child_channel_labels ⇒ Object (readonly)
Returns the value of attribute child_channel_labels.
242 243 244 |
# File 'lib/satops/operator.rb', line 242 def child_channel_labels @child_channel_labels end |
#config_channel_labels ⇒ Object (readonly)
Returns the value of attribute config_channel_labels.
242 243 244 |
# File 'lib/satops/operator.rb', line 242 def config_channel_labels @config_channel_labels end |
#entitlements ⇒ Object (readonly)
Returns the value of attribute entitlements.
242 243 244 |
# File 'lib/satops/operator.rb', line 242 def entitlements @entitlements end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
242 243 244 |
# File 'lib/satops/operator.rb', line 242 def key @key end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
242 243 244 |
# File 'lib/satops/operator.rb', line 242 def packages @packages end |
#server_group_ids ⇒ Object (readonly)
Returns the value of attribute server_group_ids.
242 243 244 |
# File 'lib/satops/operator.rb', line 242 def server_group_ids @server_group_ids end |
Class Method Details
.reader(sat, key) ⇒ Object
244 245 246 247 248 249 250 |
# File 'lib/satops/operator.rb', line 244 def self.reader(sat, key) activation_key=sat.activationkey.getDetails(key) activation_key.merge!('config_channel_labels'=>Helpers.filter(sat.activationkey.listConfigChannels(activation_key['key']), 'label')) activation_key.merge!('server_group_names'=>ActivationkeysSet.get_server_groups_names(sat, activation_key['server_group_ids'])) activation_key.merge!('config_deployment'=>sat.activationkey.checkConfigDeployment(key)) activation_key end |
.remove_id(key) ⇒ Object
252 253 254 255 256 257 258 259 260 |
# File 'lib/satops/operator.rb', line 252 def self.remove_id(key) str="" if key =~ /^[0-9]*-/ # key starts with an org id so we remove it as it's added by Satellite str=key.sub(/^[0-9]*-/, '') else str=key end end |
Instance Method Details
#common_update(sat, key) ⇒ Object
278 279 280 281 282 283 284 285 |
# File 'lib/satops/operator.rb', line 278 def common_update(sat, key) sat.activationkey.addEntitlements(key, @entitlements) sat.activationkey.enableConfigDeployment(key) if @config_deployment sat.activationkey.addChildChannels(key, @child_channel_labels) sat.activationkey.addConfigChannels([key], @config_channel_labels, true) sat.activationkey.addPackages(key, @packages) sat.activationkey.addServerGroups(key, ActivationkeysSet.get_server_groups_ids(sat, @server_group_names)) end |
#create(sat) ⇒ Object
287 288 289 290 291 |
# File 'lib/satops/operator.rb', line 287 def create(sat) @base_channel_label="" if @base_channel_label == 'none' # RHN Default key=sat.activationkey.create(Activationkey.remove_id(@key), @description, @base_channel_label, @usage_limit, @entitlements, @universal_default) common_update(sat, key) if key end |
#delete(sat) ⇒ Object
293 294 295 |
# File 'lib/satops/operator.rb', line 293 def delete(sat) sat.activationkey.delete(@key) end |
#update(sat) ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/satops/operator.rb', line 297 def update(sat) # Sync base channel field orig=Activationkey.new(Activationkey.reader(sat, @key)) @base_channel_label='' if @base_channel_label== 'none' @usage_limit=-1 if @usage_limit == 0 sat.activationkey.setDetails(@key, {'description' => @description, 'base_channel_label' => @base_channel_label, 'usage_limit' => @usage_limit, 'universal_default' => @universal_default, 'disabled' => @disabled}) sat.activationkey.removeChildChannels(@key, orig.child_channel_labels) sat.activationkey.removeConfigChannels([@key], orig.config_channel_labels) sat.activationkey.removePackages(@key, orig.packages) # must be done before removing entitlements! sat.activationkey.removeServerGroups(@key, orig.server_group_ids) sat.activationkey.disableConfigDeployment(@key) sat.activationkey.removeEntitlements(@key, orig.entitlements) common_update(sat, @key) end |