In Files

Parent

Class/Module Index [+]

Quicksearch

Fog::AWS::RDS::Mock

Public Class Methods

data() click to toggle source
# File lib/fog/aws/rds.rb, line 73
def self.data
  @data ||= Hash.new do |hash, region|
    hash[region] = Hash.new do |region_hash, key|
      region_hash[key] = {
        :servers => {},
        :security_groups => {},
        :subnet_groups => {},
        :snapshots => {},
        :parameter_groups => {"default.mysql5.1" => { "DBParameterGroupFamily"=>"mysql5.1",
                                                      "Description"=>"Default parameter group for mysql5.1",
                                                      "DBParameterGroupName"=>"default.mysql5.1"
                                                    },
                              "default.mysql5.5" => {"DBParameterGroupFamily"=>"mysql5.5",
                                                    "Description"=>"Default parameter group for mysql5.5",
                                                    "DBParameterGroupName"=>"default.mysql5.5"
                                                    }
                              }
                         }
    end
  end
end
new(options={}) click to toggle source
# File lib/fog/aws/rds.rb, line 99
def initialize(options={})

  @use_iam_profile = options[:use_iam_profile]
  @region = options[:region] || 'us-east-1'

  unless ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
    raise ArgumentError, "Unknown region: #{@region.inspect}"
  end

end
reset() click to toggle source
# File lib/fog/aws/rds.rb, line 95
def self.reset
  @data = nil
end

Public Instance Methods

add_tags_to_resource(rds_id, tags) click to toggle source
# File lib/fog/aws/requests/rds/add_tags_to_resource.rb, line 29
def add_tags_to_resource(rds_id, tags)
  response = Excon::Response.new
  if server = self.data[:servers][rds_id]
    self.data[:tags][rds_id].merge! tags
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found")
  end
end
authorize_db_security_group_ingress(name, opts = {}) click to toggle source
# File lib/fog/aws/requests/rds/authorize_db_security_group_ingress.rb, line 35
def authorize_db_security_group_ingress(name, opts = {})
  unless opts.key?('CIDRIP') || (opts.key?('EC2SecurityGroupName') && opts.key?('EC2SecurityGroupOwnerId'))
    raise ArgumentError, 'Must specify CIDRIP, or both EC2SecurityGroupName and EC2SecurityGroupOwnerId'
  end
  
  response = Excon::Response.new
  
  if sec_group = self.data[:security_groups][name]
    if opts.key?('CIDRIP')
      if sec_group['IPRanges'].detect{|h| h['CIDRIP'] == opts['CIDRIP']}
        raise Fog::AWS::RDS::AuthorizationAlreadyExists.new("AuthorizationAlreadyExists => #{opts['CIDRIP']} is alreay defined")
      end
      sec_group['IPRanges'] << opts.merge({"Status" => 'authorizing'})
    else
      if sec_group['EC2SecurityGroups'].detect{|h| h['EC2SecurityGroupName'] == opts['EC2SecurityGroupName']}
        raise Fog::AWS::RDS::AuthorizationAlreadyExists.new("AuthorizationAlreadyExists => #{opts['EC2SecurityGroupName']} is alreay defined")
      end
      sec_group['EC2SecurityGroups'] << opts.merge({"Status" => 'authorizing'})
    end
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
      'AuthorizeDBSecurityGroupIngressResult' => {          
        'DBSecurityGroup' => sec_group
      }
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBSecurityGroupNotFound => #{name} not found")
  end
  
end
create_db_instance(db_name, options={}) click to toggle source
# File lib/fog/aws/requests/rds/create_db_instance.rb, line 50
        def create_db_instance(db_name, options={})
          response = Excon::Response.new
          if self.data[:servers] and self.data[:servers][db_name]
            # I don't know how to raise an exception that contains the excon data
            #response.status = 400
            #response.body = {
            #  'Code' => 'DBInstanceAlreadyExists',
            #  'Message' => "DB Instance already exists"
            #}
            #return response
            raise Fog::AWS::RDS::IdentifierTaken.new("DBInstanceAlreadyExists #{response.body.to_s}")
          end

          # These are the required parameters according to the API
          required_params = %{AllocatedStorage DBInstanceClass Engine MasterUserPassword MasterUsername }
          required_params.each do |key|
            unless options.has_key?(key) and options[key] and !options[key].to_s.empty?
              #response.status = 400
              #response.body = {
              #  'Code' => 'MissingParameter',
              #  'Message' => "The request must contain the parameter #{key}"
              #}
              #return response
              raise Fog::AWS::RDS::NotFound.new("The request must contain the parameter #{key}")
            end
          end

          data =
              {
                 "DBInstanceIdentifier"=> db_name,
                 "DBName" => options["DBName"],
                 "InstanceCreateTime" => nil,
                 "AutoMinorVersionUpgrade"=>true,
                 "Endpoint"=>{},
                 "ReadReplicaDBInstanceIdentifiers"=>[],
                 "PreferredMaintenanceWindow"=>"mon:04:30-mon:05:00",
                 "Engine"=> options["Engine"],
                 "EngineVersion"=> options["EngineVersion"] || "5.5.12",
                 "PendingModifiedValues"=>{"MasterUserPassword"=>"****"}, # This clears when is available
                 "MultiAZ"=> !!options['MultiAZ'],
                 "MasterUsername"=> options["MasterUsername"],
                 "DBInstanceClass"=> options["DBInstanceClass"],
                 "DBInstanceStatus"=>"creating",
                 "BackupRetentionPeriod"=> options["BackupRetentionPeriod"] || 1,
                 "AllocatedStorage"=> options["AllocatedStorage"],
                 "DBParameterGroups"=> # I think groups should be in the self.data method
                          [{"DBParameterGroupName"=>"default.mysql5.5",
                            "ParameterApplyStatus"=>"in-sync"}],
                 "DBSecurityGroups"=>
                          [{"Status"=>"active", 
                            "DBSecurityGroupName"=>"default"}],
                 "LicenseModel"=>"general-public-license",
                 "PreferredBackupWindow"=>"08:00-08:30",
#                 "ReadReplicaSourceDBInstanceIdentifier" => nil,
#                 "LatestRestorableTime" => nil,
                 "AvailabilityZone" => options["AvailabilityZone"],
                 "DBSubnetGroupName" => options["DBSubnetGroupName"]
             }


          self.data[:servers][db_name] = data
          response.body = {
            "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
            "CreateDBInstanceResult"=> {"DBInstance"=> data}
          }
          response.status = 200
          # This values aren't showed at creating time but at available time
          self.data[:servers][db_name]["InstanceCreateTime"] = Time.now
          self.data[:tags] ||= {}
          self.data[:tags][db_name] = {}
          response
        end
create_db_instance_read_replica(instance_identifier, source_identifier, options={}) click to toggle source
# File lib/fog/aws/requests/rds/create_db_instance_read_replica.rb, line 35
def create_db_instance_read_replica(instance_identifier, source_identifier, options={})
  # TODO: throw error when instance_identifier already exists,
  # or source_identifier doesn't exist

  source = self.data[:servers][source_identifier]
  data = {
    'AllocatedStorage' => source['AllocatedStorage'],
    'AutoMinorVersionUpgrade' => options.key?('AutoMinorVersionUpgrade') ? options['AutoMinorVersionUpgrade'] : true,
    'AvailabilityZone' => options['AvailabilityZone'],
    'DBInstanceClass' => options['DBInstanceClass'] || 'db.m1.small',
    'DBInstanceIdentifier' => instance_identifier,
    'DBInstanceStatus' => 'creating',
    'DBName' => source['DBName'],
    'DBParameterGroups' => source['DBParameterGroups'],
    'DBSecurityGroups' => source['DBSecurityGroups'],
    'Endpoint' => {},
    'Engine' => source['Engine'],
    'EngineVersion' => options['EngineVersion'] || '5.5.12',
    'InstanceCreateTime' => nil,
    'LatestRestorableTime' => nil,
    'LicenseModel' => 'general-public-license',
    'MasterUsername' => source['MasterUsername'],
    'MultiAZ' => false,
    'PendingModifiedValues' => {},
    'PreferredBackupWindow'=> '08:00-08:30',
    'PreferredMaintenanceWindow'=> "mon:04:30-mon:05:00",
    'ReadReplicaDBInstanceIdentifiers'=> [],
    'ReadReplicaSourceDBInstanceIdentifier'=> source_identifier
  }
  self.data[:servers][instance_identifier] = data
  self.data[:servers][source_identifier]['ReadReplicaDBInstanceIdentifiers'] << instance_identifier

  response = Excon::Response.new
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "CreateDBInstanceReadReplicaResult"=> {"DBInstance"=> data}
  }
  response.status = 200
  # This values aren't showed at creating time but at available time
  self.data[:servers][instance_identifier]["InstanceCreateTime"] = Time.now

  response
end
create_db_parameter_group(group_name, group_family, description) click to toggle source
# File lib/fog/aws/requests/rds/create_db_parameter_group.rb, line 34
def create_db_parameter_group(group_name, group_family, description)
  response = Excon::Response.new
  if self.data[:parameter_groups] and self.data[:parameter_groups][group_name]
    raise Fog::AWS::RDS::IdentifierTaken.new("Parameter group #{group_name} already exists")
  end
  
  data = {
    'DBParameterGroupName' => group_name,
    'DBParameterGroupFamily' => group_family.downcase,
    'Description' => description
  }
  self.data[:parameter_groups][group_name] = data
  
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "CreateDBParameterGroupResult"=> {"DBParameterGroup"=> data}
  }
  response.status = 200
  response
  
end
create_db_security_group(name, description = name) click to toggle source
# File lib/fog/aws/requests/rds/create_db_security_group.rb, line 29
def create_db_security_group(name, description = name)
  response = Excon::Response.new
  if self.data[:security_groups] and self.data[:security_groups][name]
    raise Fog::AWS::RDS::IdentifierTaken.new("DBInstanceAlreadyExists => The security group '#{name}' already exists")
  end
  
  data = {
    'DBSecurityGroupName' => name,
    'DBSecurityGroupDescription' => description,
    'EC2SecurityGroups' => [],
    'IPRanges' => [],
    'OwnerId' => '0123456789'
  }
  self.data[:security_groups][name] = data
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    'CreateDBSecurityGroupResult' => { 'DBSecurityGroup' => data }
  }
  response
  
end
create_db_snapshot(identifier, name) click to toggle source
# File lib/fog/aws/requests/rds/create_db_snapshot.rb, line 29
def create_db_snapshot(identifier, name)
  response = Excon::Response.new
  if data[:snapshots][name]
    raise Fog::AWS::RDS::IndentifierTaken.new
  end

  server_data = data[:servers][identifier]
  unless server_data
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found")
  end

  # TODO: raise an error if the server isn't in 'available' state

  snapshot_data = {
    'Status'               => 'creating',
    'SnapshotType'         => 'manual', 
    'DBInstanceIdentifier' => identifier,
    'DBSnapshotIdentifier' => name,
    'InstanceCreateTime'   => Time.now
  }
  # Copy attributes from server
  %(Engine EngineVersion AvailabilityZone AllocatedStorage MasterUsername InstanceCreateTime).each do |key|
    snapshot_data[key] = server_data[key]
  end
  snapshot_data['Port'] = server_data['Endpoint']['Port']

  self.data[:snapshots][name] = snapshot_data

  # TODO: put the server in 'modifying' state

  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "CreateDBSnapshotResult"=> {"DBSnapshot"=> snapshot_data.dup}
  }
  response.status = 200
  # SnapshotCreateTime is not part of the response.
  self.data[:snapshots][name]['SnapshotCreateTime'] = Time.now
  response

end
create_db_subnet_group(name, subnet_ids, description = name) click to toggle source
# File lib/fog/aws/requests/rds/create_db_subnet_group.rb, line 30
def create_db_subnet_group(name, subnet_ids, description = name)
  response = Excon::Response.new
  if self.data[:subnet_groups] && self.data[:subnet_groups][name]
    raise Fog::AWS::RDS::IdentifierTaken.new("DBSubnetGroupAlreadyExists => The subnet group '#{name}' already exists")
  end

  subnets = subnet_ids.map { |snid| Fog::Compute[:aws].subnets.get(snid) }
  vpc_id = subnets.first.vpc_id

  data = {
    'DBSubnetGroupName' => name,
    'DBSubnetGroupDescription' => description,
    'SubnetGroupStatus' => 'Complete',
    'Subnets' => subnet_ids,
    'VpcId' => vpc_id
  }
  self.data[:subnet_groups][name] = data
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    'CreateDBSubnetGroupResult' => { 'DBSubnetGroup' => data }
  }
  response

end
data() click to toggle source
# File lib/fog/aws/rds.rb, line 110
def data
  self.class.data[@region][@aws_access_key_id]
end
delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false) click to toggle source
# File lib/fog/aws/requests/rds/delete_db_instance.rb, line 33
def delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false)
  response = Excon::Response.new
  
  unless skip_snapshot
    create_db_snapshot(identifier, snapshot_identifier)
  end
  
  if server_set = self.data[:servers].delete(identifier)
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
      "DeleteDBInstanceResult" => { "DBInstance" => server_set }
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found")
  end
end
delete_db_parameter_group(group_name) click to toggle source
# File lib/fog/aws/requests/rds/delete_db_parameter_group.rb, line 29
def delete_db_parameter_group(group_name)
  response = Excon::Response.new
  
  if self.data[:parameter_groups].delete(group_name)
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBParameterGroup not found: #{group_name}")
  end
end
delete_db_security_group(name, description = name) click to toggle source
# File lib/fog/aws/requests/rds/delete_db_security_group.rb, line 27
def delete_db_security_group(name, description = name)
  response = Excon::Response.new
  
  if self.data[:security_groups].delete(name)
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBSecurityGroupNotFound => #{name} not found")
  end
end
delete_db_snapshot(name) click to toggle source
# File lib/fog/aws/requests/rds/delete_db_snapshot.rb, line 29
def delete_db_snapshot(name)
  # TODO: raise error if snapshot isn't 'available'
  response = Excon::Response.new
  snapshot_data = self.data[:snapshots].delete(name)

  raise Fog::AWS::RDS::NotFound.new("DBSnapshtoNotFound => #{name} not found") unless snapshot_data

  response.status = 200
  response.body = {
    "ResponseMetadata"=> { "RequestId"=> Fog::AWS::Mock.request_id },
    "DeleteDBSnapshotResult"=> {"DBSnapshot"=> snapshot_data}
  }
  response
end
describe_db_engine_versions(opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_engine_versions.rb, line 27
def describe_db_engine_versions(opts={})
  Fog::Mock.not_implemented
end
describe_db_instances(identifier=nil, opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_instances.rb, line 35
def describe_db_instances(identifier=nil, opts={})
  response = Excon::Response.new
  server_set = []
  if identifier
    if server = self.data[:servers][identifier]
      server_set << server
    else
      raise Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found")
    end
  else
    server_set = self.data[:servers].values
  end

  server_set.each do |server|
     case server["DBInstanceStatus"]
     when "creating"
       if Time.now - server['InstanceCreateTime'] >= Fog::Mock.delay * 2
         region = "us-east-1"
         server["DBInstanceStatus"] = "available"
         server["AvailabilityZone"] ||= region + 'a'
         server["Endpoint"] = {"Port"=>3306,
                               "Address"=> Fog::AWS::Mock.rds_address(server["DBInstanceIdentifier"],region) }
         server["PendingModifiedValues"] = {}
       end
      when "rebooting"
        if Time.now - self.data[:reboot_time] >= Fog::Mock.delay
          # apply pending modified values
          server.merge!(server["PendingModifiedValues"])
          server["PendingModifiedValues"] = {}

          server["DBInstanceStatus"] = 'available'
          self.data.delete(:reboot_time)
        end
      when "modifying"
        # TODO there are some fields that only applied after rebooting
        if Time.now - self.data[:modify_time] >= Fog::Mock.delay
          server.merge!(server["PendingModifiedValues"])
          server["PendingModifiedValues"] = {}
          server["DBInstanceStatus"] = 'available'
        end
      when "available" # I'm not sure if amazon does this
        unless server["PendingModifiedValues"].empty?
          server["DBInstanceStatus"] = 'modifying'
        end
     end
  end

  response.status = 200
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "DescribeDBInstancesResult" => { "DBInstances" => server_set }
  }
  response
end
describe_db_parameter_groups(name=nil, opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_parameter_groups.rb, line 38
def describe_db_parameter_groups(name=nil, opts={})
  response = Excon::Response.new
  parameter_set = []
  if name
    if server = self.data[:parameter_groups][name]
      parameter_set << server
    else
      raise Fog::AWS::RDS::NotFound.new("DBInstance #{name} not found")
    end
  else
    parameter_set = self.data[:parameter_groups].values
  end
  

  response.status = 200
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "DescribeDBParameterGroupsResult" => { "DBParameterGroups" => parameter_set }
  }
  response
end
describe_db_parameters(name, opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_parameters.rb, line 39
def describe_db_parameters(name, opts={})
  Fog::Mock.not_implemented
end
describe_db_reserved_instances(identifier=nil, opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_reserved_instances.rb, line 35
def describe_db_reserved_instances(identifier=nil, opts={})
  Fog::Mock.not_implemented
end
describe_db_security_groups(opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_security_groups.rb, line 31
def describe_db_security_groups(opts={})
  response = Excon::Response.new
  sec_group_set = []
  if opts.is_a?(String)
    sec_group_name = opts
    if sec_group = self.data[:security_groups][sec_group_name]
      sec_group_set << sec_group
    else
      raise Fog::AWS::RDS::NotFound.new("Security Group #{sec_group_name} not found")
    end
  else
    sec_group_set = self.data[:security_groups].values
  end

  # TODO: refactor to not delete items that we're iterating over. Causes
  # model tests to fail (currently pending)
  sec_group_set.each do |sec_group|
    sec_group["IPRanges"].each do |iprange|
      if iprange["Status"] == "authorizing" || iprange["Status"] == "revoking"
        iprange[:tmp] ||= Time.now + Fog::Mock.delay * 2
        if iprange[:tmp] <= Time.now
          iprange["Status"] = "authorized" if iprange["Status"] == "authorizing"
          iprange.delete(:tmp)
          sec_group["IPRanges"].delete(iprange) if iprange["Status"] == "revoking"
        end
      end
    end

    # TODO: refactor to not delete items that we're iterating over. Causes
    # model tests to fail (currently pending)
    sec_group["EC2SecurityGroups"].each do |ec2_secg|
      if ec2_secg["Status"] == "authorizing" || ec2_secg["Status"] == "revoking"
        ec2_secg[:tmp] ||= Time.now + Fog::Mock.delay * 2
        if ec2_secg[:tmp] <= Time.now
          ec2_secg["Status"] = "authorized" if ec2_secg["Status"] == "authorizing"
          ec2_secg.delete(:tmp)
          sec_group["EC2SecurityGroups"].delete(ec2_secg) if ec2_secg["Status"] == "revoking"
        end
      end
    end
  end

  response.status = 200
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "DescribeDBSecurityGroupsResult" => { "DBSecurityGroups" => sec_group_set }
  }
  response
end
describe_db_snapshots(opts={}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_snapshots.rb, line 37
def describe_db_snapshots(opts={})
  response = Excon::Response.new
  snapshots = self.data[:snapshots].values
  if opts[:identifier]
    snapshots = snapshots.select{|snapshot| snapshot['DBInstanceIdentifier'] == opts[:identifier]}
  end

  if opts[:snapshot_id]
    snapshots = snapshots.select{|snapshot| snapshot['DBSnapshotIdentifier'] == opts[:snapshot_id]}
    raise Fog::AWS::RDS::NotFound.new("DBSnapshot #{opts[:snapshot_id]} not found") if snapshots.empty?
  end

  snapshots.each do |snapshot|
    case snapshot['Status']
    when 'creating'
      if Time.now - snapshot['SnapshotCreateTime'] > Fog::Mock.delay
        snapshot['Status'] = 'available'
      end
    end
  end

  # Build response
  response.status = 200
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "DescribeDBSnapshotsResult" => { "DBSnapshots" => snapshots }
  }
  response

end
describe_db_subnet_groups(name = nil, opts = {}) click to toggle source
# File lib/fog/aws/requests/rds/describe_db_subnet_groups.rb, line 38
def describe_db_subnet_groups(name = nil, opts = {})
  response = Excon::Response.new

  subnet_group_set = []
  if name
    if subnet_group = self.data[:subnet_groups][name]
      subnet_group_set << subnet_group
    else
      raise Fog::AWS::RDS::NotFound.new("Subnet Group #{name} not found")
    end
  else
    subnet_group_set = self.data[:subnet_groups].values
  end

  response.status = 200
  response.body = {
    "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
    "DescribeDBSubnetGroupsResult" => { "DBSubnetGroups" => subnet_group_set }
  }
  response
end
describe_events() click to toggle source
# File lib/fog/aws/requests/rds/describe_events.rb, line 46
def describe_events
  Fog::Mock.not_implemented
end
list_tags_for_resource(rds_id) click to toggle source
# File lib/fog/aws/requests/rds/list_tags_for_resource.rb, line 27
def list_tags_for_resource(rds_id)
  response = Excon::Response.new
  if server = self.data[:servers][rds_id]
    response.status = 200
    response.body = {
      "ListTagsForResourceResult" =>
        {"TagList" =>  self.data[:tags][rds_id]}
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found")
  end
end
modify_db_instance(db_name, apply_immediately, options={}) click to toggle source
# File lib/fog/aws/requests/rds/modify_db_instance.rb, line 47
def modify_db_instance(db_name, apply_immediately, options={})
  response = Excon::Response.new
  if self.data[:servers][db_name]
    if self.data[:servers][db_name]["DBInstanceStatus"] != "available"
      raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
    else
      self.data[:modify_time] = Time.now
      # TODO verify the params options
      # if apply_immediately is false, all the options go to pending_modified_values and then apply and clear after either
      # a reboot or the maintainance window
      #if apply_immediately
      #  modified_server = server.merge(options)
      #else
      #  modified_server = server["PendingModifiedValues"].merge!(options) # it appends
      #end
      self.data[:servers][db_name]["PendingModifiedValues"].merge!(options) # it appends
      self.data[:servers][db_name]["DBInstanceStatus"] = "modifying"
      response.status = 200
      response.body = {
        "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
        "ModifyDBInstanceResult" => { "DBInstance" => self.data[:servers][db_name] }
      }
      response

    end
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not found")
  end
end
modify_db_parameter_group(group_name, parameters) click to toggle source
# File lib/fog/aws/requests/rds/modify_db_parameter_group.rb, line 48
def modify_db_parameter_group(group_name, parameters)
  Fog::Mock.not_implemented
end
reboot_db_instance(instance_identifier) click to toggle source
# File lib/fog/aws/requests/rds/reboot_db_instance.rb, line 27
def reboot_db_instance(instance_identifier)
  response = Excon::Response.new
  if server = self.data[:servers][instance_identifier]
    if server["DBInstanceStatus"] != "available"
      raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not available for rebooting")
    else
      server["DBInstanceStatus"] = 'rebooting'
      self.data[:reboot_time] = Time.now
      response.status = 200
      response.body = {
        "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
        "RebootDBInstanceResult" => { "DBInstance" => server }
      }
      response

    end
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not found")
  end
end
remove_tags_from_resource(rds_id, keys) click to toggle source
# File lib/fog/aws/requests/rds/remove_tags_from_resource.rb, line 27
def remove_tags_from_resource(rds_id, keys)
  response = Excon::Response.new
  if server = self.data[:servers][rds_id]
    keys.each {|key| self.data[:tags][rds_id].delete key}
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found")
  end
end
reset_data() click to toggle source
# File lib/fog/aws/rds.rb, line 114
def reset_data
  self.class.data[@region].delete(@aws_access_key_id)
end
restore_db_instance_from_db_snapshot(snapshot_id, db_id, options={}) click to toggle source
# File lib/fog/aws/requests/rds/restore_db_instance_from_db_snapshot.rb, line 26
def restore_db_instance_from_db_snapshot(snapshot_id, db_id, options={})
  Fog::Mock.not_implemented
end
restore_db_instance_to_point_in_time(source_db_name, target_db_name, opts={}) click to toggle source
# File lib/fog/aws/requests/rds/restore_db_instance_to_point_in_time.rb, line 26
def restore_db_instance_to_point_in_time(source_db_name, target_db_name, opts={})
  Fog::Mock.not_implemented
end
revoke_db_security_group_ingress(name, opts = {}) click to toggle source
# File lib/fog/aws/requests/rds/revoke_db_security_group_ingress.rb, line 35
def revoke_db_security_group_ingress(name, opts = {})
  unless opts.key?('CIDRIP') || (opts.key?('EC2SecurityGroupName') && opts.key?('EC2SecurityGroupOwnerId'))
    raise ArgumentError, 'Must specify CIDRIP, or both EC2SecurityGroupName and EC2SecurityGroupOwnerId'
  end
  
  response = Excon::Response.new
  
  if sec_group = self.data[:security_groups][name]
    if opts.key?('CIDRIP')
      sec_group['IPRanges'].each do |iprange|
        iprange['Status']= 'revoking' if iprange['CIDRIP'] == opts['CIDRIP']
      end
    else
      sec_group['EC2SecurityGroups'].each do |ec2_secg|
        ec2_secg['Status']= 'revoking' if ec2_secg['EC2SecurityGroupName'] == opts['EC2SecurityGroupName']
      end
    end
    response.status = 200
    response.body = {
      "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
      'RevokeDBSecurityGroupIngressResult' => {          
        'DBSecurityGroup' => sec_group
      }
    }
    response
  else
    raise Fog::AWS::RDS::NotFound.new("DBSecurityGroupNotFound => #{name} not found")
  end
end
setup_credentials(options) click to toggle source
# File lib/fog/aws/rds.rb, line 118
def setup_credentials(options)
  @aws_access_key_id = options[:aws_access_key_id]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.