Class: OpenShift::MCollectiveApplicationContainerProxy

Inherits:
ApplicationContainerProxy
  • Object
show all
Defined in:
lib/openshift/mcollective_application_container_proxy.rb

Constant Summary collapse

@@C_CONTROLLER =
'openshift-origin-node'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, district = nil) ⇒ MCollectiveApplicationContainerProxy

Returns a new instance of MCollectiveApplicationContainerProxy.



10
11
12
13
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 10

def initialize(id, district=nil)
  @id = id
  @district = district
end

Instance Attribute Details

#districtObject

Returns the value of attribute district.



8
9
10
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 8

def district
  @district
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 8

def id
  @id
end

Class Method Details

.blacklisted_in_impl?(name) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 65

def self.blacklisted_in_impl?(name)
  false
end

.find_available_impl(node_profile = nil, district_uuid = nil) ⇒ Object

Raises:

  • (OpenShift::NodeException)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 28

def self.find_available_impl(node_profile=nil, district_uuid=nil)
  district = nil
  require_specific_district = !district_uuid.nil?
  if Rails.configuration.msg_broker[:districts][:enabled] && (!district_uuid || district_uuid == 'NONE')
    district = District.find_available(node_profile)
    if district
      district_uuid = district.uuid
      Rails.logger.debug "DEBUG: find_available_impl: district_uuid: #{district_uuid}"
    elsif Rails.configuration.msg_broker[:districts][:require_for_app_create]
      raise OpenShift::NodeException.new("No district nodes available.", 140)
    end
  end
  current_server, current_capacity, preferred_district = rpc_find_available(node_profile, district_uuid, require_specific_district)
  if !current_server
    current_server, current_capacity, preferred_district = rpc_find_available(node_profile, district_uuid, require_specific_district, true)
  end
  district = preferred_district if preferred_district
  Rails.logger.debug "CURRENT SERVER: #{current_server}"
  raise OpenShift::NodeException.new("No nodes available.", 140) unless current_server
  Rails.logger.debug "DEBUG: find_available_impl: current_server: #{current_server}: #{current_capacity}"

  MCollectiveApplicationContainerProxy.new(current_server, district)
end

.find_one_impl(node_profile = nil) ⇒ Object

Raises:

  • (OpenShift::NodeException)


52
53
54
55
56
57
58
59
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 52

def self.find_one_impl(node_profile=nil)
  current_server = rpc_find_one(node_profile)
  Rails.logger.debug "CURRENT SERVER: #{current_server}"
  raise OpenShift::NodeException.new("No nodes found.", 140) unless current_server
  Rails.logger.debug "DEBUG: find_one_impl: current_server: #{current_server}"

  MCollectiveApplicationContainerProxy.new(current_server)
end

.get_blacklisted_in_implObject



61
62
63
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 61

def self.get_blacklisted_in_impl
  []
end

.rpc_exec(agent, server = nil, forceRediscovery = false, options = rpc_options) ⇒ Object

Execute an RPC call for the specified agent. If a server is supplied, only execute for that server.

Raises:

  • (OpenShift::NodeException)


952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 952

def self.rpc_exec(agent, server=nil, forceRediscovery=false, options=rpc_options)

  # Setup the rpc client
  rpc_client = rpcclient(agent, :options => options)

  # Filter to the specified server
  if server
    Rails.logger.debug("DEBUG: rpc_exec: Filtering rpc_exec to server #{server}")
    rpc_client.identity_filter(server)
  end

  if forceRediscovery
    rpc_client.reset
  end
  Rails.logger.debug("DEBUG: rpc_exec: rpc_client=#{rpc_client}")

  # Execute a block and make sure we disconnect the client
  begin
    result = yield rpc_client
  ensure
    rpc_client.disconnect
  end

  raise OpenShift::NodeException.new("Node execution failure (error getting result from node).  If the problem persists please contact Red Hat support.", 143) unless result

  result
end

.valid_gear_sizes_impl(user) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 15

def self.valid_gear_sizes_impl(user)
  capability_gear_sizes = []
  capability_gear_sizes = user.capabilities['gear_sizes'] if user.capabilities.has_key?('gear_sizes')

  if user.auth_method == :broker_auth
    return ["small", "medium"] | capability_gear_sizes
  elsif !capability_gear_sizes.nil? and !capability_gear_sizes.empty?
    return capability_gear_sizes
  else
    return ["small"]
  end
end

Instance Method Details

#add_alias(app, gear, server_alias) ⇒ Object



453
454
455
456
457
458
459
460
461
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 453

def add_alias(app, gear, server_alias)
  args = Hash.new
  args['--with-container-uuid']=gear.uuid
  args['--with-container-name']=gear.name
  args['--with-namespace']=app.domain.namespace
  args['--with-alias-name']=server_alias
  result = execute_direct(@@C_CONTROLLER, 'add-alias', args)
  parse_result(result)
end

#add_authorized_ssh_key(app, gear, ssh_key, key_type = nil, comment = nil) ⇒ Object



216
217
218
219
220
221
222
223
224
225
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 216

def add_authorized_ssh_key(app, gear, ssh_key, key_type=nil, comment=nil)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-ssh-key'] = ssh_key
  args['--with-ssh-key-type'] = key_type if key_type
  args['--with-ssh-key-comment'] = comment if comment
  result = execute_direct(@@C_CONTROLLER, 'authorized-ssh-key-add', args)
  parse_result(result)
end

#add_broker_auth_key(app, gear, iv, token) ⇒ Object



256
257
258
259
260
261
262
263
264
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 256

def add_broker_auth_key(app, gear, iv, token)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-iv'] = iv
  args['--with-token'] = token
  result = execute_direct(@@C_CONTROLLER, 'broker-auth-key-add', args)
  parse_result(result)
end

#add_env_var(app, gear, key, value) ⇒ Object



237
238
239
240
241
242
243
244
245
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 237

def add_env_var(app, gear, key, value)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-key'] = key
  args['--with-value'] = value
  result = execute_direct(@@C_CONTROLLER, 'env-var-add', args)
  parse_result(result)
end

#conceal_port(app, gear, cart) ⇒ Object



445
446
447
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 445

def conceal_port(app, gear, cart)
  run_cartridge_command(cart, app, gear, "conceal-port")
end

#configure_cartridge(app, gear, cart, template_git_url = nil) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 282

def configure_cartridge(app, gear, cart, template_git_url=nil)
  result_io = ResultIO.new
  cart_data = nil
            
  if framework_carts.include? cart
    result_io = run_cartridge_command(cart, app, gear, "configure", template_git_url)
  elsif embedded_carts.include? cart
    result_io, cart_data = add_component(app,gear,cart)
  else
    #no-op
  end
  
  return result_io, cart_data
end

#create(app, gear, quota_blocks = nil, quota_files = nil) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 171

def create(app, gear, quota_blocks=nil, quota_files=nil)
  result = nil
  (1..10).each do |i|
    args = Hash.new
    args['--with-app-uuid'] = app.uuid
    args['--with-app-name'] = app.name
    args['--with-container-uuid'] = gear.uuid
    args['--with-container-name'] = gear.name
    args['--with-quota-blocks'] = quota_blocks if quota_blocks
    args['--with-quota-files'] = quota_files if quota_files
    args['--with-namespace'] = app.domain.namespace
    args['--with-uid'] = gear.uid if gear.uid
    mcoll_reply = execute_direct(@@C_CONTROLLER, 'app-create', args)
    result = parse_result(mcoll_reply)
    if result.exitcode == 129 && has_uid_or_gid?(app.gear.uid) # Code to indicate uid already taken
      destroy(app, gear, true)
      inc_externally_reserved_uids_size
      gear.uid = reserve_uid
      app.save
    else
      break
    end
  end
  result
end

#deconfigure_cartridge(app, gear, cart) ⇒ Object



297
298
299
300
301
302
303
304
305
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 297

def deconfigure_cartridge(app, gear, cart)
  if framework_carts.include? cart
    run_cartridge_command(cart, app, gear, "deconfigure")
  elsif embedded_carts.include? cart
    remove_component(app,gear,cart)
  else
    ResultIO.new
  end        
end

#destroy(app, gear, keep_uid = false, uid = nil, skip_hooks = false) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 197

def destroy(app, gear, keep_uid=false, uid=nil, skip_hooks=false)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-app-name'] = app.name
  args['--with-container-uuid'] = gear.uuid
  args['--with-container-name'] = gear.name
  args['--with-namespace'] = app.domain.namespace
  args['--skip-hooks'] = true if skip_hooks
  result = execute_direct(@@C_CONTROLLER, 'app-destroy', args)
  result_io = parse_result(result)

  uid = gear.uid unless uid
  
  if uid && !keep_uid
    unreserve_uid(uid)
  end
  return result_io
end

#execute_connector(app, gear, cart, connector_name, input_args) ⇒ Object



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 343

def execute_connector(app, gear, cart, connector_name, input_args)
  args = Hash.new
  args['--gear-uuid'] = gear.uuid
  args['--cart-name'] = cart
  args['--hook-name'] = connector_name
  args['--input-args'] = input_args.join(" ")
  mcoll_reply = execute_direct(@@C_CONTROLLER, 'connector-execute', args)
  if mcoll_reply and mcoll_reply.length>0
    mcoll_reply = mcoll_reply[0]
    output = mcoll_reply.results[:data][:output]
    exitcode = mcoll_reply.results[:data][:exitcode]
    return [output, exitcode]
  end
  [nil, nil]
end

#expose_port(app, gear, cart) ⇒ Object



441
442
443
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 441

def expose_port(app, gear, cart)
  run_cartridge_command(cart, app, gear, "expose-port")
end

#force_stop(app, gear, cart) ⇒ Object



379
380
381
382
383
384
385
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 379

def force_stop(app, gear, cart)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  result = execute_direct(@@C_CONTROLLER, 'force-stop', args)
  parse_result(result)
end

#get_active_capacityObject



315
316
317
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 315

def get_active_capacity
  rpc_get_fact_direct('active_capacity').to_f
end

#get_add_authorized_ssh_key_job(app, gear, ssh_key, key_type = nil, comment = nil) ⇒ Object



497
498
499
500
501
502
503
504
505
506
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 497

def get_add_authorized_ssh_key_job(app, gear, ssh_key, key_type=nil, comment=nil)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-ssh-key'] = ssh_key
  args['--with-ssh-key-type'] = key_type if key_type
  args['--with-ssh-key-comment'] = comment if comment
  job = RemoteJob.new('openshift-origin-node', 'authorized-ssh-key-add', args)
  job
end

#get_app_status(app) ⇒ Object



900
901
902
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 900

def get_app_status(app)
  get_cart_status(app, app.gear, app.framework)
end

#get_available_cartridgesObject



69
70
71
72
73
74
75
76
77
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 69

def get_available_cartridges
  args = Hash.new
  args['--porcelain'] = true
  args['--with-descriptors'] = true
  result = execute_direct(@@C_CONTROLLER, 'cartridge-list', args, false)
  result = parse_result(result)
  cart_data = JSON.parse(result.resultIO.string)
  cart_data.map! {|c| OpenShift::Cartridge.new.from_descriptor(YAML.load(c))}
end

#get_broker_auth_key_add_job(app, gear, iv, token) ⇒ Object



518
519
520
521
522
523
524
525
526
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 518

def get_broker_auth_key_add_job(app, gear, iv, token)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-iv'] = iv
  args['--with-token'] = token
  job = RemoteJob.new('openshift-origin-node', 'broker-auth-key-add', args)
  job
end

#get_broker_auth_key_remove_job(app, gear) ⇒ Object



528
529
530
531
532
533
534
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 528

def get_broker_auth_key_remove_job(app, gear)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  job = RemoteJob.new('openshift-origin-node', 'broker-auth-key-remove', args)
  job
end

#get_capacityObject



311
312
313
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 311

def get_capacity
  rpc_get_fact_direct('capacity').to_f
end

#get_cart_status(app, gear, cart_name) ⇒ Object



904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 904

def get_cart_status(app, gear, cart_name)
  reply = ResultIO.new
  source_container = gear.container
  leave_stopped = false
  idle = false
  quota_blocks = nil
  quota_files = nil
  log_debug "DEBUG: Getting existing app '#{app.name}' status before moving"
  do_with_retry('status') do
    result = source_container.status(app, gear, cart_name)
    result.cart_commands.each do |command_item|
      case command_item[:command]
      when "ATTR"
        key = command_item[:args][0]
        value = command_item[:args][1]
        if key == 'status'
          case value
          when "ALREADY_STOPPED"
            leave_stopped = true
          when "ALREADY_IDLED"
            leave_stopped = true
            idle = true
          end
        elsif key == 'quota_blocks'
          quota_blocks = value
        elsif key == 'quota_files'
          quota_files = value
        end
      end
      reply.append result
    end
  end

  if idle
    log_debug "DEBUG: Gear component '#{cart_name}' was idle"
  elsif leave_stopped
    log_debug "DEBUG: Gear component '#{cart_name}' was stopped"
  else
    log_debug "DEBUG: Gear component '#{cart_name}' was running"
  end

  return [idle, leave_stopped, quota_blocks, quota_files]
end

#get_district_uuidObject



319
320
321
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 319

def get_district_uuid
  rpc_get_fact_direct('district_uuid')
end

#get_env_var_add_job(app, gear, key, value) ⇒ Object



478
479
480
481
482
483
484
485
486
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 478

def get_env_var_add_job(app, gear, key, value)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-key'] = key
  args['--with-value'] = value
  job = RemoteJob.new('openshift-origin-node', 'env-var-add', args)
  job
end

#get_env_var_remove_job(app, gear, key) ⇒ Object



488
489
490
491
492
493
494
495
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 488

def get_env_var_remove_job(app, gear, key)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-key'] = key
  job = RemoteJob.new('openshift-origin-node', 'env-var-remove', args)
  job
end

#get_execute_connector_job(app, gear, cart, connector_name, input_args) ⇒ Object



536
537
538
539
540
541
542
543
544
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 536

def get_execute_connector_job(app, gear, cart, connector_name, input_args)
  args = Hash.new
  args['--gear-uuid'] = gear.uuid
  args['--cart-name'] = cart
  args['--hook-name'] = connector_name
  args['--input-args'] = input_args.join(" ")
  job = RemoteJob.new('openshift-origin-node', 'connector-execute', args)
  job
end

#get_ip_addressObject



323
324
325
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 323

def get_ip_address
  rpc_get_fact_direct('ipaddress')
end

#get_node_profileObject



331
332
333
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 331

def get_node_profile
  rpc_get_fact_direct('node_profile')
end

#get_public_hostnameObject



307
308
309
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 307

def get_public_hostname
  rpc_get_fact_direct('public_hostname')
end

#get_public_ip_addressObject



327
328
329
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 327

def get_public_ip_address
  rpc_get_fact_direct('public_ip')
end

#get_quota(gear) ⇒ Object

Returns an array with following information [Filesystem, blocks_used, blocks_soft_limit, blocks_hard_limit, inodes_used,

inodes_soft_limit, inodes_hard_limit]


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 82

def get_quota(gear)
  args = Hash.new
  args['--uuid'] = gear.uuid
  reply = execute_direct(@@C_CONTROLLER, 'get-quota', args, false)

  output = nil
  exitcode = 0
  if reply.length > 0
    mcoll_result = reply[0]
    if (mcoll_result && (defined? mcoll_result.results) && !mcoll_result.results[:data].nil?)
      output = mcoll_result.results[:data][:output]
      exitcode = mcoll_result.results[:data][:exitcode]
      raise OpenShift::NodeException.new("Failed to get quota for user: #{output}", 143) unless exitcode == 0
    else
      raise OpenShift::NodeException.new("Node execution failure (error getting result from node).  If the problem persists please contact Red Hat support.", 143)
    end
  else
    raise OpenShift::NodeException.new("Node execution failure (error getting result from node).  If the problem persists please contact Red Hat support.", 143)
  end
  output
end

#get_quota_blocksObject



335
336
337
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 335

def get_quota_blocks
  rpc_get_fact_direct('quota_blocks')
end

#get_quota_filesObject



339
340
341
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 339

def get_quota_files
  rpc_get_fact_direct('quota_files')
end

#get_remove_authorized_ssh_key_job(app, gear, ssh_key, comment = nil) ⇒ Object



508
509
510
511
512
513
514
515
516
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 508

def get_remove_authorized_ssh_key_job(app, gear, ssh_key, comment=nil)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-ssh-key'] = ssh_key
  args['--with-ssh-comment'] = comment if comment
  job = RemoteJob.new('openshift-origin-node', 'authorized-ssh-key-remove', args)
  job
end

#get_show_gear_quota_job(gear) ⇒ Object



560
561
562
563
564
565
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 560

def get_show_gear_quota_job(gear)
  args = Hash.new
  args['--uuid'] = gear.uuid
  job = RemoteJob.new('openshift-origin-node', 'get-quota', args)
  job
end

#get_show_state_job(app, gear) ⇒ Object



546
547
548
549
550
551
552
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 546

def get_show_state_job(app, gear)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  job = RemoteJob.new('openshift-origin-node', 'app-state-show', args)
  job
end

#get_status_job(app, gear, cart) ⇒ Object



554
555
556
557
558
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 554

def get_status_job(app, gear, cart)
  args = "'#{gear.name}' '#{app.domain.namespace}' '#{gear.uuid}'"
  job = RemoteJob.new(cart, 'status', args)
  job
end

#get_update_gear_quota_job(gear, storage_in_gb, inodes) ⇒ Object



567
568
569
570
571
572
573
574
575
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 567

def get_update_gear_quota_job(gear, storage_in_gb, inodes)
  args = Hash.new
  args['--uuid']   = gear.uuid
  # quota command acts on 1K blocks
  args['--blocks'] = Integer(storage_in_gb * 1024 * 1024)
  args['--inodes'] = inodes unless inodes.to_s.empty?
  job = RemoteJob.new('openshift-origin-node', 'set-quota', args)
  job
end

#inc_externally_reserved_uids_size(district_uuid = nil) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 158

def inc_externally_reserved_uids_size(district_uuid=nil)
  if Rails.configuration.msg_broker[:districts][:enabled]
    if @district
      district_uuid = @district.uuid
    else
      district_uuid = get_district_uuid unless district_uuid
    end
    if district_uuid && district_uuid != 'NONE'
      OpenShift::DataStore.instance.inc_district_externally_reserved_uids_size(district_uuid)
    end
  end
end

#move_gear(app, gear, destination_container, destination_district_uuid, allow_change_district, node_profile) ⇒ Object



656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 656

def move_gear(app, gear, destination_container, destination_district_uuid, allow_change_district, node_profile)
  reply = ResultIO.new
  state_map = {}
  gear.node_profile = node_profile if node_profile
  orig_uid = gear.uid

  # resolve destination_container according to district
  destination_container, destination_district_uuid, keep_uid = resolve_destination(app, gear, destination_container, destination_district_uuid, allow_change_district)

  source_container = gear.container
  destination_node_profile = destination_container.get_node_profile
  if app.scalable and source_container.get_node_profile != destination_node_profile
    log_debug "Cannot change node_profile for a gear belonging to a scalable application. The destination container's node profile is #{destination_node_profile}, while the gear's node_profile is #{gear.node_profile}"
    raise OpenShift::UserException.new("Error moving app.  Cannot change node profile.", 1)
  end

  # get the state of all cartridges
  quota_blocks = nil
  quota_files = nil
  idle, leave_stopped, quota_blocks, quota_files = get_app_status(app)
  gi = app.group_instance_map[gear.group_instance_name]
  gi.component_instances.each do |ci_name|
    cinst = app.comp_instance_map[ci_name]
    cart = cinst.parent_cart_name
    next if cart == app.name
    # idle, leave_stopped, quota_blocks, quota_files = get_cart_status(app, gear, cart)
    state_map[ci_name] = [idle, leave_stopped]
  end

  begin
    # pre-move
    reply.append move_gear_pre(app, gear, state_map, keep_uid)

    unless keep_uid
      gear.uid = destination_container.reserve_uid(destination_district_uuid)
      log_debug "DEBUG: Reserved uid '#{gear.uid}' on district: '#{destination_district_uuid}'"
    end
    begin
      # rsync gear with destination container
      rsync_destination_container(app, gear, destination_container, destination_district_uuid, quota_blocks, quota_files, orig_uid, keep_uid)

      # now execute 'move'/'expose-port' hooks on the new nest of the components
      app.configure_order.each do |ci_name|
        next if not gi.component_instances.include?(ci_name)
        cinst = app.comp_instance_map[ci_name]
        cart = cinst.parent_cart_name
        next if cart == app.name
        idle, leave_stopped = state_map[ci_name]
        if keep_uid
          if framework_carts.include?(cart)
            log_debug "DEBUG: Restarting httpd proxy for '#{cart}' on #{destination_container.id}"
            reply.append destination_container.send(:run_cartridge_command, 'abstract', app, gear, "restart-httpd-proxy", nil, false)
          end
        else
          if embedded_carts.include?(cart)
            if app.scalable and cart.include? app.proxy_cartridge
              log_debug "DEBUG: Performing cartridge level move for '#{cart}' on #{destination_container.id}"
              reply.append destination_container.send(:run_cartridge_command, cart, app, gear, "move", idle ? '--idle' : nil, false)
            else
              log_debug "DEBUG: Performing cartridge level move for embedded #{cart} for '#{app.name}' on #{destination_container.id}"
              embedded_reply = destination_container.send(:run_cartridge_command, "embedded/" + cart, app, gear, "move", nil, false)
              component_details = embedded_reply.appInfoIO.string
              unless component_details.empty?
                app.set_embedded_cart_info(cart, component_details)
              end
              reply.append embedded_reply
              log_debug "DEBUG: Performing cartridge level post-move for embedded #{cart} for '#{app.name}' on #{destination_container.id}"
              reply.append destination_container.send(:run_cartridge_command, "embedded/" + cart, app, gear, "post-move", nil, false)
            end
          end
          if framework_carts.include?(cart)
            log_debug "DEBUG: Performing cartridge level move for '#{cart}' on #{destination_container.id}"
            reply.append destination_container.send(:run_cartridge_command, cart, app, gear, "move", idle ? '--idle' : nil, false)
          end
        end
        if app.scalable and not cart.include? app.proxy_cartridge
          begin
            reply.append destination_container.expose_port(app, gear, cinst.parent_cart_name)
          rescue Exception=>e
            # just pass because some embedded cartridges do not have expose-port hook implemented (e.g. jenkins-client)
          end
        end
      end 

      # start the gears again and change DNS entry
      reply.append move_gear_post(app, gear, destination_container, state_map, keep_uid)
      app.elaborate_descriptor
      app.execute_connections
      if app.scalable
        # execute connections restart the haproxy service, so stop it explicitly if needed
        app.start_order.reverse.each do |ci_name|
          next if not gi.component_instances.include? ci_name
          cinst = app.comp_instance_map[ci_name]
          cart = cinst.parent_cart_name
          next if cart==app.name
          idle, leave_stopped = state_map[ci_name]
          if leave_stopped and cart.include? app.proxy_cartridge
            log_debug "DEBUG: Explicitly stopping cartridge '#{cart}' in '#{app.name}' after move on #{destination_container.id}"
            reply.append destination_container.stop(app, gear, cart)
          end
        end
      end
      if gear.node_profile != destination_node_profile
        log_debug "DEBUG: The gear's node profile changed from #{gear.node_profile} to #{destination_node_profile}"
        gear.node_profile = destination_node_profile
        if not app.scalable
          app.node_profile = destination_node_profile 
          gi.node_profile = destination_node_profile
        end
      end
      app.save

    rescue Exception => e
      gear.container = source_container
      # remove-httpd-proxy of destination
      log_debug "DEBUG: Moving failed.  Rolling back gear '#{gear.name}' '#{app.name}' with remove-httpd-proxy on '#{destination_container.id}'"
      gi.component_instances.each do |ci_name|
        cinst = app.comp_instance_map[ci_name]
        cart = cinst.parent_cart_name
        next if cart == app.name
        if framework_carts.include? cart
          begin
            reply.append destination_container.send(:run_cartridge_command, cart, app, gear, "remove-httpd-proxy", nil, false)
          rescue Exception => e
            log_debug "DEBUG: Remove httpd proxy with cart '#{cart}' failed on '#{destination_container.id}'  - gear: '#{gear.name}', app: '#{app.name}'"
          end
        end
      end
      # destroy destination
      log_debug "DEBUG: Moving failed.  Rolling back gear '#{gear.name}' in '#{app.name}' with destroy on '#{destination_container.id}'"
      reply.append destination_container.destroy(app, gear, keep_uid, nil, true)
      raise
    end
  rescue Exception => e
    begin
      unless keep_uid
        # post_move source
        gi.component_instances.each do |ci_name|
          cinst = app.comp_instance_map[ci_name]
          cart = cinst.parent_cart_name
          next if cart==app.name
          proxy_cart = (app.proxy_cartridge or "")
          if embedded_carts.include? cart and not cart.include? proxy_cart
            begin
              log_debug "DEBUG: Performing cartridge level post-move for embedded #{cart} for '#{app.name}' on #{source_container.id}"
              reply.append source_container.send(:run_cartridge_command, "embedded/" + cart, app, gear, "post-move", nil, false)
            rescue Exception => e
              log_error "ERROR: Error performing cartridge level post-move for embedded #{cart} for '#{app.name}' on #{source_container.id}: #{e.message}"
            end
          end
        end
      end
      # start source
      gi.component_instances.each do |ci_name|
        cinst = app.comp_instance_map[ci_name]
        cart = cinst.parent_cart_name
        next if cart==app.name
        idle, leave_stopped = state_map[ci_name]
        if not leave_stopped
          reply.append source_container.run_cartridge_command(cart, app, gear, "start", nil, false) if framework_carts.include? cart
        end
      end
    ensure
      raise
    end
  end

  move_gear_destroy_old(app, gear, keep_uid, orig_uid, source_container, destination_container)

  log_debug "Successfully moved '#{app.name}' with gear uuid '#{gear.uuid}' from '#{source_container.id}' to '#{destination_container.id}'"
  reply
end

#move_gear_destroy_old(app, gear, keep_uid, orig_uid, source_container, destination_container) ⇒ Object



829
830
831
832
833
834
835
836
837
838
839
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 829

def move_gear_destroy_old(app, gear, keep_uid, orig_uid, source_container, destination_container)
  reply = ResultIO.new
  log_debug "DEBUG: Deconfiguring old app '#{app.name}' on #{source_container.id} after move"
  begin
    reply.append source_container.destroy(app, gear, keep_uid, orig_uid, true)
  rescue Exception => e
    log_debug "DEBUG: The application '#{app.name}' with gear uuid '#{gear.uuid}' is now moved to '#{destination_container.id}' but not completely deconfigured from '#{source_container.id}'"
    raise
  end
  reply
end

#move_gear_post(app, gear, destination_container, state_map, keep_uid) ⇒ Object



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 577

def move_gear_post(app, gear, destination_container, state_map, keep_uid)
  reply = ResultIO.new
  source_container = gear.container
  gi = app.group_instance_map[gear.group_instance_name]
  app.start_order.each do |ci_name|
    next if not gi.component_instances.include? ci_name
    cinst = app.comp_instance_map[ci_name]
    cart = cinst.parent_cart_name
    next if cart==app.name
    idle, leave_stopped = state_map[ci_name]
    unless leave_stopped
      log_debug "DEBUG: Starting cartridge '#{cart}' in '#{app.name}' after move on #{destination_container.id}"
      reply.append destination_container.send(:run_cartridge_command, cart, app, gear, "start", nil, false)
    end
  end

  log_debug "DEBUG: Fixing DNS and mongo for gear '#{gear.name}' after move"
  log_debug "DEBUG: Changing server identity of '#{gear.name}' from '#{source_container.id}' to '#{destination_container.id}'"
  gear.server_identity = destination_container.id
  gear.container = destination_container
  if app.scalable and not gi.component_instances.find { |cart| cart.include? app.proxy_cartridge }
    dns = OpenShift::DnsService.instance
    begin
      public_hostname = destination_container.get_public_hostname
      dns.modify_application(gear.name, app.domain.namespace, public_hostname)
      dns.publish
    ensure
      dns.close
    end
  end

  if (not app.scalable) or (app.scalable and gi.component_instances.find { |cart| cart.include? app.proxy_cartridge } )
    unless keep_uid
      unless app.aliases.nil?
        app.aliases.each do |server_alias|
          reply.append destination_container.add_alias(app, app.gear, server_alias)
        end
      end
    end
    app.recreate_dns
  end

  reply
end

#move_gear_pre(app, gear, state_map, keep_uid) ⇒ Object



622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 622

def move_gear_pre(app, gear, state_map, keep_uid)
  reply = ResultIO.new
  source_container = gear.container
  gi = app.group_instance_map[gear.group_instance_name]
  app.start_order.reverse.each { |ci_name|
    next if not gi.component_instances.include? ci_name
    cinst = app.comp_instance_map[ci_name]
    cart = cinst.parent_cart_name
    next if cart==app.name
    idle, leave_stopped = state_map[ci_name]
    # stop the cartridge if it needs to
    unless leave_stopped
      log_debug "DEBUG: Stopping existing app cartridge '#{cart}' before moving"
      do_with_retry('stop') do
        reply.append source_container.stop(app, gear, cart)
      end
      if framework_carts.include? cart
        log_debug "DEBUG: Force stopping existing app cartridge '#{cart}' before moving"
        do_with_retry('force-stop') do
          reply.append source_container.force_stop(app, gear, cart)
        end
      end
    end
    # execute pre_move
    if embedded_carts.include? cart and not keep_uid
      if (app.scalable and not cart.include? app.proxy_cartridge) or not app.scalable
        log_debug "DEBUG: Performing cartridge level pre-move for embedded #{cart} for '#{app.name}' on #{source_container.id}"
        reply.append source_container.send(:run_cartridge_command, "embedded/" + cart, app, gear, "pre-move", nil, false)
      end
    end
  }
  reply
end

#reload(app, gear, cart) ⇒ Object



397
398
399
400
401
402
403
404
405
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 397

def reload(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "reload")
  elsif embedded_carts.include? cart
    reload_component(app, gear, cart)
  else
    ResultIO.new          
  end
end

#remove_alias(app, gear, server_alias) ⇒ Object



463
464
465
466
467
468
469
470
471
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 463

def remove_alias(app, gear, server_alias)
  args = Hash.new
  args['--with-container-uuid']=gear.uuid
  args['--with-container-name']=gear.name
  args['--with-namespace']=app.domain.namespace
  args['--with-alias-name']=server_alias
  result = execute_direct(@@C_CONTROLLER, 'remove-alias', args)
  parse_result(result)        
end

#remove_authorized_ssh_key(app, gear, ssh_key, comment = nil) ⇒ Object



227
228
229
230
231
232
233
234
235
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 227

def remove_authorized_ssh_key(app, gear, ssh_key, comment=nil)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-ssh-key'] = ssh_key
  args['--with-ssh-comment'] = comment if comment
  result = execute_direct(@@C_CONTROLLER, 'authorized-ssh-key-remove', args)
  parse_result(result)
end

#remove_broker_auth_key(app, gear) ⇒ Object



266
267
268
269
270
271
272
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 266

def remove_broker_auth_key(app, gear)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  result = execute_direct(@@C_CONTROLLER, 'broker-auth-key-remove', args)
  parse_result(result)
end

#remove_env_var(app, gear, key) ⇒ Object



247
248
249
250
251
252
253
254
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 247

def remove_env_var(app, gear, key)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  args['--with-key'] = key
  result = execute_direct(@@C_CONTROLLER, 'env-var-remove', args)
  parse_result(result)
end

#reserve_uid(district_uuid = nil) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 129

def reserve_uid(district_uuid=nil)
  reserved_uid = nil
  if Rails.configuration.msg_broker[:districts][:enabled]
    if @district
      district_uuid = @district.uuid
    else
      district_uuid = get_district_uuid unless district_uuid
    end
    if district_uuid && district_uuid != 'NONE'
      reserved_uid = OpenShift::DataStore.instance.reserve_district_uid(district_uuid)
      raise OpenShift::OOException.new("uid could not be reserved") unless reserved_uid
    end
  end
  reserved_uid
end

#resolve_destination(app, gear, destination_container, destination_district_uuid, allow_change_district) ⇒ Object



841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 841

def resolve_destination(app, gear, destination_container, destination_district_uuid, allow_change_district)
  source_container = gear.container
  source_container = gear.get_proxy if source_container.nil? 
  source_district_uuid = source_container.get_district_uuid
  if destination_container.nil?
    unless allow_change_district
      if destination_district_uuid && destination_district_uuid != source_district_uuid
        raise OpenShift::UserException.new("Error moving app.  Cannot change district from '#{source_district_uuid}' to '#{destination_district_uuid}' without allow_change_district flag.", 1)
      else
        destination_district_uuid = source_district_uuid unless source_district_uuid == 'NONE'
      end
    end
    destination_container = MCollectiveApplicationContainerProxy.find_available_impl(gear.node_profile, destination_district_uuid)
    log_debug "DEBUG: Destination container: #{destination_container.id}"
    destination_district_uuid = destination_container.get_district_uuid
  else
    if destination_district_uuid
      log_debug "DEBUG: Destination district uuid '#{destination_district_uuid}' is being ignored in favor of destination container #{destination_container.id}"
    end
    destination_district_uuid = destination_container.get_district_uuid
    unless allow_change_district || (source_district_uuid == destination_district_uuid)
      raise OpenShift::UserException.new("Resulting move would change districts from '#{source_district_uuid}' to '#{destination_district_uuid}'.  You can use the 'allow_change_district' option if you really want this to happen.", 1)
    end
  end
  
  log_debug "DEBUG: Source district uuid: #{source_district_uuid}"
  log_debug "DEBUG: Destination district uuid: #{destination_district_uuid}"
  keep_uid = destination_district_uuid == source_district_uuid && destination_district_uuid && destination_district_uuid != 'NONE'
  log_debug "DEBUG: District unchanged keeping uid" if keep_uid

  if source_container.id == destination_container.id
    raise OpenShift::UserException.new("Error moving app.  Old and new servers are the same: #{source_container.id}", 1)
  end
  return [destination_container, destination_district_uuid, keep_uid]
end

#restart(app, gear, cart) ⇒ Object



387
388
389
390
391
392
393
394
395
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 387

def restart(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "restart")
  elsif embedded_carts.include? cart
    restart_component(app, gear, cart)
  else
    ResultIO.new                  
  end
end

#rsync_destination_container(app, gear, destination_container, destination_district_uuid, quota_blocks, quota_files, orig_uid, keep_uid) ⇒ Object



877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 877

def rsync_destination_container(app, gear, destination_container, destination_district_uuid, quota_blocks, quota_files, orig_uid, keep_uid)
  reply = ResultIO.new
  source_container = gear.container
  log_debug "DEBUG: Creating new account for gear '#{gear.name}' on #{destination_container.id}"
  reply.append destination_container.create(app, gear, quota_blocks, quota_files)

  log_debug "DEBUG: Moving content for app '#{app.name}', gear '#{gear.name}' to #{destination_container.id}"
  rsync_keyfile = Rails.configuration.auth[:rsync_keyfile]
  log_debug `eval \`ssh-agent\`; ssh-add #{rsync_keyfile}; ssh -o StrictHostKeyChecking=no -A root@#{source_container.get_ip_address} "rsync -aA#{(gear.uid && gear.uid == orig_uid) ? 'X' : ''} -e 'ssh -o StrictHostKeyChecking=no' /var/lib/openshift/#{gear.uuid}/ root@#{destination_container.get_ip_address}:/var/lib/openshift/#{gear.uuid}/"; exit_code=$?; ssh-agent -k; exit $exit_code`
  if $?.exitstatus != 0
    raise OpenShift::NodeException.new("Error moving app '#{app.name}', gear '#{gear.name}' from #{source_container.id} to #{destination_container.id}", 143)
  end

  if keep_uid
    log_debug "DEBUG: Moving system components for app '#{app.name}', gear '#{gear.name}' to #{destination_container.id}"
    log_debug `eval \`ssh-agent\`; ssh-add #{rsync_keyfile}; ssh -o StrictHostKeyChecking=no -A root@#{source_container.get_ip_address} "rsync -aAX -e 'ssh -o StrictHostKeyChecking=no' --include '.httpd.d/' --include '.httpd.d/#{gear.uuid}_***' --include '#{app.name}-#{app.domain.namespace}' --include '.last_access/' --include '.last_access/#{gear.uuid}' --exclude '*' /var/lib/openshift/ root@#{destination_container.get_ip_address}:/var/lib/openshift/"; exit_code=$?; ssh-agent -k; exit $exit_code`
    if $?.exitstatus != 0
      raise OpenShift::NodeException.new("Error moving system components for app '#{app.name}', gear '#{gear.name}' from #{source_container.id} to #{destination_container.id}", 143)
    end
  end
  reply
end

#set_district(uuid, active) ⇒ Object



980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 980

def set_district(uuid, active)
  mc_args = { :uuid => uuid,
              :active => active}
  rpc_client = rpc_exec_direct('openshift')
  result = nil
  begin
    Rails.logger.debug "DEBUG: rpc_client.custom_request('set_district', #{mc_args.inspect}, #{@id}, {'identity' => #{@id}})"
    result = rpc_client.custom_request('set_district', mc_args, @id, {'identity' => @id})
    Rails.logger.debug "DEBUG: #{result.inspect}"
  ensure
    rpc_client.disconnect
  end
  Rails.logger.debug result.inspect
  result
end

#set_quota(gear, storage_in_gb, inodes) ⇒ Object

Set blocks hard limit and inodes ihard limit for uuid



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 105

def set_quota(gear, storage_in_gb, inodes)
  args = Hash.new
  args['--uuid']   = gear.uuid
  # quota command acts on 1K blocks
  args['--blocks'] = Integer(storage_in_gb * 1024 * 1024)
  args['--inodes'] = inodes unless inodes.nil?
  reply = execute_direct(@@C_CONTROLLER, 'set-quota', args, false)

  output = nil
  exitcode = 0
  if reply.length > 0
    mcoll_result = reply[0]
    if (mcoll_result && (defined? mcoll_result.results) && !mcoll_result.results[:data].nil?)
      output = mcoll_result.results[:data][:output]
      exitcode = mcoll_result.results[:data][:exitcode]
      raise OpenShift::NodeException.new("Failed to set quota for user: #{output}", 143) unless exitcode == 0
    else
      raise OpenShift::NodeException.new("Node execution failure (error getting result from node).  If the problem persists please contact Red Hat support.", 143)
    end
  else
    raise OpenShift::NodeException.new("Node execution failure (error getting result from node).  If the problem persists please contact Red Hat support.", 143)
  end
end

#show_port(app, gear, cart) ⇒ Object



449
450
451
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 449

def show_port(app, gear, cart)
  run_cartridge_command(cart, app, gear, "show-port")
end

#show_state(app, gear) ⇒ Object



274
275
276
277
278
279
280
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 274

def show_state(app, gear)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  result = execute_direct(@@C_CONTROLLER, 'app-state-show', args)
  parse_result(result)
end

#start(app, gear, cart) ⇒ Object



359
360
361
362
363
364
365
366
367
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 359

def start(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "start")
  elsif embedded_carts.include? cart
    start_component(app, gear, cart)
  else
    ResultIO.new
  end
end

#status(app, gear, cart) ⇒ Object



407
408
409
410
411
412
413
414
415
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 407

def status(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "status")
  elsif embedded_carts.include? cart
    component_status(app, gear, cart)
  else
    ResultIO.new          
  end
end

#stop(app, gear, cart) ⇒ Object



369
370
371
372
373
374
375
376
377
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 369

def stop(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "stop")
  elsif embedded_carts.include? cart
    stop_component(app, gear, cart)
  else
    ResultIO.new          
  end
end

#system_messages(app, gear, cart) ⇒ Object



433
434
435
436
437
438
439
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 433

def system_messages(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "system-messages")
  else
    ResultIO.new
  end          
end

#threaddump(app, gear, cart) ⇒ Object



425
426
427
428
429
430
431
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 425

def threaddump(app, gear, cart)
  if framework_carts.include?(cart)
    run_cartridge_command(cart, app, gear, "threaddump")
  else
    ResultIO.new
  end          
end

#tidy(app, gear, cart) ⇒ Object



417
418
419
420
421
422
423
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 417

def tidy(app, gear, cart)
  args = Hash.new
  args['--with-app-uuid'] = app.uuid
  args['--with-container-uuid'] = gear.uuid
  result = execute_direct(@@C_CONTROLLER, 'tidy', args)
  parse_result(result)
end

#unreserve_uid(uid, district_uuid = nil) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 145

def unreserve_uid(uid, district_uuid=nil)
  if Rails.configuration.msg_broker[:districts][:enabled]
    if @district
      district_uuid = @district.uuid
    else
      district_uuid = get_district_uuid unless district_uuid
    end
    if district_uuid && district_uuid != 'NONE'
      OpenShift::DataStore.instance.unreserve_district_uid(district_uuid, uid)
    end
  end
end

#update_namespace(app, gear, cart, new_ns, old_ns) ⇒ Object



473
474
475
476
# File 'lib/openshift/mcollective_application_container_proxy.rb', line 473

def update_namespace(app, gear, cart, new_ns, old_ns)
  mcoll_reply = execute_direct(cart, 'update-namespace', "#{gear.name} #{new_ns} #{old_ns} #{gear.uuid}")
  parse_result(mcoll_reply)
end