Class: Fog::AWS::ELB::Mock
- Inherits:
-
Object
- Object
- Fog::AWS::ELB::Mock
- Defined in:
- lib/fog/aws/elb.rb,
lib/fog/aws/elb/policy_types.rb,
lib/fog/aws/requests/elb/create_load_balancer.rb,
lib/fog/aws/requests/elb/delete_load_balancer.rb,
lib/fog/aws/requests/elb/configure_health_check.rb,
lib/fog/aws/requests/elb/describe_load_balancers.rb,
lib/fog/aws/requests/elb/describe_instance_health.rb,
lib/fog/aws/requests/elb/create_load_balancer_policy.rb,
lib/fog/aws/requests/elb/delete_load_balancer_policy.rb,
lib/fog/aws/requests/elb/create_load_balancer_listeners.rb,
lib/fog/aws/requests/elb/delete_load_balancer_listeners.rb,
lib/fog/aws/requests/elb/attach_load_balancer_to_subnets.rb,
lib/fog/aws/requests/elb/describe_load_balancer_policies.rb,
lib/fog/aws/requests/elb/detach_load_balancer_from_subnets.rb,
lib/fog/aws/requests/elb/create_lb_cookie_stickiness_policy.rb,
lib/fog/aws/requests/elb/create_app_cookie_stickiness_policy.rb,
lib/fog/aws/requests/elb/describe_load_balancer_policy_types.rb,
lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb,
lib/fog/aws/requests/elb/apply_security_groups_to_load_balancer.rb,
lib/fog/aws/requests/elb/set_load_balancer_policies_of_listener.rb,
lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb,
lib/fog/aws/requests/elb/set_load_balancer_listener_ssl_certificate.rb,
lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb,
lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb
Constant Summary collapse
- POLICY_TYPES =
[{ "Description" => "", "PolicyAttributeTypeDescriptions" => [{ "AttributeName"=>"CookieName", "AttributeType"=>"String", "Cardinality"=>"ONE", "DefaultValue"=>"", "Description"=>"" }], "PolicyTypeName"=>"AppCookieStickinessPolicyType" }, { "Description" => "", "PolicyAttributeTypeDescriptions" => [{ "AttributeName"=>"CookieExpirationPeriod", "AttributeType"=>"String", "Cardinality"=>"ONE", "DefaultValue"=>"", "Description"=>"" }], "PolicyTypeName"=>"LBCookieStickinessPolicyType" }, { "Description" => "Policy containing a list of public keys to accept when authenticating the back-end server(s). This policy cannot be applied directly to back-end servers or listeners but must be part of a BackendServerAuthenticationPolicyType.", "PolicyAttributeTypeDescriptions" => [{ "AttributeName"=>"PublicKey", "AttributeType"=>"String", "Cardinality"=>"ONE", "DefaultValue"=>"", "Description"=>"" }], "PolicyTypeName"=>"PublicKeyPolicyType" }, { "Description" => "Listener policy that defines the ciphers and protocols that will be accepted by the load balancer. This policy can be associated only with HTTPS/SSL listeners.", "PolicyAttributeTypeDescriptions" => [{ "AttributeName"=>"Protocol-SSLv2", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EDH-DSS-DES-CBC3-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-RSA-CAMELLIA128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DES-CBC-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"KRB5-RC4-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-CAMELLIA128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-KRB5-RC4-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-RC4-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"PSK-RC4-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"PSK-AES128-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-EDH-RSA-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"CAMELLIA128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-DSS-AES128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EDH-RSA-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-RSA-SEED-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"KRB5-DES-CBC-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-RSA-CAMELLIA256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-DES-CBC3-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DES-CBC3-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-KRB5-RC2-CBC-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EDH-DSS-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"KRB5-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"PSK-AES256-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-AES256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"KRB5-DES-CBC3-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"AES128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"DHE-DSS-SEED-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-CAMELLIA256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-KRB5-RC4-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EDH-RSA-DES-CBC3-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-KRB5-DES-CBC-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"Protocol-TLSv1", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"PSK-3DES-EDE-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"SEED-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-DSS-CAMELLIA256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"IDEA-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"RC2-CBC-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"KRB5-RC4-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-AES128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"RC4-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"AES256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"Protocol-SSLv3", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"EXP-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DES-CBC3-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"DHE-RSA-AES128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-EDH-DSS-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-KRB5-RC2-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-RSA-AES256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"KRB5-DES-CBC3-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"RC4-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"TRUE", "Description"=>"" }, { "AttributeName"=>"EXP-RC2-CBC-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-ADH-RC4-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-RC4-MD5", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"CAMELLIA256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-DSS-CAMELLIA128-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-KRB5-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"EXP-ADH-DES-CBC-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"DHE-DSS-AES256-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }, { "AttributeName"=>"ADH-SEED-SHA", "AttributeType"=>"Boolean", "Cardinality"=>"ONE", "DefaultValue"=>"FALSE", "Description"=>"" }], "PolicyTypeName"=>"SSLNegotiationPolicyType" }]
Class Method Summary collapse
Instance Method Summary collapse
- #apply_security_groups_to_load_balancer(security_group_ids, lb_name) ⇒ Object (also: #apply_security_groups)
- #attach_load_balancer_to_subnets(subnet_ids, lb_name) ⇒ Object (also: #enable_subnets)
- #configure_health_check(lb_name, health_check) ⇒ Object
- #create_app_cookie_stickiness_policy(lb_name, policy_name, cookie_name) ⇒ Object
- #create_lb_cookie_stickiness_policy(lb_name, policy_name, cookie_expiration_period = nil) ⇒ Object
- #create_load_balancer(availability_zones, lb_name, listeners = [], options = {}) ⇒ Object
- #create_load_balancer_listeners(lb_name, listeners) ⇒ Object
- #create_load_balancer_policy(lb_name, name, type_name, attributes = {}) ⇒ Object
- #data ⇒ Object
- #delete_load_balancer(lb_name) ⇒ Object
- #delete_load_balancer_listeners(lb_name, load_balancer_ports) ⇒ Object
- #delete_load_balancer_policy(lb_name, policy_name) ⇒ Object
- #deregister_instances_from_load_balancer(instance_ids, lb_name) ⇒ Object (also: #deregister_instances)
- #describe_instance_health(lb_name, instance_ids = []) ⇒ Object
- #describe_load_balancer_policies(lb_name = nil, names = []) ⇒ Object
- #describe_load_balancer_policy_types(type_names = []) ⇒ Object
- #describe_load_balancers(options = {}) ⇒ Object
- #detach_load_balancer_from_subnets(subnet_ids, lb_name) ⇒ Object (also: #disable_subnets)
- #disable_availability_zones_for_load_balancer(availability_zones, lb_name) ⇒ Object (also: #disable_zones)
- #enable_availability_zones_for_load_balancer(availability_zones, lb_name) ⇒ Object (also: #enable_zones)
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #register_instances_with_load_balancer(instance_ids, lb_name) ⇒ Object (also: #register_instances)
- #reset_data ⇒ Object
- #set_load_balancer_listener_ssl_certificate(lb_name, load_balancer_port, ssl_certificate_id) ⇒ Object
- #set_load_balancer_policies_of_listener(lb_name, load_balancer_port, policy_names) ⇒ Object
- #setup_credentials(options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fog/aws/elb.rb', line 78 def initialize(={}) @use_iam_profile = [:use_iam_profile] setup_credentials() @region = [:region] || 'us-east-1' unless ['ap-northeast-1', 'ap-southeast-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2'].include?(@region) raise ArgumentError, "Unknown region: #{@region.inspect}" end end |
Class Method Details
.data ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fog/aws/elb.rb', line 57 def self.data @data ||= Hash.new do |hash, region| owner_id = Fog::AWS::Mock.owner_id hash[region] = Hash.new do |region_hash, key| region_hash[key] = { :owner_id => owner_id, :load_balancers => {}, :policy_types => Fog::AWS::ELB::Mock::POLICY_TYPES } end end end |
.dns_name(name, region) ⇒ Object
70 71 72 |
# File 'lib/fog/aws/elb.rb', line 70 def self.dns_name(name, region) "#{name}-#{Fog::Mock.random_hex(8)}.#{region}.elb.amazonaws.com" end |
.reset ⇒ Object
74 75 76 |
# File 'lib/fog/aws/elb.rb', line 74 def self.reset @data = nil end |
Instance Method Details
#apply_security_groups_to_load_balancer(security_group_ids, lb_name) ⇒ Object Also known as: apply_security_groups
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/aws/requests/elb/apply_security_groups_to_load_balancer.rb', line 36 def apply_security_groups_to_load_balancer(security_group_ids, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['SecurityGroups'] << security_group_ids load_balancer['SecurityGroups'].flatten!.uniq! response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DetachLoadBalancerFromSubnetsResult' => { 'SecurityGroups' => load_balancer['SecurityGroups'] } } response end |
#attach_load_balancer_to_subnets(subnet_ids, lb_name) ⇒ Object Also known as: enable_subnets
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/aws/requests/elb/attach_load_balancer_to_subnets.rb', line 36 def attach_load_balancer_to_subnets(subnet_ids, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['Subnets'] << subnet_ids load_balancer['Subnets'].flatten!.uniq! response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'AttachLoadBalancerToSubnetsResult' => { 'Subnets' => load_balancer['Subnets'] } } response end |
#configure_health_check(lb_name, health_check) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fog/aws/requests/elb/configure_health_check.rb', line 41 def configure_health_check(lb_name, health_check) if load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['HealthCheck'] = health_check response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'ConfigureHealthCheckResult' => { 'HealthCheck' => load_balancer['HealthCheck'] } } response else raise Fog::AWS::ELB::NotFound end end |
#create_app_cookie_stickiness_policy(lb_name, policy_name, cookie_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/aws/requests/elb/create_app_cookie_stickiness_policy.rb', line 33 def (lb_name, policy_name, ) if load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['Policies']['AppCookieStickinessPolicies'] << { 'CookieName' => , 'PolicyName' => policy_name } create_load_balancer_policy(lb_name, policy_name, 'AppCookieStickinessPolicyType', {'CookieName' => }) response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else raise Fog::AWS::ELB::NotFound end end |
#create_lb_cookie_stickiness_policy(lb_name, policy_name, cookie_expiration_period = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fog/aws/requests/elb/create_lb_cookie_stickiness_policy.rb', line 35 def (lb_name, policy_name, =nil) if load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['Policies']['LBCookieStickinessPolicies'] << { 'CookieExpirationPeriod' => , 'PolicyName' => policy_name } create_load_balancer_policy(lb_name, policy_name, 'LBCookieStickinessPolicyType', {'CookieExpirationPeriod' => }) response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else raise Fog::AWS::ELB::NotFound end end |
#create_load_balancer(availability_zones, lb_name, listeners = [], options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/aws/requests/elb/create_load_balancer.rb', line 60 def create_load_balancer(availability_zones, lb_name, listeners = [], = {}) response = Excon::Response.new response.status = 200 raise Fog::AWS::ELB::IdentifierTaken if self.data[:load_balancers].has_key? lb_name certificate_ids = Fog::AWS::IAM::Mock.data[@aws_access_key_id][:server_certificates].map {|n, c| c['Arn'] } listeners = [*listeners].map do |listener| if listener['SSLCertificateId'] and !certificate_ids.include? listener['SSLCertificateId'] raise Fog::AWS::IAM::NotFound.new('CertificateNotFound') end {'Listener' => listener, 'PolicyNames' => []} end dns_name = Fog::AWS::ELB::Mock.dns_name(lb_name, @region) self.data[:load_balancers][lb_name] = { 'AvailabilityZones' => availability_zones, 'Subnets' => [:subnet_ids] || [], 'Scheme' => [:scheme].nil? ? 'internet-facing' : [:scheme], 'SecurityGroups' => [:security_groups].nil? ? [] : [:security_groups], 'CanonicalHostedZoneName' => '', 'CanonicalHostedZoneNameID' => '', 'CreatedTime' => Time.now, 'DNSName' => dns_name, 'HealthCheck' => { 'HealthyThreshold' => 10, 'Timeout' => 5, 'UnhealthyThreshold' => 2, 'Interval' => 30, 'Target' => 'TCP:80' }, 'Instances' => [], 'ListenerDescriptions' => listeners, 'LoadBalancerName' => lb_name, 'Policies' => { 'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [], 'Proper' => [] }, 'SourceSecurityGroup' => { 'GroupName' => '', 'OwnerAlias' => '' } } response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'CreateLoadBalancerResult' => { 'DNSName' => dns_name } } response end |
#create_load_balancer_listeners(lb_name, listeners) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fog/aws/requests/elb/create_load_balancer_listeners.rb', line 55 def create_load_balancer_listeners(lb_name, listeners) if load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new certificate_ids = Fog::AWS::IAM::Mock.data[@aws_access_key_id][:server_certificates].map {|n, c| c['Arn'] } listeners.each do |listener| if listener['SSLCertificateId'] and !certificate_ids.include? listener['SSLCertificateId'] raise Fog::AWS::IAM::NotFound.new('CertificateNotFound') end if (%w( HTTP HTTPS).include?(listener['Protocol']) && !%w( HTTP HTTPS ).include?(listener['InstanceProtocol'])) || (%w( TCP SSL).include?(listener['Protocol']) && !%w( TCP SSL ).include?(listener['InstanceProtocol'])) raise Fog::AWS::ELB::ValidationError end if listener['Protocol'] && listener['InstanceProtocol'] load_balancer['ListenerDescriptions'] << {'Listener' => listener, 'PolicyNames' => []} end response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else raise Fog::AWS::ELB::NotFound end end |
#create_load_balancer_policy(lb_name, name, type_name, attributes = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/aws/requests/elb/create_load_balancer_policy.rb', line 47 def create_load_balancer_policy(lb_name, name, type_name, attributes = {}) if load_balancer = self.data[:load_balancers][lb_name] raise Fog::AWS::IAM::DuplicatePolicyName if policy = load_balancer['Policies']['Proper'].find { |p| p['PolicyName'] == name } raise Fog::AWS::IAM::PolicyTypeNotFound unless policy_type = self.data[:policy_types].find { |pt| pt['PolicyTypeName'] == type_name } response = Excon::Response.new attributes = attributes.map do |key, value| {"AttributeName" => key, "AttributeValue" => value.to_s} end load_balancer['Policies']['Proper'] << { 'PolicyAttributeDescriptions' => attributes, 'PolicyName' => name, 'PolicyTypeName' => type_name } response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else raise Fog::AWS::ELB::NotFound end end |
#data ⇒ Object
93 94 95 |
# File 'lib/fog/aws/elb.rb', line 93 def data self.class.data[@region][@aws_access_key_id] end |
#delete_load_balancer(lb_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fog/aws/requests/elb/delete_load_balancer.rb', line 33 def delete_load_balancer(lb_name) response = Excon::Response.new response.status = 200 self.data[:load_balancers].delete(lb_name) response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DeleteLoadBalancerResult' => nil } response end |
#delete_load_balancer_listeners(lb_name, load_balancer_ports) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/aws/requests/elb/delete_load_balancer_listeners.rb', line 31 def delete_load_balancer_listeners(lb_name, load_balancer_ports) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['ListenerDescriptions'].delete_if { |listener| load_balancer_ports.include? listener['Listener']['LoadBalancerPort'] } response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#delete_load_balancer_policy(lb_name, policy_name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/aws/requests/elb/delete_load_balancer_policy.rb', line 31 def delete_load_balancer_policy(lb_name, policy_name) if load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['Policies'].each do |name, policies| policies.delete_if { |policy| policy['PolicyName'] == policy_name } end response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else raise Fog::AWS::ELB::NotFound end end |
#deregister_instances_from_load_balancer(instance_ids, lb_name) ⇒ Object Also known as: deregister_instances
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb', line 36 def deregister_instances_from_load_balancer(instance_ids, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] instance_ids = [*instance_ids] instance_ids.each do |instance| raise Fog::AWS::ELB::InvalidInstance unless Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:instances][instance] end response = Excon::Response.new response.status = 200 load_balancer['Instances'].delete_if { |i| instance_ids.include? i['InstanceId'] } response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DeregisterInstancesFromLoadBalancerResult' => { 'Instances' => load_balancer['Instances'].dup } } response end |
#describe_instance_health(lb_name, instance_ids = []) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fog/aws/requests/elb/describe_instance_health.rb', line 37 def describe_instance_health(lb_name, instance_ids = []) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] instance_ids = [*instance_ids] instance_ids = load_balancer['Instances'].collect { |i| i['InstanceId'] } unless instance_ids.any? data = instance_ids.map do |id| unless Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:instances][id] raise Fog::AWS::ELB::InvalidInstance end { 'Description' => "", 'InstanceId' => id, 'ReasonCode' => "", 'State' => 'OutOfService' } end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DescribeInstanceHealthResult' => { 'InstanceStates' => data } } response end |
#describe_load_balancer_policies(lb_name = nil, names = []) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fog/aws/requests/elb/describe_load_balancer_policies.rb', line 38 def describe_load_balancer_policies(lb_name = nil, names = []) if lb_name raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] names = [*names] policies = if names.any? names.map do |name| raise Fog::AWS::ELB::PolicyNotFound unless policy = load_balancer['Policies']['Proper'].find { |p| p['PolicyName'] == name } policy.dup end.compact else load_balancer['Policies']['Proper'] end else policies = [] end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DescribeLoadBalancerPoliciesResult' => { 'PolicyDescriptions' => policies } } response end |
#describe_load_balancer_policy_types(type_names = []) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/aws/requests/elb/describe_load_balancer_policy_types.rb', line 39 def describe_load_balancer_policy_types(type_names = []) type_names = [*type_names] policy_types = if type_names.any? type_names.map do |type_name| policy_type = self.data[:policy_types].find { |pt| pt['PolicyTypeName'] == type_name } raise Fog::AWS::ELB::PolicyTypeNotFound unless policy_type policy_type[1].dup end.compact else self.data[:policy_types].map { |policy_type| policy_type.dup } end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DescribeLoadBalancerPolicyTypesResult' => { 'PolicyTypeDescriptions' => policy_types } } response end |
#describe_load_balancers(options = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/aws/requests/elb/describe_load_balancers.rb', line 67 def describe_load_balancers( = {}) unless .is_a?(Hash) Fog::Logger.deprecation("describe_load_balancers with #{.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]") = { 'LoadBalancerNames' => [].flatten } end lb_names = ['LoadBalancerNames'] || [] lb_names = [*lb_names] load_balancers = if lb_names.any? lb_names.map do |lb_name| lb = self.data[:load_balancers].find { |name, data| name == lb_name } raise Fog::AWS::ELB::NotFound unless lb lb[1].dup end.compact else self.data[:load_balancers].map { |lb, values| values.dup } end marker = .fetch('Marker', 0).to_i if load_balancers.count - marker > 400 next_marker = marker + 400 load_balancers = load_balancers[marker...next_marker] else next_marker = nil end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DescribeLoadBalancersResult' => { 'LoadBalancerDescriptions' => load_balancers.map do |lb| lb['Instances'] = lb['Instances'].map { |i| i['InstanceId'] } lb['Policies'] = lb['Policies'].reject { |name, policies| name == 'Proper' } lb end } } if next_marker response.body['DescribeLoadBalancersResult']['NextMarker'] = next_marker.to_s end response end |
#detach_load_balancer_from_subnets(subnet_ids, lb_name) ⇒ Object Also known as: disable_subnets
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/aws/requests/elb/detach_load_balancer_from_subnets.rb', line 36 def detach_load_balancer_from_subnets(subnet_ids, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['Subnets'] << subnet_ids load_balancer['Subnets'].flatten!.uniq! response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DetachLoadBalancerFromSubnetsResult' => { 'Subnets' => load_balancer['Subnets'] } } response end |
#disable_availability_zones_for_load_balancer(availability_zones, lb_name) ⇒ Object Also known as: disable_zones
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb', line 35 def disable_availability_zones_for_load_balancer(availability_zones, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['AvailabilityZones'].delete_if { |az| availability_zones.include? az } response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'DisableAvailabilityZonesForLoadBalancerResult' => { 'AvailabilityZones' => load_balancer['AvailabilityZones'] } } response end |
#enable_availability_zones_for_load_balancer(availability_zones, lb_name) ⇒ Object Also known as: enable_zones
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb', line 36 def enable_availability_zones_for_load_balancer(availability_zones, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] response = Excon::Response.new response.status = 200 load_balancer['AvailabilityZones'] << availability_zones load_balancer['AvailabilityZones'].flatten!.uniq! response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'EnableAvailabilityZonesForLoadBalancerResult' => { 'AvailabilityZones' => load_balancer['AvailabilityZones'] } } response end |
#register_instances_with_load_balancer(instance_ids, lb_name) ⇒ Object Also known as: register_instances
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb', line 36 def register_instances_with_load_balancer(instance_ids, lb_name) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] instance_ids = [*instance_ids] instances = instance_ids.map do |instance| raise Fog::AWS::ELB::InvalidInstance unless Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:instances][instance] {'InstanceId' => instance} end response = Excon::Response.new response.status = 200 load_balancer['Instances'] = load_balancer['Instances'] | instances.dup response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }, 'RegisterInstancesWithLoadBalancerResult' => { 'Instances' => instances } } response end |
#reset_data ⇒ Object
97 98 99 |
# File 'lib/fog/aws/elb.rb', line 97 def reset_data self.class.data[@region].delete(@aws_access_key_id) end |
#set_load_balancer_listener_ssl_certificate(lb_name, load_balancer_port, ssl_certificate_id) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fog/aws/requests/elb/set_load_balancer_listener_ssl_certificate.rb', line 37 def set_load_balancer_listener_ssl_certificate(lb_name, load_balancer_port, ssl_certificate_id) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] certificate_ids = Fog::AWS::IAM::Mock.data[@aws_access_key_id][:server_certificates].map {|n, c| c['Arn'] } if !certificate_ids.include? ssl_certificate_id raise Fog::AWS::IAM::NotFound.new('CertificateNotFound') end response = Excon::Response.new unless listener = load_balancer['ListenerDescriptions'].find { |listener| listener['Listener']['LoadBalancerPort'] == load_balancer_port } response.status = 400 response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>ListenerNotFound</Code><Message>LoadBalancer does not have a listnener configured at the given port.</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>" raise Excon::Errors.status_error({:expects => 200}, response) end listener['Listener']['SSLCertificateId'] = ssl_certificate_id response.status = 200 response.body = { "ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id } } response end |
#set_load_balancer_policies_of_listener(lb_name, load_balancer_port, policy_names) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fog/aws/requests/elb/set_load_balancer_policies_of_listener.rb', line 43 def set_load_balancer_policies_of_listener(lb_name, load_balancer_port, policy_names) raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name] policy_names = [*policy_names] response = Excon::Response.new if policy_names.size > 1 response.status = 409 response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>InvalidConfigurationRequest</Code><Message>Requested configuration change is invalid.</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>" raise Excon::Errors.status_error({:expects => 200}, response) end unless listener = load_balancer['ListenerDescriptions'].find { |listener| listener['Listener']['LoadBalancerPort'] == load_balancer_port } response.status = 400 response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>ListenerNotFound</Code><Message>LoadBalancer does not have a listnener configured at the given port.</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>" raise Excon::Errors.status_error({:expects => 200}, response) end unless load_balancer['Policies']['Proper'].find { |policy| policy['PolicyName'] == policy_names.first } response.status = 400 response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>PolicyNotFound</Code><Message>One or more specified policies were not found.</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>" raise Excon::Errors.status_error({:expects => 200}, response) end if policy_names.any? listener['PolicyNames'] = policy_names response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#setup_credentials(options) ⇒ Object
89 90 91 |
# File 'lib/fog/aws/elb.rb', line 89 def setup_credentials() @aws_access_key_id = [:aws_access_key_id] end |