class RHC::Rest::Mock::MockRestApplication

Public Class Methods

new(client, name, type, domain, scale=nil, gear_profile='default', initial_git_url=nil) click to toggle source
# File lib/rhc/rest/mock.rb, line 634
def initialize(client, name, type, domain, scale=nil, gear_profile='default', initial_git_url=nil)
  super({}, client)
  @name = name
  @domain = domain
  @cartridges = []
  @creation_time = Date.new(2000, 1, 1).strftime('%Y-%m-%dT%H:%M:%S%z')
  @uuid = fakeuuid
  @initial_git_url = initial_git_url
  @git_url = "git:fake.foo/git/#{@name}.git"
  @app_url = "https://#{@name}-#{@domain.id}.fake.foo/"
  @ssh_url = "ssh://#{@uuid}@127.0.0.1"
  @aliases = []
  @gear_profile = gear_profile
  if scale
    @scalable = true
  end
  self.attributes = {:links => mock_response_links(mock_app_links('mock_domain_0', 'mock_app_0')), :messages => []}
  self.gear_count = 5
  types = Array(type)
  cart = add_cartridge(types.first, false) if types.first
  if scale
    cart.supported_scales_to = (cart.scales_to = -1)
    cart.supported_scales_from = (cart.scales_from = 2)
    cart.current_scale = 2
    cart.scales_with = "haproxy-1.4"
    prox = add_cartridge('haproxy-1.4')
    prox.collocated_with = [types.first]
  end
  types.drop(1).each{ |c| add_cartridge(c, false) }
  @framework = types.first
end

Public Instance Methods

add_alias(app_alias) click to toggle source
# File lib/rhc/rest/mock.rb, line 708
def add_alias(app_alias)
  @aliases << MockRestAlias.new(@client, app_alias)
end
add_cartridge(name, embedded=true) click to toggle source
# File lib/rhc/rest/mock.rb, line 670
def add_cartridge(name, embedded=true)
  type = embedded ? "embedded" : "standalone"
  c = MockRestCartridge.new(client, name, type, self)
  c.properties << {'name' => 'prop1', 'value' => 'value1', 'description' => 'description1' }
  @cartridges << c
  c.messages << "Cartridge added with properties"
  c
end
aliases() click to toggle source
# File lib/rhc/rest/mock.rb, line 716
def aliases
  @aliases
end
cartridges() click to toggle source
# File lib/rhc/rest/mock.rb, line 684
def cartridges
  @cartridges
end
destroy() click to toggle source
# File lib/rhc/rest/mock.rb, line 666
def destroy
  @domain.applications.delete self
end
fakeuuid() click to toggle source
# File lib/rhc/rest/mock.rb, line 630
def fakeuuid
  "fakeuuidfortests#{@name}"
end
gear_groups() click to toggle source
# File lib/rhc/rest/mock.rb, line 679
def gear_groups
  # we don't have heavy interaction with gear groups yet so keep this simple
  @gear_groups ||= [MockRestGearGroup.new(client)]
end
reload() click to toggle source
# File lib/rhc/rest/mock.rb, line 700
def reload
  @app
end
remove_alias(app_alias) click to toggle source
# File lib/rhc/rest/mock.rb, line 712
def remove_alias(app_alias)
  @aliases.delete_if {|x| x.id == app_alias}
end
restart() click to toggle source
# File lib/rhc/rest/mock.rb, line 696
def restart
  @app
end
start() click to toggle source
# File lib/rhc/rest/mock.rb, line 688
def start
  @app
end
stop(*args) click to toggle source
# File lib/rhc/rest/mock.rb, line 692
def stop(*args)
  @app
end
tidy() click to toggle source
# File lib/rhc/rest/mock.rb, line 704
def tidy
  @app
end