Repository: libcloud Updated Branches: refs/heads/trunk 329bbc499 -> 94c6b9143
Initial structure for supporting backup driver type Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/99edca71 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/99edca71 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/99edca71 Branch: refs/heads/trunk Commit: 99edca71dbd83c64b0221e21ed2fe549e498600b Parents: ee6f984 Author: Anthony Shaw <anthony.p.s...@gmail.com> Authored: Mon Nov 9 09:38:09 2015 +1100 Committer: Anthony Shaw <anthony.p.s...@gmail.com> Committed: Mon Nov 9 09:38:09 2015 +1100 ---------------------------------------------------------------------- libcloud/backup/__init__.py | 0 libcloud/backup/base.py | 56 ++++++++++++++++++++++++++++++++ libcloud/backup/drivers/__init__.py | 0 libcloud/backup/drivers/dummy.py | 41 +++++++++++++++++++++++ libcloud/backup/providers.py | 31 ++++++++++++++++++ libcloud/backup/types.py | 22 +++++++++++++ libcloud/test/backup/__init__.py | 0 libcloud/test/backup/test_base.py | 29 +++++++++++++++++ setup.py | 5 +-- 9 files changed, 182 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/backup/__init__.py ---------------------------------------------------------------------- diff --git a/libcloud/backup/__init__.py b/libcloud/backup/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/backup/base.py ---------------------------------------------------------------------- diff --git a/libcloud/backup/base.py b/libcloud/backup/base.py new file mode 100644 index 0000000..0c4723a --- /dev/null +++ b/libcloud/backup/base.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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 libcloud.common.base import ConnectionUserAndKey, BaseDriver + +__all__ = [ + 'BackupDriver' +] + + +class BackupDriver(BaseDriver): + """ + A base BackupDriver class to derive from + + This class is always subclassed by a specific driver. + """ + connectionCls = ConnectionUserAndKey + name = None + website = None + + def __init__(self, key, secret=None, secure=True, host=None, port=None, + **kwargs): + """ + :param key: API key or username to used (required) + :type key: ``str`` + + :param secret: Secret password to be used (required) + :type secret: ``str`` + + :param secure: Whether to use HTTPS or HTTP. Note: Some providers + only support HTTPS, and it is on by default. + :type secure: ``bool`` + + :param host: Override hostname used for connections. + :type host: ``str`` + + :param port: Override port used for connections. + :type port: ``int`` + + :return: ``None`` + """ + super(BackupDriver, self).__init__(key=key, secret=secret, + secure=secure, host=host, port=port, + **kwargs) http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/backup/drivers/__init__.py ---------------------------------------------------------------------- diff --git a/libcloud/backup/drivers/__init__.py b/libcloud/backup/drivers/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/backup/drivers/dummy.py ---------------------------------------------------------------------- diff --git a/libcloud/backup/drivers/dummy.py b/libcloud/backup/drivers/dummy.py new file mode 100644 index 0000000..2b28d66 --- /dev/null +++ b/libcloud/backup/drivers/dummy.py @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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 libcloud.backup.base import BackupDriver + + +class DummyBackupDriver(BackupDriver): + """ + Dummy Backup driver. + + >>> from libcloud.backup.drivers.dummy import DummyBackupDriver + >>> driver = DummyBackupDriver('key', 'secret') + >>> driver.name + 'Dummy Backup Provider' + """ + + name = 'Dummy Backup Provider' + website = 'http://example.com' + + def __init__(self, api_key, api_secret): + """ + :param api_key: API key or username to used (required) + :type api_key: ``str`` + + :param api_secret: Secret password to be used (required) + :type api_secret: ``str`` + + :rtype: ``None`` + """ http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/backup/providers.py ---------------------------------------------------------------------- diff --git a/libcloud/backup/providers.py b/libcloud/backup/providers.py new file mode 100644 index 0000000..21bafda --- /dev/null +++ b/libcloud/backup/providers.py @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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 libcloud.utils.misc import get_driver as get_provider_driver +from libcloud.utils.misc import set_driver as set_provider_driver +from libcloud.backup.types import Provider + +DRIVERS = { + Provider.DUMMY: + ('libcloud.backup.drivers.dummy', 'DummyBackupDriver'), +} + + +def get_driver(provider): + return get_provider_driver(DRIVERS, provider) + + +def set_driver(provider, module, klass): + return set_provider_driver(DRIVERS, provider, module, klass) http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/backup/types.py ---------------------------------------------------------------------- diff --git a/libcloud/backup/types.py b/libcloud/backup/types.py new file mode 100644 index 0000000..5930832 --- /dev/null +++ b/libcloud/backup/types.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +__all__ = [ + 'Provider', +] + + +class Provider(object): + DUMMY = 'dummy' http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/test/backup/__init__.py ---------------------------------------------------------------------- diff --git a/libcloud/test/backup/__init__.py b/libcloud/test/backup/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/libcloud/test/backup/test_base.py ---------------------------------------------------------------------- diff --git a/libcloud/test/backup/test_base.py b/libcloud/test/backup/test_base.py new file mode 100644 index 0000000..e254e6d --- /dev/null +++ b/libcloud/test/backup/test_base.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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 + +from __future__ import with_statement + +import sys + +from libcloud.test import unittest +from libcloud.backup.base import BackupDriver + + +class BaseTestCase(unittest.TestCase): + def setUp(self): + self.driver = BackupDriver('none', 'none') + + +if __name__ == '__main__': + sys.exit(unittest.main()) http://git-wip-us.apache.org/repos/asf/libcloud/blob/99edca71/setup.py ---------------------------------------------------------------------- diff --git a/setup.py b/setup.py index 9a29e3b..94253ad 100644 --- a/setup.py +++ b/setup.py @@ -48,10 +48,11 @@ HTML_VIEWSOURCE_BASE = 'https://svn.apache.org/viewvc/libcloud/trunk' PROJECT_BASE_DIR = 'http://libcloud.apache.org' TEST_PATHS = ['libcloud/test', 'libcloud/test/common', 'libcloud/test/compute', 'libcloud/test/storage', 'libcloud/test/loadbalancer', - 'libcloud/test/dns'] + 'libcloud/test/dns', 'libcloud/test/backup'] DOC_TEST_MODULES = ['libcloud.compute.drivers.dummy', 'libcloud.storage.drivers.dummy', - 'libcloud.dns.drivers.dummy'] + 'libcloud.dns.drivers.dummy', + 'libcloud.backup.drivers.dummy'] SUPPORTED_VERSIONS = ['2.5', '2.6', '2.7', 'PyPy', '3.x']