Skip to content

Commit

Permalink
Add database restore primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
Jc2k committed Mar 29, 2015
1 parent 332a873 commit 7699a0b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog for Touchdown
0.0.9 (unreleased)
------------------

- Nothing changed yet.
- rds: Add point in time restore and snashot restore.


0.0.8 (2015-03-26)
Expand Down
6 changes: 5 additions & 1 deletion touchdown/aws/rds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

from .subnet_group import SubnetGroup
from .database import Database
from .point_in_time_restore import PointInTimeRestore
from .snapshot_restore import SnapshotRestore


__all__ = [
'SubnetGroup',
'Database'
'Database',
'PointInTimeRestore',
'SnapshotRestore',
]
49 changes: 49 additions & 0 deletions touchdown/aws/rds/point_in_time_restore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2015 Isotoma Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from touchdown.core.resource import Resource
from touchdown.core.plan import Plan
from touchdown.core import argument

from ..account import Account
from ..common import SimpleDescribe, SimpleApply

from .database import Database


class PointInTimeRestore(Resource):

resource_name = "point_in_time_restore"

name = argument.String(field="SourceDBInstanceIdentifier")
from_database = argument.Resource(Database, field="TargetDBInstanceIdentifier")
restore_time = argument.String(field="RestoreTime")

account = argument.Resource(Account)


class Describe(SimpleDescribe, Plan):

resource = PointInTimeRestore
service_name = 'rds'
describe_action = "describe_db_instances"
describe_notfound_exception = "DBInstanceNotFound"
describe_envelope = "DBInstances"
key = 'DBInstanceIdentifier'


class Apply(SimpleApply, Describe):

create_action = "restore_db_instance_to_point_in_time"
waiter = "db_instance_available"
46 changes: 46 additions & 0 deletions touchdown/aws/rds/snapshot_restore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2015 Isotoma Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from touchdown.core.resource import Resource
from touchdown.core.plan import Plan
from touchdown.core import argument

from ..account import Account
from ..common import SimpleDescribe, SimpleApply


class SnapshotRestore(Resource):

resource_name = "snapshot_restore"

name = argument.String(field="DBInstanceIdentifier")
snapshot = argument.String(field="DBSnapshotIdentifier")

account = argument.Resource(Account)


class Describe(SimpleDescribe, Plan):

resource = SnapshotRestore
service_name = 'rds'
describe_action = "describe_db_instances"
describe_notfound_exception = "DBInstanceNotFound"
describe_envelope = "DBInstances"
key = 'DBInstanceIdentifier'


class Apply(SimpleApply, Describe):

create_action = "restore_db_instance_from_db_snapshot"
waiter = "db_instance_available"

0 comments on commit 7699a0b

Please sign in to comment.