class RHC::Rest::Mock::MockRestApplication
Attributes
region[W]
Public Class Methods
new(client, name, type, domain, scale=nil, gear_profile='default', initial_git_url=nil, environment_variables=nil, region=nil)
click to toggle source
Calls superclass method
# File lib/rhc/rest/mock.rb, line 858 def initialize(client, name, type, domain, scale=nil, gear_profile='default', initial_git_url=nil, environment_variables=nil, region=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.name}.fake.foo/" @ssh_url = "ssh://#{@uuid}@127.0.0.1" @aliases = [] @environment_variables = environment_variables || [] @gear_profile = gear_profile @auto_deploy = true @keep_deployments = 1 if scale @scalable = true end @region = region 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, true) 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] prox.tags = ['web_proxy'] 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 977 def add_alias(app_alias) @aliases << MockRestAlias.new(@client, app_alias) end
add_cartridge(cart, embedded=true, environment_variables=nil)
click to toggle source
# File lib/rhc/rest/mock.rb, line 899 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
add_member(member)
click to toggle source
# File lib/rhc/rest/mock.rb, line 1019 def add_member(member) (@members ||= []) << member (attributes['members'] ||= []) << member.attributes self end
aliases()
click to toggle source
# File lib/rhc/rest/mock.rb, line 985 def aliases @aliases end
auto_deploy()
click to toggle source
# File lib/rhc/rest/mock.rb, line 1029 def auto_deploy @auto_deploy || false end
cartridges()
click to toggle source
# File lib/rhc/rest/mock.rb, line 937 def cartridges @cartridges end
configure(options={})
click to toggle source
# File lib/rhc/rest/mock.rb, line 1025 def configure(options={}) options.each {|key,value| self.instance_variable_set("@#{key.to_s}", value)} end
deployments()
click to toggle source
# File lib/rhc/rest/mock.rb, line 1041 def deployments base_time1 = Time.local(2000,1,1,1,0,0).strftime('%Y-%m-%dT%H:%M:%S%z') base_time2 = Time.local(2000,1,1,2,0,0).strftime('%Y-%m-%dT%H:%M:%S%z') base_time3 = Time.local(2000,1,1,3,0,0).strftime('%Y-%m-%dT%H:%M:%S%z') base_time4 = Time.local(2000,1,1,4,0,0).strftime('%Y-%m-%dT%H:%M:%S%z') base_time5 = Time.local(2000,1,1,5,0,0).strftime('%Y-%m-%dT%H:%M:%S%z') base_time6 = Time.local(2000,1,1,6,0,0).strftime('%Y-%m-%dT%H:%M:%S%z') [ MockRestDeployment.new(self, '0000001', 'master', '0000001', nil, false, base_time1, false, [base_time1]), MockRestDeployment.new(self, '0000002', 'master', '0000002', nil, false, base_time2, false, [base_time2, base_time6]), MockRestDeployment.new(self, '0000003', 'master', '0000003', nil, false, base_time3, false, [base_time3, base_time5]), MockRestDeployment.new(self, '0000004', 'master', '0000004', nil, false, base_time4, false, [base_time4]), MockRestDeployment.new(self, '0000005', 'master', '0000005', nil, false, base_time5, false, [base_time5]), ] end
destroy()
click to toggle source
# File lib/rhc/rest/mock.rb, line 895 def destroy @domain.applications.delete self end
enable_ha()
click to toggle source
# File lib/rhc/rest/mock.rb, line 961 def enable_ha if supports? "MAKE_HA" @app else raise RHC::HighAvailabilityNotSupportedException.new end end
environment_variables()
click to toggle source
# File lib/rhc/rest/mock.rb, line 989 def environment_variables if supports? "LIST_ENVIRONMENT_VARIABLES" @environment_variables || [] else raise RHC::EnvironmentVariablesNotSupportedException.new end end
fakeuuid()
click to toggle source
# File lib/rhc/rest/mock.rb, line 854 def fakeuuid "fakeuuidfortests#{@name}" end
gear_groups()
click to toggle source
# File lib/rhc/rest/mock.rb, line 926 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
id()
click to toggle source
# File lib/rhc/rest/mock.rb, line 922 def id @uuid || attributes['uuid'] || attributes['id'] end
init_members()
click to toggle source
# File lib/rhc/rest/mock.rb, line 1013 def init_members @members ||= [] attributes['members'] ||= [] self end
keep_deployments()
click to toggle source
# File lib/rhc/rest/mock.rb, line 1033 def keep_deployments @keep_deployments end
region()
click to toggle source
# File lib/rhc/rest/mock.rb, line 1037 def region @region end
reload()
click to toggle source
# File lib/rhc/rest/mock.rb, line 953 def reload @app end
remove_alias(app_alias)
click to toggle source
# File lib/rhc/rest/mock.rb, line 981 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 949 def restart @app end
scale_down()
click to toggle source
# File lib/rhc/rest/mock.rb, line 973 def scale_down @app end
scale_up()
click to toggle source
# File lib/rhc/rest/mock.rb, line 969 def scale_up @app end
set_environment_variables(env_vars=[])
click to toggle source
# File lib/rhc/rest/mock.rb, line 997 def set_environment_variables(env_vars=[]) if supports? "SET_UNSET_ENVIRONMENT_VARIABLES" environment_variables.concat env_vars else raise RHC::EnvironmentVariablesNotSupportedException.new end end
start()
click to toggle source
# File lib/rhc/rest/mock.rb, line 941 def start @app end
stop(*args)
click to toggle source
# File lib/rhc/rest/mock.rb, line 945 def stop(*args) @app end
tidy()
click to toggle source
# File lib/rhc/rest/mock.rb, line 957 def tidy @app end
unset_environment_variables(env_vars=[])
click to toggle source
# File lib/rhc/rest/mock.rb, line 1005 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