# File lib/rhc/rest/mock.rb, line 702 def initialize(client, name, type, domain, scale=nil, gear_profile='default', initial_git_url=nil, environment_variables=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 = [] @environment_variables = environment_variables || [] @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
# File lib/rhc/rest/mock.rb, line 797 def add_alias(app_alias) @aliases << MockRestAlias.new(@client, app_alias) end
# File lib/rhc/rest/mock.rb, line 739 def add_cartridge(cart, embedded=true, environment_variables=nil) name, url = if cart.is_a? String [cart, nil] elsif cart.respond_to? :[] [cart[:name] || cart['name'], cart[:url] || cart['url']] elsif RHC::Rest::Cartridge === cart [cart.name, cart.url] end type = embedded ? "embedded" : "standalone" c = MockRestCartridge.new(client, name, type, self) if url c.url = url c.name = c.url_basename end #set_environment_variables(environment_variables) c.properties << {'name' => 'prop1', 'value' => 'value1', 'description' => 'description1' } @cartridges << c c.messages << "Cartridge added with properties" c end
# File lib/rhc/rest/mock.rb, line 805 def aliases @aliases end
# File lib/rhc/rest/mock.rb, line 773 def cartridges @cartridges end
# File lib/rhc/rest/mock.rb, line 735 def destroy @domain.applications.delete self end
# File lib/rhc/rest/mock.rb, line 809 def environment_variables if supports? "LIST_ENVIRONMENT_VARIABLES" @environment_variables || [] else raise RHC::EnvironmentVariablesNotSupportedException.new end end
# File lib/rhc/rest/mock.rb, line 698 def fakeuuid "fakeuuidfortests#{@name}" end
# File lib/rhc/rest/mock.rb, line 762 def gear_groups # we don't have heavy interaction with gear groups yet so keep this simple @gear_groups ||= begin if @scalable cartridges.map{ |c| MockRestGearGroup.new(client, [c.name], c.current_scale) if c.name != 'haproxy-1.4' }.compact else [MockRestGearGroup.new(client, cartridges.map{ |c| {'name' => c.name} }, 1)] end end end
# File lib/rhc/rest/mock.rb, line 789 def reload @app end
# File lib/rhc/rest/mock.rb, line 801 def remove_alias(app_alias) @aliases.delete_if {|x| x.id == app_alias} end
# File lib/rhc/rest/mock.rb, line 785 def restart @app end
# File lib/rhc/rest/mock.rb, line 817 def set_environment_variables(env_vars=[]) if supports? "SET_UNSET_ENVIRONMENT_VARIABLES" environment_variables.concat env_vars else raise RHC::EnvironmentVariablesNotSupportedException.new end end
# File lib/rhc/rest/mock.rb, line 777 def start @app end
# File lib/rhc/rest/mock.rb, line 781 def stop(*args) @app end
# File lib/rhc/rest/mock.rb, line 793 def tidy @app end
# File lib/rhc/rest/mock.rb, line 825 def unset_environment_variables(env_vars=[]) if supports? "SET_UNSET_ENVIRONMENT_VARIABLES" env_vars.each { |item| environment_variables.delete_if { |env_var| env_var.name == item } } else raise RHC::EnvironmentVariablesNotSupportedException.new end end