From 2f684da0aa64cfa67c18c84b98555bdeab524be4 Mon Sep 17 00:00:00 2001 From: Pino de Candia <32303022+pinodeca@users.noreply.github.com> Date: Thu, 25 Jan 2018 02:42:29 -0600 Subject: [PATCH] Initial and incomplete conversion from designate to tatu. --- bin/designate | 2 +- designateclient/cli/base.py | 139 ---- designateclient/cli/diagnostics.py | 38 - designateclient/cli/domains.py | 144 ---- designateclient/cli/quotas.py | 83 -- designateclient/cli/records.py | 187 ----- designateclient/cli/reports.py | 71 -- designateclient/cli/servers.py | 98 --- designateclient/cli/sync.py | 63 -- designateclient/cli/touch.py | 37 - .../resources/schemas/v1/domain.json | 76 -- .../resources/schemas/v1/record.json | 246 ------ .../resources/schemas/v1/server.json | 44 -- designateclient/tests/test_v1/__init__.py | 53 -- designateclient/tests/test_v1/test_client.py | 124 --- .../tests/test_v1/test_diagnostics.py | 30 - designateclient/tests/test_v1/test_domain.py | 184 ----- designateclient/tests/test_v1/test_quotas.py | 48 -- designateclient/tests/test_v1/test_records.py | 222 ------ designateclient/tests/test_v1/test_reports.py | 54 -- designateclient/tests/test_v1/test_servers.py | 95 --- designateclient/tests/test_v1/test_sync.py | 42 - designateclient/tests/test_v1/test_touch.py | 29 - designateclient/v1/__init__.py | 161 ---- designateclient/v1/diagnostics.py | 27 - designateclient/v1/domains.py | 92 --- designateclient/v1/quotas.py | 38 - designateclient/v1/records.py | 115 --- designateclient/v1/reports.py | 67 -- designateclient/v1/servers.py | 81 -- designateclient/v1/sync.py | 37 - designateclient/v1/touch.py | 24 - designateclient/v2/blacklists.py | 48 -- designateclient/v2/cli/__init__.py | 0 designateclient/v2/cli/blacklists.py | 155 ---- designateclient/v2/cli/quotas.py | 133 ---- designateclient/v2/cli/reverse.py | 142 ---- designateclient/v2/cli/service_statuses.py | 94 --- designateclient/v2/cli/tlds.py | 154 ---- designateclient/v2/cli/tsigkeys.py | 170 ----- designateclient/v2/cli/zones.py | 716 ------------------ designateclient/v2/limits.py | 21 - designateclient/v2/nameservers.py | 26 - designateclient/v2/pools.py | 22 - designateclient/v2/quotas.py | 27 - designateclient/v2/reverse.py | 49 -- designateclient/v2/service_statuses.py | 28 - designateclient/v2/tlds.py | 49 -- designateclient/v2/tsigkeys.py | 50 -- designateclient/v2/zones.py | 168 ---- doc/examples/recordset_create.py | 6 +- doc/examples/recordset_crud.py | 6 +- doc/examples/zone_create_primary.py | 6 +- doc/examples/zone_create_secondary.py | 6 +- doc/examples/zone_list_nameservers.py | 6 +- doc/examples/zone_list_paging.py | 4 +- doc/source/conf.py | 12 +- ...oject => python-tatuclient.sublime-project | 0 releasenotes/source/conf.py | 4 +- setup.cfg | 163 +--- {designateclient => tatuclient}/__init__.py | 2 +- {designateclient => tatuclient}/client.py | 4 +- {designateclient => tatuclient}/exceptions.py | 0 .../functionaltests/__init__.py | 0 .../functionaltests/base.py | 4 +- .../functionaltests/client.py | 6 +- .../functionaltests/config.py | 4 +- .../functionaltests/datagen.py | 0 .../functionaltests/models.py | 0 .../functionaltests/v2}/__init__.py | 0 .../functionaltests/v2/fixtures.py | 2 +- .../functionaltests/v2/test_blacklist.py | 6 +- .../functionaltests/v2/test_recordsets.py | 10 +- .../functionaltests/v2/test_tlds.py | 6 +- .../functionaltests/v2/test_tsigkeys.py | 12 +- .../functionaltests/v2/test_zone.py | 6 +- .../functionaltests/v2/test_zone_export.py | 8 +- .../functionaltests/v2/test_zone_import.py | 6 +- .../functionaltests/v2/test_zone_transfer.py | 10 +- .../v2 => tatuclient/osc}/__init__.py | 0 {designateclient => tatuclient}/osc/plugin.py | 20 +- {designateclient => tatuclient}/shell.py | 6 +- .../osc => tatuclient/tests}/__init__.py | 0 {designateclient => tatuclient}/tests/base.py | 4 +- .../tests/test_designateclient.py | 8 +- .../tests/test_exceptions.py | 4 +- .../tests/test_utils.py | 6 +- .../tests/v2/__init__.py | 2 +- .../tests/v2/test_blacklists.py | 2 +- .../tests/v2/test_client.py | 4 +- .../tests/v2/test_limits.py | 2 +- .../tests/v2/test_nameservers.py | 4 +- .../tests/v2/test_recordsets.py | 6 +- .../tests/v2/test_reverse.py | 2 +- .../tests/v2/test_service_statuses.py | 2 +- .../tests/v2/test_timeout.py | 4 +- .../tests/v2/test_tlds.py | 2 +- .../tests/v2/test_tsigkeys.py | 2 +- .../tests/v2/test_zones.py | 2 +- {designateclient => tatuclient}/utils.py | 4 +- .../tests => tatuclient/v2}/__init__.py | 0 {designateclient => tatuclient}/v2/base.py | 4 +- .../v2/recordsets.py => tatuclient/v2/ca.py | 4 +- .../v2 => tatuclient/v2/cli}/__init__.py | 0 .../recordsets.py => tatuclient/v2/cli/ca.py | 6 +- .../v2/cli/common.py | 0 tatuclient/v2/cli/hostcert.py | 260 +++++++ tatuclient/v2/cli/usercert.py | 260 +++++++ {designateclient => tatuclient}/v2/client.py | 57 +- tatuclient/v2/hostcert.py | 106 +++ tatuclient/v2/usercert.py | 106 +++ {designateclient => tatuclient}/v2/utils.py | 2 +- {designateclient => tatuclient}/version.py | 2 +- {designateclient => tatuclient}/warlock.py | 0 114 files changed, 899 insertions(+), 5096 deletions(-) delete mode 100644 designateclient/cli/base.py delete mode 100644 designateclient/cli/diagnostics.py delete mode 100644 designateclient/cli/domains.py delete mode 100644 designateclient/cli/quotas.py delete mode 100644 designateclient/cli/records.py delete mode 100644 designateclient/cli/reports.py delete mode 100644 designateclient/cli/servers.py delete mode 100644 designateclient/cli/sync.py delete mode 100644 designateclient/cli/touch.py delete mode 100644 designateclient/resources/schemas/v1/domain.json delete mode 100644 designateclient/resources/schemas/v1/record.json delete mode 100644 designateclient/resources/schemas/v1/server.json delete mode 100644 designateclient/tests/test_v1/__init__.py delete mode 100644 designateclient/tests/test_v1/test_client.py delete mode 100644 designateclient/tests/test_v1/test_diagnostics.py delete mode 100644 designateclient/tests/test_v1/test_domain.py delete mode 100644 designateclient/tests/test_v1/test_quotas.py delete mode 100644 designateclient/tests/test_v1/test_records.py delete mode 100644 designateclient/tests/test_v1/test_reports.py delete mode 100644 designateclient/tests/test_v1/test_servers.py delete mode 100644 designateclient/tests/test_v1/test_sync.py delete mode 100644 designateclient/tests/test_v1/test_touch.py delete mode 100644 designateclient/v1/__init__.py delete mode 100644 designateclient/v1/diagnostics.py delete mode 100644 designateclient/v1/domains.py delete mode 100644 designateclient/v1/quotas.py delete mode 100644 designateclient/v1/records.py delete mode 100644 designateclient/v1/reports.py delete mode 100644 designateclient/v1/servers.py delete mode 100644 designateclient/v1/sync.py delete mode 100644 designateclient/v1/touch.py delete mode 100644 designateclient/v2/blacklists.py delete mode 100644 designateclient/v2/cli/__init__.py delete mode 100644 designateclient/v2/cli/blacklists.py delete mode 100644 designateclient/v2/cli/quotas.py delete mode 100644 designateclient/v2/cli/reverse.py delete mode 100644 designateclient/v2/cli/service_statuses.py delete mode 100644 designateclient/v2/cli/tlds.py delete mode 100644 designateclient/v2/cli/tsigkeys.py delete mode 100644 designateclient/v2/cli/zones.py delete mode 100644 designateclient/v2/limits.py delete mode 100644 designateclient/v2/nameservers.py delete mode 100644 designateclient/v2/pools.py delete mode 100644 designateclient/v2/quotas.py delete mode 100644 designateclient/v2/reverse.py delete mode 100644 designateclient/v2/service_statuses.py delete mode 100644 designateclient/v2/tlds.py delete mode 100644 designateclient/v2/tsigkeys.py delete mode 100644 designateclient/v2/zones.py rename python-designateclient.sublime-project => python-tatuclient.sublime-project (100%) rename {designateclient => tatuclient}/__init__.py (94%) rename {designateclient => tatuclient}/client.py (97%) rename {designateclient => tatuclient}/exceptions.py (100%) rename {designateclient => tatuclient}/functionaltests/__init__.py (100%) rename {designateclient => tatuclient}/functionaltests/base.py (93%) rename {designateclient => tatuclient}/functionaltests/client.py (98%) rename {designateclient => tatuclient}/functionaltests/config.py (95%) rename {designateclient => tatuclient}/functionaltests/datagen.py (100%) rename {designateclient => tatuclient}/functionaltests/models.py (100%) rename {designateclient/cli => tatuclient/functionaltests/v2}/__init__.py (100%) rename {designateclient => tatuclient}/functionaltests/v2/fixtures.py (99%) rename {designateclient => tatuclient}/functionaltests/v2/test_blacklist.py (94%) rename {designateclient => tatuclient}/functionaltests/v2/test_recordsets.py (91%) rename {designateclient => tatuclient}/functionaltests/v2/test_tlds.py (93%) rename {designateclient => tatuclient}/functionaltests/v2/test_tsigkeys.py (88%) rename {designateclient => tatuclient}/functionaltests/v2/test_zone.py (95%) rename {designateclient => tatuclient}/functionaltests/v2/test_zone_export.py (90%) rename {designateclient => tatuclient}/functionaltests/v2/test_zone_import.py (91%) rename {designateclient => tatuclient}/functionaltests/v2/test_zone_transfer.py (92%) rename {designateclient/functionaltests/v2 => tatuclient/osc}/__init__.py (100%) rename {designateclient => tatuclient}/osc/plugin.py (75%) rename {designateclient => tatuclient}/shell.py (98%) rename {designateclient/osc => tatuclient/tests}/__init__.py (100%) rename {designateclient => tatuclient}/tests/base.py (98%) rename {designateclient => tatuclient}/tests/test_designateclient.py (80%) rename {designateclient => tatuclient}/tests/test_exceptions.py (96%) rename {designateclient => tatuclient}/tests/test_utils.py (96%) rename {designateclient => tatuclient}/tests/v2/__init__.py (97%) rename {designateclient => tatuclient}/tests/v2/test_blacklists.py (98%) rename {designateclient => tatuclient}/tests/v2/test_client.py (94%) rename {designateclient => tatuclient}/tests/v2/test_limits.py (96%) rename {designateclient => tatuclient}/tests/v2/test_nameservers.py (94%) rename {designateclient => tatuclient}/tests/v2/test_recordsets.py (98%) rename {designateclient => tatuclient}/tests/v2/test_reverse.py (97%) rename {designateclient => tatuclient}/tests/v2/test_service_statuses.py (97%) rename {designateclient => tatuclient}/tests/v2/test_timeout.py (97%) rename {designateclient => tatuclient}/tests/v2/test_tlds.py (98%) rename {designateclient => tatuclient}/tests/v2/test_tsigkeys.py (98%) rename {designateclient => tatuclient}/tests/v2/test_zones.py (99%) rename {designateclient => tatuclient}/utils.py (98%) rename {designateclient/tests => tatuclient/v2}/__init__.py (100%) rename {designateclient => tatuclient}/v2/base.py (93%) rename designateclient/v2/recordsets.py => tatuclient/v2/ca.py (97%) rename {designateclient/v2 => tatuclient/v2/cli}/__init__.py (100%) rename designateclient/v2/cli/recordsets.py => tatuclient/v2/cli/ca.py (98%) rename {designateclient => tatuclient}/v2/cli/common.py (100%) create mode 100644 tatuclient/v2/cli/hostcert.py create mode 100644 tatuclient/v2/cli/usercert.py rename {designateclient => tatuclient}/v2/client.py (62%) create mode 100644 tatuclient/v2/hostcert.py create mode 100644 tatuclient/v2/usercert.py rename {designateclient => tatuclient}/v2/utils.py (98%) rename {designateclient => tatuclient}/version.py (90%) rename {designateclient => tatuclient}/warlock.py (100%) diff --git a/bin/designate b/bin/designate index 510ff8f..ae4e7fb 100755 --- a/bin/designate +++ b/bin/designate @@ -15,7 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. import sys -from designateclient.shell import DesignateShell +from tatuclient.shell import DesignateShell shell = DesignateShell() sys.exit(shell.run(sys.argv[1:])) diff --git a/designateclient/cli/base.py b/designateclient/cli/base.py deleted file mode 100644 index 6cfb4bc..0000000 --- a/designateclient/cli/base.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. -import abc -import warnings - -from keystoneauth1 import exceptions as ks_exceptions -from osc_lib.command import command -import six - -from designateclient import exceptions -from designateclient import utils -from designateclient.v1 import Client - - -@six.add_metaclass(abc.ABCMeta) -class Command(command.Command): - def run(self, parsed_args): - - warnings.simplefilter('once', category=DeprecationWarning) - warnings.warn( - 'The "designate" CLI is being deprecated in favour of the ' - '"openstack" CLI plugin. All designate API v2 commands are ' - 'implemented there. When the v1 API is removed this CLI will ' - 'stop functioning', - DeprecationWarning) - warnings.resetwarnings() - warnings.simplefilter('ignore', category=DeprecationWarning) - - self.client = Client( - region_name=self.app.options.os_region_name, - service_type=self.app.options.os_service_type, - endpoint_type=self.app.options.os_endpoint_type, - session=self.app.session, - all_tenants=self.app.options.all_tenants, - edit_managed=self.app.options.edit_managed, - endpoint=self.app.options.os_endpoint) - warnings.resetwarnings() - try: - return super(Command, self).run(parsed_args) - except exceptions.RemoteError as e: - columns = ['Code', 'Type'] - values = [e.code, e.type] - - if e.message: - columns.append('Message') - values.append(e.message) - - if e.errors: - columns.append('Errors') - values.append(e.errors) - - self.error_output(parsed_args, columns, values) - except ks_exceptions.EndpointNotFound as e: - self.app.log.error('No endpoint was found. You must provide a ' - 'username or user id via --os-username, ' - '--os-user-id, env[OS_USERNAME] or ' - 'env[OS_USER_ID]') - - return 1 - - def error_output(self, parsed_args, column_names, data): - self.formatter.emit_one(column_names, - data, - self.app.stdout, - parsed_args) - self.app.log.error('The requested action did not complete ' - 'successfully') - - @abc.abstractmethod - def execute(self, parsed_args): - """ - Execute something, this is since we overload self.take_action() - in order to format the data - - This method __NEEDS__ to be overloaded! - - :param parsed_args: The parsed args that are given by take_action() - """ - - def post_execute(self, data): - """ - Format the results locally if needed, by default we just return data - - :param data: Whatever is returned by self.execute() - """ - return data - - def take_action(self, parsed_args): - results = self.execute(parsed_args) - return self.post_execute(results) - - def find_resourceid_by_name_or_id(self, resource_plural, name_or_id): - resource_client = getattr(self.client, resource_plural) - return utils.find_resourceid_by_name_or_id(resource_client, name_or_id) - - -class ListCommand(Command, command.Lister): - columns = None - - def post_execute(self, results): - if len(results) > 0: - columns = self.columns or utils.get_columns(results) - data = [utils.get_item_properties(i, columns) for i in results] - return columns, data - else: - return [], () - - -class GetCommand(Command, command.ShowOne): - def post_execute(self, results): - return list(six.iterkeys(results)), list(six.itervalues(results)) - - -class CreateCommand(Command, command.ShowOne): - def post_execute(self, results): - return list(six.iterkeys(results)), list(six.itervalues(results)) - - -class UpdateCommand(Command, command.ShowOne): - def post_execute(self, results): - return list(six.iterkeys(results)), list(six.itervalues(results)) - - -class DeleteCommand(Command, command.ShowOne): - def post_execute(self, results): - return [], [] diff --git a/designateclient/cli/diagnostics.py b/designateclient/cli/diagnostics.py deleted file mode 100644 index e621616..0000000 --- a/designateclient/cli/diagnostics.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import logging - -from designateclient.cli import base - -LOG = logging.getLogger(__name__) - - -class PingCommand(base.GetCommand): - """Ping a service on a given host""" - - def get_parser(self, prog_name): - parser = super(PingCommand, self).get_parser(prog_name) - - parser.add_argument('--service', help="Service name (e.g. central)", - required=True) - parser.add_argument('--host', help="Hostname", required=True) - - return parser - - def execute(self, parsed_args): - return self.client.diagnostics.ping(parsed_args.service, - parsed_args.host) diff --git a/designateclient/cli/domains.py b/designateclient/cli/domains.py deleted file mode 100644 index 25ccd31..0000000 --- a/designateclient/cli/domains.py +++ /dev/null @@ -1,144 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import logging - -from designateclient.cli import base -from designateclient.v1.domains import Domain - -LOG = logging.getLogger(__name__) - - -class ListDomainsCommand(base.ListCommand): - """List Domains""" - - columns = ['id', 'name', 'serial'] - - def execute(self, parsed_args): - return self.client.domains.list() - - -class GetDomainCommand(base.GetCommand): - """Get Domain""" - - def get_parser(self, prog_name): - parser = super(GetDomainCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Domain ID or name.") - - return parser - - def execute(self, parsed_args): - id = self.find_resourceid_by_name_or_id('domains', parsed_args.id) - return self.client.domains.get(id) - - -class CreateDomainCommand(base.CreateCommand): - """Create Domain""" - - def get_parser(self, prog_name): - parser = super(CreateDomainCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="Domain name.", required=True) - parser.add_argument('--email', help="Domain email.", required=True) - parser.add_argument('--ttl', type=int, help="Time to live (seconds).") - parser.add_argument('--description', help="Description.") - - return parser - - def execute(self, parsed_args): - domain = Domain( - name=parsed_args.name, - email=parsed_args.email, - ) - - if parsed_args.description: - domain.description = parsed_args.description - - if parsed_args.ttl is not None: - domain.ttl = parsed_args.ttl - - return self.client.domains.create(domain) - - -class UpdateDomainCommand(base.UpdateCommand): - """Update Domain""" - - def get_parser(self, prog_name): - parser = super(UpdateDomainCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Domain ID or name.") - parser.add_argument('--name', help="Domain name.") - parser.add_argument('--email', help="Domain email.") - parser.add_argument('--ttl', type=int, help="Time to live (seconds).") - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description.") - description_group.add_argument('--no-description', action='store_true') - - return parser - - def execute(self, parsed_args): - # TODO(kiall): API needs updating.. this get is silly - id = self.find_resourceid_by_name_or_id('domains', parsed_args.id) - domain = self.client.domains.get(id) - - if parsed_args.name: - domain.name = parsed_args.name - - if parsed_args.email: - domain.email = parsed_args.email - - if parsed_args.ttl is not None: - domain.ttl = parsed_args.ttl - - if parsed_args.no_description: - domain.description = None - elif parsed_args.description: - domain.description = parsed_args.description - - return self.client.domains.update(domain) - - -class DeleteDomainCommand(base.DeleteCommand): - """Delete Domain""" - - def get_parser(self, prog_name): - parser = super(DeleteDomainCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Domain ID or name.") - - return parser - - def execute(self, parsed_args): - id = self.find_resourceid_by_name_or_id('domains', parsed_args.id) - return self.client.domains.delete(id) - - -class ListDomainServersCommand(base.ListCommand): - """List Domain Servers""" - - columns = ['name'] - - def get_parser(self, prog_name): - parser = super(ListDomainServersCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Domain ID or name.") - - return parser - - def execute(self, parsed_args): - id = self.find_resourceid_by_name_or_id('domains', parsed_args.id) - return self.client.domains.list_domain_servers(id) diff --git a/designateclient/cli/quotas.py b/designateclient/cli/quotas.py deleted file mode 100644 index ae41690..0000000 --- a/designateclient/cli/quotas.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. - -import logging - -from designateclient.cli import base - - -LOG = logging.getLogger(__name__) - - -class GetQuotaCommand(base.GetCommand): - """Get Quota""" - - def get_parser(self, prog_name): - parser = super(GetQuotaCommand, self).get_parser(prog_name) - - parser.add_argument('tenant_id', help="Tenant ID") - - return parser - - def execute(self, parsed_args): - return self.client.quotas.get(parsed_args.tenant_id) - - -class UpdateQuotaCommand(base.UpdateCommand): - """Update Quota""" - - def get_parser(self, prog_name): - parser = super(UpdateQuotaCommand, self).get_parser(prog_name) - - parser.add_argument('tenant_id', help="Tenant ID.") - parser.add_argument('--domains', help="Allowed domains.", type=int) - parser.add_argument('--domain-recordsets', - help="Allowed domain records.", - type=int) - parser.add_argument('--recordset-records', - help="Allowed recordset records.", - type=int) - parser.add_argument('--domain-records', - help="Allowed domain records.", - type=int) - parser.add_argument('--api-export-size', - help="Allowed zone export recordsets.", - type=int) - return parser - - def execute(self, parsed_args): - # TODO(kiall): API needs updating.. this get is silly - quota = self.client.quotas.get(parsed_args.tenant_id) - - for key, old in quota.items(): - new = getattr(parsed_args, key) - if new is not None and new != old: - quota[key] = new - return self.client.quotas.update(parsed_args.tenant_id, quota) - - -class ResetQuotaCommand(base.DeleteCommand): - """Reset Quota""" - - def get_parser(self, prog_name): - parser = super(ResetQuotaCommand, self).get_parser(prog_name) - - parser.add_argument('tenant_id', help="Tenant ID.") - - return parser - - def execute(self, parsed_args): - self.client.quotas.reset(parsed_args.tenant_id) diff --git a/designateclient/cli/records.py b/designateclient/cli/records.py deleted file mode 100644 index 6e276ca..0000000 --- a/designateclient/cli/records.py +++ /dev/null @@ -1,187 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import logging - -from designateclient.cli import base -from designateclient.v1.records import Record - -LOG = logging.getLogger(__name__) - - -class ListRecordsCommand(base.ListCommand): - """List Records""" - - columns = ['id', 'type', 'name', 'data'] - - def get_parser(self, prog_name): - parser = super(ListRecordsCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID or name.") - - return parser - - def execute(self, parsed_args): - domain_id = self.find_resourceid_by_name_or_id( - 'domains', parsed_args.domain_id) - return self.client.records.list(domain_id) - - -class GetRecordCommand(base.GetCommand): - """Get Record""" - - def get_parser(self, prog_name): - parser = super(GetRecordCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID or name.") - parser.add_argument('id', help="Record ID.") - - return parser - - def execute(self, parsed_args): - domain_id = self.find_resourceid_by_name_or_id( - 'domains', parsed_args.domain_id) - return self.client.records.get(domain_id, parsed_args.id) - - -class CreateRecordCommand(base.CreateCommand): - """Create Record""" - - def get_parser(self, prog_name): - parser = super(CreateRecordCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID or name.") - parser.add_argument( - '--name', help="Record (relative|absolute) name.", required=True) - parser.add_argument('--type', help="Record type.", required=True) - parser.add_argument('--data', help="Record data.", required=True) - parser.add_argument('--ttl', type=int, help="Record TTL.") - parser.add_argument('--priority', type=int, help="Record priority.") - parser.add_argument('--description', help="Description.") - - return parser - - def execute(self, parsed_args): - domain_id = self.find_resourceid_by_name_or_id( - 'domains', parsed_args.domain_id) - - if not parsed_args.name.endswith('.'): - # Relative name? - domain_name = self.client.domains.get(domain_id)['name'] - absolute = parsed_args.name + '.' - relative = absolute + domain_name - if absolute.endswith('.' + domain_name): - # Relative name or absolute name missing final period? - msg = ('"%s" is a relative name but looks like an absolute ' - 'name, use --name "%s" or "%s"' - % (parsed_args.name, absolute, relative)) - raise ValueError(msg) - parsed_args.name = relative - - record = Record( - name=parsed_args.name, - type=parsed_args.type, - data=parsed_args.data, - ) - - if parsed_args.ttl is not None: - record.ttl = parsed_args.ttl - - if parsed_args.priority is not None: - record.priority = parsed_args.priority - - if parsed_args.description: - record.description = parsed_args.description - - return self.client.records.create(domain_id, record) - - -class UpdateRecordCommand(base.UpdateCommand): - """Update Record""" - - def get_parser(self, prog_name): - parser = super(UpdateRecordCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID or name.") - parser.add_argument('id', help="Record ID.") - parser.add_argument('--name', help="Record name.") - parser.add_argument('--type', help="Record type.") - parser.add_argument('--data', help="Record data.") - - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description.") - description_group.add_argument('--no-description', action='store_true') - - ttl_group = parser.add_mutually_exclusive_group() - ttl_group.add_argument('--ttl', type=int, - help="Record time to live (seconds).") - ttl_group.add_argument('--no-ttl', action='store_true') - - priotity_group = parser.add_mutually_exclusive_group() - priotity_group.add_argument('--priority', type=int, - help="Record priority.") - priotity_group.add_argument('--no-priority', action='store_true') - - return parser - - def execute(self, parsed_args): - # TODO(kiall): API needs updating.. this get is silly - record = self.client.records.get(parsed_args.domain_id, parsed_args.id) - - if parsed_args.name: - record.name = parsed_args.name - - if parsed_args.type: - record.type = parsed_args.type - - if parsed_args.data: - record.data = parsed_args.data - - if parsed_args.no_ttl: - record.ttl = None - elif parsed_args.ttl is not None: - record.ttl = parsed_args.ttl - - if parsed_args.no_priority: - record.priority = None - elif parsed_args.priority is not None: - record.priority = parsed_args.priority - - if parsed_args.no_description: - record.description = None - elif parsed_args.description: - record.description = parsed_args.description - - domain_id = self.find_resourceid_by_name_or_id( - 'domains', parsed_args.domain_id) - return self.client.records.update(domain_id, record) - - -class DeleteRecordCommand(base.DeleteCommand): - """Delete Record""" - - def get_parser(self, prog_name): - parser = super(DeleteRecordCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID or name.") - parser.add_argument('id', help="Record ID.") - - return parser - - def execute(self, parsed_args): - domain_id = self.find_resourceid_by_name_or_id( - 'domains', parsed_args.domain_id) - return self.client.records.delete(domain_id, parsed_args.id) diff --git a/designateclient/cli/reports.py b/designateclient/cli/reports.py deleted file mode 100644 index 6ecfc2e..0000000 --- a/designateclient/cli/reports.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2013 Hewlett-Packard Development Company, L.P. All Rights Reserved. -# -# Author: Patrick Galbraith -# -# 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 designateclient.cli import base - - -class DomainCountCommand(base.GetCommand): - """Get counts for total domains""" - - def execute(self, parsed_args): - return self.client.reports.count_domains() - - -class RecordCountCommand(base.GetCommand): - """Get counts for total records""" - - def execute(self, parsed_args): - return self.client.reports.count_records() - - -class TenantCountCommand(base.GetCommand): - """Get counts for total tenants""" - - def execute(self, parsed_args): - return self.client.reports.count_tenants() - - -class CountsCommand(base.GetCommand): - """Get count totals for all tenants, domains and records""" - - def execute(self, parsed_args): - return self.client.reports.count_all() - - -class TenantsCommand(base.ListCommand): - """Get list of tenants and domain count for each""" - - columns = ['domain_count', 'id'] - - def execute(self, parsed_args): - return self.client.reports.tenants_all() - - -class TenantCommand(base.ListCommand): - """Get a list of domains for given tenant""" - - columns = ['domain'] - - def get_parser(self, prog_name): - parser = super(TenantCommand, self).get_parser(prog_name) - - parser.add_argument('--report-tenant-id', - help="The tenant_id being reported on.", - required=True) - - return parser - - def execute(self, parsed_args): - return self.client.reports.tenant_domains(parsed_args.report_tenant_id) diff --git a/designateclient/cli/servers.py b/designateclient/cli/servers.py deleted file mode 100644 index 184271b..0000000 --- a/designateclient/cli/servers.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import logging - -from designateclient.cli import base -from designateclient.v1.servers import Server - -LOG = logging.getLogger(__name__) - - -class ListServersCommand(base.ListCommand): - """List Servers""" - - columns = ['id', 'name'] - - def execute(self, parsed_args): - return self.client.servers.list() - - -class GetServerCommand(base.GetCommand): - """Get Server""" - - def get_parser(self, prog_name): - parser = super(GetServerCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Server ID.") - - return parser - - def execute(self, parsed_args): - return self.client.servers.get(parsed_args.id) - - -class CreateServerCommand(base.CreateCommand): - """Create Server""" - - def get_parser(self, prog_name): - parser = super(CreateServerCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="Server name.", required=True) - - return parser - - def execute(self, parsed_args): - server = Server( - name=parsed_args.name, - ) - - return self.client.servers.create(server) - - -class UpdateServerCommand(base.UpdateCommand): - """Update Server""" - - def get_parser(self, prog_name): - parser = super(UpdateServerCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Server ID.") - parser.add_argument('--name', help="Server name.") - - return parser - - def execute(self, parsed_args): - # TODO(kiall): API needs updating.. this get is silly - server = self.client.servers.get(parsed_args.id) - - if parsed_args.name: - server.name = parsed_args.name - - return self.client.servers.update(server) - - -class DeleteServerCommand(base.DeleteCommand): - """Delete Server""" - - def get_parser(self, prog_name): - parser = super(DeleteServerCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Server ID.") - - return parser - - def execute(self, parsed_args): - return self.client.servers.delete(parsed_args.id) diff --git a/designateclient/cli/sync.py b/designateclient/cli/sync.py deleted file mode 100644 index 18e2852..0000000 --- a/designateclient/cli/sync.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. -import logging - -from designateclient.cli import base - -LOG = logging.getLogger(__name__) - - -class SyncAllCommand(base.DeleteCommand): - """Sync Everything""" - - def execute(self, parsed_args): - self.client.sync.sync_all() - - LOG.info('Synchronization of all domains scheduled') - - -class SyncDomainCommand(base.DeleteCommand): - """Sync a single Domain""" - - def get_parser(self, prog_name): - parser = super(SyncDomainCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID") - - return parser - - def execute(self, parsed_args): - self.client.sync.sync_domain(parsed_args.domain_id) - - LOG.info('Synchronization of domain scheduled') - - -class SyncRecordCommand(base.DeleteCommand): - """Sync a single Record""" - - def get_parser(self, prog_name): - parser = super(SyncRecordCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID") - parser.add_argument('record_id', help="Record ID") - - return parser - - def execute(self, parsed_args): - self.client.sync.sync_record(parsed_args.domain_id, - parsed_args.record_id) - - LOG.info('Synchronization of record scheduled') diff --git a/designateclient/cli/touch.py b/designateclient/cli/touch.py deleted file mode 100644 index a9713f0..0000000 --- a/designateclient/cli/touch.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import logging - -from designateclient.cli import base - -LOG = logging.getLogger(__name__) - - -class TouchDomainCommand(base.DeleteCommand): - """Touch a single Domain""" - - def get_parser(self, prog_name): - parser = super(TouchDomainCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID") - - return parser - - def execute(self, parsed_args): - self.client.touch.domain(parsed_args.domain_id) - - LOG.info('Domain touched successfully') diff --git a/designateclient/resources/schemas/v1/domain.json b/designateclient/resources/schemas/v1/domain.json deleted file mode 100644 index 5ed584f..0000000 --- a/designateclient/resources/schemas/v1/domain.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "id": "domain", - - "$schema": "http://json-schema.org/draft-03/hyper-schema", - - "title": "domain", - "description": "Domain", - "additionalProperties": false, - - "properties": { - "id": { - "type": "string", - "description": "Domain Identifier", - "pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", - "readonly": true - }, - "name": { - "type": "string", - "description": "Domain name", - "format": "domain-name", - "maxLength": 255, - "required": true, - "readonly": true - }, - "email": { - "type": "string", - "description": "Hostmaster email address", - "format": "email", - "maxLength": 255, - "required": true - }, - "ttl": { - "type": "integer", - "description": "Time to live", - "minimum": 1, - "maximum": 2147483647 - }, - "serial": { - "type": "integer", - "description": "Serial Number", - "minimum": 1, - "maximum": 4294967295, - "readonly": true - }, - "description": { - "type": ["string", "null"], - "description": "Description for the Domain", - "maxLength": 160 - }, - "created_at": { - "type": "string", - "description": "Date and time of domain creation", - "format": "date-time", - "readonly": true - }, - "updated_at": { - "type": ["string", "null"], - "description": "Date and time of last domain update", - "format": "date-time", - "readonly": true - } - }, - "links": [{ - "rel": "self", - "href": "/domains/{id}" - }, { - "rel": "records", - "href": "/domains/{id}/records" - }, { - "rel": "servers", - "href": "/domains/{id}/servers" - }, { - "rel": "collection", - "href": "/domains" - }] -} diff --git a/designateclient/resources/schemas/v1/record.json b/designateclient/resources/schemas/v1/record.json deleted file mode 100644 index cecc9fd..0000000 --- a/designateclient/resources/schemas/v1/record.json +++ /dev/null @@ -1,246 +0,0 @@ -{ - "id": "record", - - "$schema": "http://json-schema.org/draft-03/hyper-schema", - - "title": "record", - "description": "Record", - "additionalProperties": false, - - "properties": { - "id": { - "type": "string", - "description": "Record Identifier", - "pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", - "readonly": true - }, - "domain_id": { - "type": "string", - "description": "Domain Identifier", - "pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", - "readonly": true - }, - "name": { - "type": "string", - "description": "DNS Record Name", - "format": "host-name", - "maxLength": 255, - "required": true - }, - "type": { - "type": "string", - "description": "DNS Record Type", - "enum": ["A", "AAAA", "CNAME", "MX", "SRV", "TXT", "SPF", "NS", "PTR", "SSHFP", "SOA"], - "required": true - }, - "data": { - "type": "string", - "description": "DNS Record Value", - "maxLength": 255, - "required": true - }, - "priority": { - "type": ["integer", "null"], - "description": "DNS Record Priority", - "minimum": 0, - "maximum": 65535 - }, - "ttl": { - "type": ["integer", "null"], - "description": "Time to live", - "minimum": 1, - "maximum": 2147483647 - }, - "description": { - "type": ["string", "null"], - "description": "Description for the record", - "maxLength": 160 - }, - "created_at": { - "type": "string", - "description": "Date and time of record creation", - "format": "date-time", - "readonly": true - }, - "updated_at": { - "type": ["string", "null"], - "description": "Date and time of last record update", - "format": "date-time", - "readonly": true - } - }, - "oneOf": [{ - "description": "An A Record", - "properties": { - "type": { - "type": "string", - "enum": ["A"] - }, - "data": { - "format": "ip-address", - "required": true - }, - "priority": { - "type": "null" - } - } - }, { - "description": "An AAAA Record", - "properties": { - "type": { - "type": "string", - "enum": ["AAAA"] - }, - "data": { - "format": "ipv6", - "required": true - }, - "priority": { - "type": "null" - } - } - }, { - "description": "A CNAME Record", - "properties": { - "type": { - "type": "string", - "enum": ["CNAME"] - }, - "data": { - "format": "host-name", - "required": true - }, - "priority": { - "type": "null" - } - } - }, { - "description": "A MX Record", - "properties": { - "type": { - "type": "string", - "enum": ["MX"] - }, - "data": { - "format": "host-name", - "required": true - }, - "priority": { - "type": "integer", - "required": true - } - } - }, { - "description": "A SRV Record", - "properties": { - "type": { - "type": "string", - "enum": ["SRV"] - }, - "name": { - "type": "string", - "pattern": "^(?:_[A-Za-z0-9_\\-]{1,62}\\.){2}" - }, - "data": { - "type": "string", - "pattern": "^(?:(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])\\s){2}(?!.{255,})((?!\\-)[A-Za-z0-9_\\-]{1,63}(? -# -# 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. -import uuid - -from designateclient.tests import base - - -class CrudMixin(object): - path_prefix = None - - def new_ref(self, **kwargs): - kwargs.setdefault('id', uuid.uuid4().hex) - return kwargs - - def stub_entity(self, method, parts=None, entity=None, id=None, **kwargs): - if entity: - kwargs['json'] = entity - - if not parts: - parts = [self.RESOURCE] - - if self.path_prefix: - parts.insert(0, self.path_prefix) - - if id: - if not parts: - parts = [] - - parts.append(id) - - self.stub_url(method, parts=parts, **kwargs) - - def assertList(self, expected, actual): - self.assertEqual(len(expected), len(actual)) - for i in expected: - self.assertIn(i, actual) - - -class APIV1TestCase(base.APITestCase): - VERSION = "1" diff --git a/designateclient/tests/test_v1/test_client.py b/designateclient/tests/test_v1/test_client.py deleted file mode 100644 index f46f64d..0000000 --- a/designateclient/tests/test_v1/test_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Kiall Mac Innes -# -# 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 designateclient.tests import test_v1 -from designateclient import utils -from designateclient import v1 - -from keystoneauth1 import session as keystone_session - - -class TestClient(test_v1.APIV1TestCase): - def test_all_tenants(self): - # Create a client with the all_tenants flag set to True - client = v1.Client(all_tenants=True) - - # Verify this has been picked up - self.assertTrue(client.all_tenants) - - def test_all_tenants_not_supplied(self): - # Create a client without supplying any all_tenants flag - client = v1.Client() - - # Verify all_tenants is False - self.assertFalse(client.all_tenants) - self.assertIsNotNone(client.all_tenants) - - def test_all_tenants_through_session(self): - # Create a session with the all_tenants flag set to True - session = utils.get_session( - auth_url='Anything', - endpoint='Anything', - domain_id='Anything', - domain_name='Anything', - project_id='Anything', - project_name='Anything', - project_domain_name='Anything', - project_domain_id='Anything', - username='Anything', - user_id='Anything', - password='Anything', - user_domain_id='Anything', - user_domain_name='Anything', - token=None, - insecure=False, - cacert=None, - all_tenants=True) - - # Create a client using the pre-created session - client = v1.Client(session=session) - - # Verify the all_tenants flag has been picked up - self.assertTrue(client.all_tenants) - - def test_edit_managed(self): - # Create a client with the edit_managed flag set to True - client = v1.Client(edit_managed=True) - - # Verify this has been picked up - self.assertTrue(client.edit_managed) - - def test_edit_managed_not_supplied(self): - # Create a client without supplying any edit_managed flag - client = v1.Client() - - # Verify edit_managed is False - self.assertFalse(client.edit_managed) - self.assertIsNotNone(client.edit_managed) - - def test_edit_managed_through_session(self): - # Create a session with the edit_managed flag set to True - session = utils.get_session( - auth_url='Anything', - endpoint='Anything', - domain_id='Anything', - domain_name='Anything', - project_id='Anything', - project_name='Anything', - project_domain_name='Anything', - project_domain_id='Anything', - username='Anything', - user_id='Anything', - password='Anything', - user_domain_id='Anything', - user_domain_name='Anything', - token=None, - insecure=False, - cacert=None, - edit_managed=True) - - # Create a client using the pre-created session - client = v1.Client(session=session) - - # Verify the edit_managed flag has been picked up - self.assertTrue(client.edit_managed) - - def test_timeout_new_session(self): - client = v1.Client( - auth_url="http://127.0.0.1:22/", - timeout=1, - ) - assert client.session.timeout == 1 - - def test_timeout_override_session_timeout(self): - # The adapter timeout should override the session timeout - session = keystone_session.Session(timeout=10) - client = v1.Client( - auth_url="http://127.0.0.1:22/", - session=session, - timeout=2, - ) - self.assertEqual(2, client.session.timeout) diff --git a/designateclient/tests/test_v1/test_diagnostics.py b/designateclient/tests/test_v1/test_diagnostics.py deleted file mode 100644 index 09487f1..0000000 --- a/designateclient/tests/test_v1/test_diagnostics.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import mock -from mock import patch - -from designateclient.tests import test_v1 -from designateclient.v1 import diagnostics - - -class TestDiagnostics(test_v1.APIV1TestCase, test_v1.CrudMixin): - - @patch.object(diagnostics.DiagnosticsController, "ping") - def test_ping(self, ping): - args = mock.MagicMock() - args.service = "foo" - args.host = "host1" - self.client.diagnostics.ping(args.host, args.service) - self.client.diagnostics.ping.assert_called_with("host1", "foo") diff --git a/designateclient/tests/test_v1/test_domain.py b/designateclient/tests/test_v1/test_domain.py deleted file mode 100644 index fa69030..0000000 --- a/designateclient/tests/test_v1/test_domain.py +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import uuid - -from mock import patch - -from designateclient.tests import test_v1 -from designateclient import utils -from designateclient.v1 import domains -from designateclient import warlock - -Domain = warlock.model_factory(utils.load_schema('v1', 'domain')) - - -class TestDomain(test_v1.APIV1TestCase, test_v1.CrudMixin): - RESOURCE = 'domains' - - def new_ref(self, **kwargs): - ref = super(TestDomain, self).new_ref(**kwargs) - ref.setdefault("name", uuid.uuid4().hex) - ref.setdefault("email", "abc@example.com.") - ref.setdefault("ttl", 3600) - return ref - - def test_create(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain1.com.", - "email": "nsadmin@example.org", - "ttl": 60} - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - response = self.client.domains.create(values["name"]) - self.assertEqual(ref['id'], response['id']) - - def test_create_with_description(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain1.com.", - "email": "nsadmin@example.org", - "ttl": 60, - "description": "fully qualified domain"} - - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - response = self.client.domains.create(values["name"]) - self.assertEqual(ref['id'], response['id']) - - def test_create_with_description_too_long(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain1.com.", - "email": "nsadmin@example.org", - "ttl": 60, - "description": "d" * 161} - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.assertRaises(ValueError, self.client.domains.create, - values["name"]) - - def test_create_with_zero_ttl(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain1.com.", - "email": "nsadmin@example.org", - "ttl": 0} - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.assertRaises(ValueError, self.client.domains.create, - values["name"]) - - def test_create_with_negative_ttl(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain1.com.", - "email": "nsadmin@example.org", - "ttl": -1} - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.assertRaises(ValueError, self.client.domains.create, - values["name"]) - - def test_create_with_no_ttl(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain1.com.", - "email": "nsadmin@example.org", - "ttl": ""} - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.assertRaises(ValueError, self.client.domains.create, - values["name"]) - - def test_create_with_name_too_long(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "domain" + "a" * 255 + ".com.", - "email": "nsadmin@example.org", - "ttl": 60} - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.assertRaises(ValueError, self.client.domains.create, - values["name"]) - - def test_list(self): - items = [ - self.new_ref(email="abc@example.org", - id="89acac79-38e7-497d-807c-a011e1310438"), - self.new_ref(email="root@example.org", - id="89acac79-38e7-497d-807c-a011e1310435") - ] - - self.stub_url("GET", parts=[self.RESOURCE], json={"domains": items}) - - listed = self.client.domains.list() - self.assertList(items, listed) - self.assertQueryStringIs("") - - def test_get(self): - ref = self.new_ref(email="abc@example.org", - id="89acac79-38e7-497d-807c-a011e1310438") - - self.stub_entity("GET", entity=ref, id=ref["id"]) - - response = self.client.domains.get(ref["id"]) - self.assertEqual(ref, response) - - def test_delete(self): - ref = self.new_ref(email="abc@example.org", - id="89acac79-38e7-497d-807c-a011e1310438") - - self.stub_entity("DELETE", entity=ref, id=ref["id"]) - - self.client.domains.delete(ref["id"]) - self.assertRequestBodyIs(None) - - def test_update(self): - ref = self.new_ref(id="89acac79-38e7-497d-807c-a011e1310438") - - self.stub_entity("PUT", entity=ref, id=ref["id"]) - - values = ref.copy() - - self.client.domains.update(Domain(values)) - - @patch.object(domains.DomainsController, "list_domain_servers") - def test_list_domain_servers(self, domains_get): - domains_get.return_value = [{"id": "foo", "name": "ns1.example.com."}] - - ref = [{ - "id": "foo", - "name": "ns1.example.com.", - }] - parts = ["domains", "foo", "servers"] - self.stub_url("GET", parts=parts, json={"servers": ref}) - - response = self.client.domains.list_domain_servers("foo") - self.assertEqual(ref, response) diff --git a/designateclient/tests/test_v1/test_quotas.py b/designateclient/tests/test_v1/test_quotas.py deleted file mode 100644 index 4e73940..0000000 --- a/designateclient/tests/test_v1/test_quotas.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import mock -from mock import patch - -from designateclient.tests import test_v1 -from designateclient.v1 import quotas - - -class TestQuota(test_v1.APIV1TestCase, test_v1.CrudMixin): - - @patch.object(quotas.QuotasController, "get") - def test_get(self, quota_get): - QUOTA = {"domains": 10, - "recordset_records": 20, - "domain_records": 500, - "domain_recordsets": 500} - quota_get.return_value = QUOTA - response = self.client.quotas.get("foo") - self.assertEqual(QUOTA, response) - - @patch.object(quotas.QuotasController, "update") - def test_update(self, quota_update): - args = mock.MagicMock() - args.tenant_id = "1234" - args.value = {"domains": 1000} - self.client.quotas.update(args.tenant_id, args.value) - self.client.quotas.update.assert_called_with(args.tenant_id, - args.value) - - @patch.object(quotas.QuotasController, "reset") - def test_reset(self, quota_reset): - args = mock.MagicMock() - args.tenant_id = "1234" - self.client.quotas.reset(args.tenant_id) - self.client.quotas.reset.assert_called_with("1234") diff --git a/designateclient/tests/test_v1/test_records.py b/designateclient/tests/test_v1/test_records.py deleted file mode 100644 index b1b54b5..0000000 --- a/designateclient/tests/test_v1/test_records.py +++ /dev/null @@ -1,222 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import uuid - -from designateclient.tests import test_v1 -from designateclient import utils -from designateclient import warlock - - -Record = warlock.model_factory(utils.load_schema('v1', 'record')) - -DOMAIN = { - "id": str(uuid.uuid4()), - "name": "example.com." -} - - -class TestRecords(test_v1.APIV1TestCase, test_v1.CrudMixin): - RESOURCE = 'records' - - def new_ref(self, **kwargs): - ref = super(TestRecords, self).new_ref(**kwargs) - ref.setdefault("name", uuid.uuid4().hex) - ref.setdefault("type", "A") - ref.setdefault("data", "10.0.0.1") - return ref - - def test_create_record(self): - ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_AAAA_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778888", - type="AAAA", - data="2001:db8:0:1234:0:5678:9:12") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_MX_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778989", - type="MX", - data="mail.example.com.", - priority=10) - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_CNAME_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778890", - type="CNAME", - data="example.com.") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_TXT_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778889", - type="TXT", - data="This is a TXT record") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_SRV_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778888", - type="SRV", - data="0 5060 sip.example.com.", - priority=30) - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_NS_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677779999", - type="NS", - data="ns1.example.com.") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_PTR_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778891", - type="PTR", - data="www.example.com.") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_SPF_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778899", - type="SPF", - data="v=spf1 +mx a:colo.example.com/28 -all") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_create_SSHFP_record(self): - ref = self.new_ref(id="11112222-3333-4444-5555-666677778888", - type="SSHFP", - data="2 1 6c3c958af43d953f91f40e0d84157f4fe7b4a898") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("POST", parts=parts, json=ref) - - values = ref.copy() - del values["id"] - - self.client.records.create(DOMAIN['id'], Record(values)) - self.assertRequestBodyIs(json=values) - - def test_get(self): - ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_entity("GET", entity=ref, id=ref["id"], parts=parts) - - response = self.client.records.get(DOMAIN["id"], ref["id"]) - self.assertEqual(ref, response) - - def test_list(self): - items = [ - self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad"), - self.new_ref(id="11112222-3333-4444-5555-666677778888") - ] - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_url("GET", parts=parts, json={"records": items}) - - listed = self.client.records.list(DOMAIN["id"]) - self.assertList(items, listed) - self.assertQueryStringIs("") - - def test_update(self): - ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad", - type="A", - data="192.0.2.5") - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_entity("PUT", entity=ref, id=ref["id"], parts=parts) - - values = ref.copy() - del values["id"] - - self.client.records.update(DOMAIN["id"], Record(ref)) - - def test_delete(self): - ref = self.new_ref() - - parts = ["domains", DOMAIN["id"], self.RESOURCE] - self.stub_entity("DELETE", id=ref["id"], parts=parts) - - self.client.records.delete(DOMAIN["id"], ref["id"]) - self.assertRequestBodyIs(None) diff --git a/designateclient/tests/test_v1/test_reports.py b/designateclient/tests/test_v1/test_reports.py deleted file mode 100644 index 0edd154..0000000 --- a/designateclient/tests/test_v1/test_reports.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import mock -from mock import patch - -from designateclient.tests import test_v1 -from designateclient.v1 import reports - - -class TestReports(test_v1.APIV1TestCase, test_v1.CrudMixin): - - @patch.object(reports.ReportsController, "count_all") - def test_count_all(self, count_all): - self.client.reports.count_all() - self.client.reports.count_all.assert_called_with() - - @patch.object(reports.ReportsController, "count_domains") - def test_count_domain(self, count_domains): - self.client.reports.count_domains() - self.client.reports.count_domains.assert_called_once_with() - - @patch.object(reports.ReportsController, "count_tenants") - def test_count_tenants(self, count_tenants): - self.client.reports.count_tenants() - self.client.reports.count_tenants.assert_called_once_with() - - @patch.object(reports.ReportsController, "count_records") - def test_count_records(self, count_records): - self.client.reports.count_records() - self.client.reports.count_records.assert_called_once_with() - - @patch.object(reports.ReportsController, "tenants_all") - def test_tenants_all(self, tenants_all): - self.client.reports.tenants_all() - self.client.reports.tenants_all.assert_called_once_with() - - @patch.object(reports.ReportsController, "tenant_domains") - def test_tenant_domains(self, tenant_domains): - args = mock.MagicMock() - args.other_tenant_id = "uuid" - self.client.reports.tenant_domains(args.other_tenant_id) - self.client.reports.tenant_domains.assert_called_once_with("uuid") diff --git a/designateclient/tests/test_v1/test_servers.py b/designateclient/tests/test_v1/test_servers.py deleted file mode 100644 index b8fa653..0000000 --- a/designateclient/tests/test_v1/test_servers.py +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import uuid - -import mock -from mock import patch - -from designateclient.tests import test_v1 -from designateclient.v1 import servers - - -class TestServers(test_v1.APIV1TestCase, test_v1.CrudMixin): - RESOURCE = 'servers' - - def new_ref(self, **kwargs): - ref = super(TestServers, self).new_ref(**kwargs) - ref.setdefault("name", uuid.uuid4().hex) - return ref - - def test_list(self): - items = [ - self.new_ref(name="ns1.example.org.", - id="89acac79-38e7-497d-807c-a011e1310438"), - self.new_ref(name="ns2.example.org.", - id="89acac79-38e7-497d-807c-a011e1310435") - ] - - self.stub_url("GET", parts=[self.RESOURCE], json={"servers": items}) - - listed = self.client.servers.list() - self.assertList(items, listed) - self.assertQueryStringIs("") - - def test_get(self): - ref = self.new_ref(name="ns1.example.org.", - id="89acac79-38e7-497d-807c-a011e1310438") - - self.stub_entity("GET", entity=ref, id=ref["id"]) - - response = self.client.servers.get(ref["id"]) - self.assertEqual(ref, response) - - def test_create(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "ns1.example.org."} - - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.client.servers.create({"name": "ns1.example.org."}) - self.assertRequestBodyIs(json=values) - - def test_create_with_name_too_long(self): - ref = {"id": "89acac79-38e7-497d-807c-a011e1310438", - "name": "ns1." + "foo" * 85 + ".org."} - - self.stub_url("POST", parts=[self.RESOURCE], json=ref) - - values = ref.copy() - del values["id"] - - self.assertRaises(ValueError, self.client.servers.create, - {"name": "ns1.example.org."}) - - @patch.object(servers.ServersController, "update") - def test_update(self, server_update): - ref = self.new_ref() - - self.stub_entity("PUT", entity=ref, id=ref["id"]) - - mock_server = mock.MagicMock() - self.client.servers.update(mock_server) - self.client.servers.update.assert_called_with(mock_server) - - def test_delete(self): - ref = self.new_ref() - - self.stub_entity("DELETE", id=ref["id"]) - - self.client.servers.delete(ref["id"]) - self.assertRequestBodyIs(None) diff --git a/designateclient/tests/test_v1/test_sync.py b/designateclient/tests/test_v1/test_sync.py deleted file mode 100644 index 88ad5d1..0000000 --- a/designateclient/tests/test_v1/test_sync.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import mock -from mock import patch - -from designateclient.tests import test_v1 -from designateclient.v1 import sync - - -class TestSync(test_v1.APIV1TestCase, test_v1.CrudMixin): - - @patch.object(sync.SyncController, "sync_all") - def test_sync_all(self, sync_all): - self.client.sync.sync_all() - self.client.sync.sync_all.assert_called_with() - - @patch.object(sync.SyncController, "sync_domain") - def test_sync_domain(self, sync_domain): - args = mock.MagicMock() - args.tenant_id = "1234" - self.client.sync.sync_domain(args.tenant_id) - self.client.sync.sync_domain.assert_called_with("1234") - - @patch.object(sync.SyncController, "sync_record") - def test_sync_record(self, sync_record): - args = mock.MagicMock() - args.tenant_id = "1234" - args.record_id = "uuid" - self.client.sync.sync_record(args.tenant_id, args.record_id) - self.client.sync.sync_record.assert_called_with("1234", "uuid") diff --git a/designateclient/tests/test_v1/test_touch.py b/designateclient/tests/test_v1/test_touch.py deleted file mode 100644 index 5c944b0..0000000 --- a/designateclient/tests/test_v1/test_touch.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# 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. - -import mock -from mock import patch - -from designateclient.tests import test_v1 -from designateclient.v1 import touch - - -class TestTouch(test_v1.APIV1TestCase, test_v1.CrudMixin): - - @patch.object(touch.TouchController, "domain") - def test_domain(self, domain): - args = mock.MagicMock() - args.domain_id = "1234" - self.client.touch.domain(args.domain_id) - self.client.touch.domain.assert_called_with("1234") diff --git a/designateclient/v1/__init__.py b/designateclient/v1/__init__.py deleted file mode 100644 index 2474a4e..0000000 --- a/designateclient/v1/__init__.py +++ /dev/null @@ -1,161 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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 debtcollector import removals -from stevedore import extension - -from designateclient import exceptions -from designateclient import utils -from designateclient import version - - -@removals.removed_class( - 'designateclient.v1.Client', - replacement='designateclient.v2.client.Client', - message='Designate v1 API is being retired, and the v1 Client class will ' - 'stop functioning. Please update code to the ' - 'designateclient.v2.client.Client class. The API is deprecated', - version='2.2.0', - removal_version='?', - stacklevel=3) -class Client(object): - """Client for the Designate v1 API""" - - def __init__(self, endpoint=None, username=None, user_id=None, - user_domain_id=None, user_domain_name=None, password=None, - tenant_name=None, tenant_id=None, domain_name=None, - domain_id=None, project_name=None, - project_id=None, project_domain_name=None, - project_domain_id=None, auth_url=None, token=None, - endpoint_type='publicURL', region_name=None, - service_type='dns', insecure=False, session=None, - cacert=None, all_tenants=None, edit_managed=None, - timeout=None): - """ - :param endpoint: Endpoint URL - :param token: A token instead of username / password - :param insecure: Allow "insecure" HTTPS requests - """ - - if endpoint: - endpoint = endpoint.rstrip('/') - if not endpoint.endswith('v1'): - endpoint = "%s/v1" % endpoint - - # Compatibility code to mimic the old behaviour of the client - if session is None: - session = utils.get_session( - auth_url=auth_url, - endpoint=endpoint, - domain_id=domain_id, - domain_name=domain_name, - project_id=project_id or tenant_id, - project_name=project_name or tenant_name, - project_domain_name=project_domain_name, - project_domain_id=project_domain_id, - username=username, - user_id=user_id, - password=password, - user_domain_id=user_domain_id, - user_domain_name=user_domain_name, - token=token, - insecure=insecure, - cacert=cacert, - ) - - # NOTE: all_tenants and edit_managed are pulled from the session for - # backwards compat reasons, do not pull additional modifiers from - # here. Once removed, the kwargs above should default to False. - if all_tenants is None: - self.all_tenants = getattr(session, 'all_tenants', False) - else: - self.all_tenants = all_tenants - - if edit_managed is None: - self.edit_managed = getattr(session, 'edit_managed', False) - else: - self.edit_managed = edit_managed - - # Since we have to behave nicely like a legacy client/bindings we use - # an adapter around the session to not modify it's state. - interface = endpoint_type.rstrip('URL') - - self.session = utils.AdapterWithTimeout( - session, - auth=session.auth, - endpoint_override=endpoint, - region_name=region_name, - service_type=service_type, - interface=interface, - user_agent='python-designateclient-%s' % version.version_info, - version='1', - timeout=timeout, - ) - - def _load_controller(ext): - controller = ext.plugin(client=self) - setattr(self, ext.name, controller) - - # Load all controllers - mgr = extension.ExtensionManager('designateclient.v1.controllers') - mgr.map(_load_controller) - - def wrap_api_call(self, func, *args, **kw): - """ - Wrap a self. with exception handling - - :param func: The function to wrap - """ - kw['raise_exc'] = False - kw.setdefault('headers', {}) - kw['headers'].setdefault('Content-Type', 'application/json') - if self.all_tenants: - kw['headers'].update({'X-Auth-All-Projects': 'true'}) - if self.edit_managed: - kw['headers'].update({'X-Designate-Edit-Managed-Records': 'true'}) - - # Trigger the request - response = func(*args, **kw) - - # Decode is response, if possible - try: - response_payload = response.json() - except ValueError: - response_payload = {} - - if response.status_code == 400: - raise exceptions.BadRequest(**response_payload) - elif response.status_code in (401, 403, 413): - raise exceptions.Forbidden(**response_payload) - elif response.status_code == 404: - raise exceptions.NotFound(**response_payload) - elif response.status_code == 409: - raise exceptions.Conflict(**response_payload) - elif response.status_code >= 500: - raise exceptions.Unknown(**response_payload) - else: - return response - - def get(self, path, **kw): - return self.wrap_api_call(self.session.get, path, **kw) - - def post(self, path, **kw): - return self.wrap_api_call(self.session.post, path, **kw) - - def put(self, path, **kw): - return self.wrap_api_call(self.session.put, path, **kw) - - def delete(self, path, **kw): - return self.wrap_api_call(self.session.delete, path, **kw) diff --git a/designateclient/v1/diagnostics.py b/designateclient/v1/diagnostics.py deleted file mode 100644 index d2e5153..0000000 --- a/designateclient/v1/diagnostics.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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 designateclient import client - - -class DiagnosticsController(client.Controller): - def ping(self, service, host): - """ - Ping a service on a given host - """ - response = self.client.get('/diagnostics/ping/%s/%s' % - (service, host)) - - return response.json() diff --git a/designateclient/v1/domains.py b/designateclient/v1/domains.py deleted file mode 100644 index 2b556a5..0000000 --- a/designateclient/v1/domains.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. -import json - -from designateclient import client -from designateclient import utils -from designateclient import warlock - - -Domain = warlock.model_factory(utils.load_schema('v1', 'domain')) -Server = warlock.model_factory(utils.load_schema('v1', 'server')) - - -class DomainsController(client.CrudController): - def list(self): - """ - Retrieve a list of domains - - :returns: A list of :class:`Domain` - """ - response = self.client.get('/domains') - - return [Domain(i) for i in response.json()['domains']] - - def get(self, domain_id): - """ - Retrieve a domain - - :param domain_id: Domain Identifier - :returns: :class:`Domain` - """ - response = self.client.get('/domains/%s' % domain_id) - - return Domain(response.json()) - - def create(self, domain): - """ - Create a domain - - :param domain: A :class:`Domain` to create - :returns: :class:`Domain` - """ - response = self.client.post('/domains', data=json.dumps(domain)) - - return Domain(response.json()) - - def update(self, domain): - """ - Update a domain - - :param domain: A :class:`Domain` to update - :returns: :class:`Domain` - """ - response = self.client.put('/domains/%s' % domain.id, - data=json.dumps(domain.changes)) - - return Domain(response.json()) - - def delete(self, domain): - """ - Delete a domain - - :param domain: A :class:`Domain`, or Domain Identifier to delete - """ - if isinstance(domain, Domain): - self.client.delete('/domains/%s' % domain.id) - else: - self.client.delete('/domains/%s' % domain) - - def list_domain_servers(self, domain_id): - """ - Retrieve the list of nameservers for a domain - - :param domain_id: Domain Identifier - :returns: A list of :class:`Server` - """ - response = self.client.get('/domains/%s/servers' % domain_id) - - return [Server(i) for i in response.json()['servers']] diff --git a/designateclient/v1/quotas.py b/designateclient/v1/quotas.py deleted file mode 100644 index 32a1467..0000000 --- a/designateclient/v1/quotas.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. -import json - -from designateclient import client - - -class QuotasController(client.Controller): - def get(self, tenant_id): - """ - Ping a service on a given host - """ - response = self.client.get('/quotas/%s' % tenant_id) - - return response.json() - - def update(self, tenant_id, values): - response = self.client.put('/quotas/%s' % tenant_id, - data=json.dumps(values)) - return response.json() - - def reset(self, tenant_id): - response = self.client.delete('/quotas/%s' % tenant_id) - - return response diff --git a/designateclient/v1/records.py b/designateclient/v1/records.py deleted file mode 100644 index cd699a7..0000000 --- a/designateclient/v1/records.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import json - -from designateclient import client -from designateclient import utils -from designateclient.v1.domains import Domain -from designateclient import warlock - - -Record = warlock.model_factory(utils.load_schema('v1', 'record')) - - -class RecordsController(client.CrudController): - def list(self, domain): - """ - Retrieve a list of records - - :param domain: :class:`Domain` or Domain Identifier - :returns: A list of :class:`Record` - """ - domain_id = domain.id if isinstance(domain, Domain) else domain - - response = self.client.get('/domains/%(domain_id)s/records' % { - 'domain_id': domain_id - }) - - return [Record(i) for i in response.json()['records']] - - def get(self, domain, record_id): - """ - Retrieve a record - - :param domain: :class:`Domain` or Domain Identifier - :param record_id: Record Identifier - :returns: :class:`Record` - """ - domain_id = domain.id if isinstance(domain, Domain) else domain - - uri = '/domains/%(domain_id)s/records/%(record_id)s' % { - 'domain_id': domain_id, - 'record_id': record_id - } - - response = self.client.get(uri) - - return Record(response.json()) - - def create(self, domain, record): - """ - Create a record - - :param domain: :class:`Domain` or Domain Identifier - :param record: A :class:`Record` to create - :returns: :class:`Record` - """ - domain_id = domain.id if isinstance(domain, Domain) else domain - - uri = '/domains/%(domain_id)s/records' % { - 'domain_id': domain_id - } - - response = self.client.post(uri, data=json.dumps(record)) - - return Record(response.json()) - - def update(self, domain, record): - """ - Update a record - - :param domain: :class:`Domain` or Domain Identifier - :param record: A :class:`Record` to update - :returns: :class:`Record` - """ - domain_id = domain.id if isinstance(domain, Domain) else domain - - uri = '/domains/%(domain_id)s/records/%(record_id)s' % { - 'domain_id': domain_id, - 'record_id': record.id - } - - response = self.client.put(uri, data=json.dumps(record.changes)) - - return Record(response.json()) - - def delete(self, domain, record): - """ - Delete a record - - :param domain: :class:`Domain` or Domain Identifier - :param record: A :class:`Record`, or Record Identifier to delete - """ - domain_id = domain.id if isinstance(domain, Domain) else domain - record_id = record.id if isinstance(record, Record) else record - - uri = '/domains/%(domain_id)s/records/%(record_id)s' % { - 'domain_id': domain_id, - 'record_id': record_id - } - - self.client.delete(uri) diff --git a/designateclient/v1/reports.py b/designateclient/v1/reports.py deleted file mode 100644 index 4a32c6c..0000000 --- a/designateclient/v1/reports.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2013 Hewlett-Packard Development Company, L.P. All Rights Reserved. -# -# Author: Patrick Galbraith -# -# 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 designateclient import client - - -class ReportsController(client.Controller): - def count_all(self): - """ - Domain, Records and tenant total count - """ - response = self.client.get('/reports/counts') - - return response.json() - - def count_domains(self): - """ - Domain total count - """ - response = self.client.get('/reports/counts/domains') - - return response.json() - - def count_tenants(self): - """ - Tenant total count - """ - response = self.client.get('/reports/counts/tenants') - - return response.json() - - def count_records(self): - """ - Record total count - """ - response = self.client.get('/reports/counts/records') - - return response.json() - - def tenants_all(self): - """ - Per tenant count - """ - response = self.client.get('/reports/tenants') - - return response.json()['tenants'] - - def tenant_domains(self, other_tenant_id): - """ - Tenant's domain count - """ - response = self.client.get('/reports/tenants/%s' % - other_tenant_id) - - return [{'domain': d} for d in response.json()['domains']] diff --git a/designateclient/v1/servers.py b/designateclient/v1/servers.py deleted file mode 100644 index 9d77e8b..0000000 --- a/designateclient/v1/servers.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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. - -import json - -from designateclient import client -from designateclient import utils -from designateclient import warlock - - -Server = warlock.model_factory(utils.load_schema('v1', 'server')) - - -class ServersController(client.CrudController): - def list(self): - """ - Retrieve a list of servers - - :returns: A list of :class:`Server` - """ - response = self.client.get('/servers') - - return [Server(i) for i in response.json()['servers']] - - def get(self, server_id): - """ - Retrieve a server - - :param server_id: Server Identifier - :returns: :class:`Server` - """ - response = self.client.get('/servers/%s' % server_id) - - return Server(response.json()) - - def create(self, server): - """ - Create a server - - :param server: A :class:`Server` to create - :returns: :class:`Server` - """ - response = self.client.post('/servers', data=json.dumps(server)) - - return Server(response.json()) - - def update(self, server): - """ - Update a server - - :param server: A :class:`Server` to update - :returns: :class:`Server` - """ - response = self.client.put('/servers/%s' % server.id, - data=json.dumps(server.changes)) - - return Server(response.json()) - - def delete(self, server): - """ - Delete a server - - :param server: A :class:`Server`, or Server Identifier to delete - """ - if isinstance(server, Server): - self.client.delete('/servers/%s' % server.id) - else: - self.client.delete('/servers/%s' % server) diff --git a/designateclient/v1/sync.py b/designateclient/v1/sync.py deleted file mode 100644 index f86e642..0000000 --- a/designateclient/v1/sync.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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 designateclient import client - - -class SyncController(client.Controller): - def sync_all(self): - """ - Sync Everything - """ - self.client.post('/domains/sync') - - def sync_domain(self, domain_id): - """ - Sync Single Domain - """ - self.client.post('/domains/%s/sync' % domain_id) - - def sync_record(self, domain_id, record_id): - """ - Sync Single Record - """ - self.client.post('/domains/%s/records/%s/sync' % - (domain_id, record_id)) diff --git a/designateclient/v1/touch.py b/designateclient/v1/touch.py deleted file mode 100644 index bbbdbd2..0000000 --- a/designateclient/v1/touch.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2013 Hewlett-Packard Development Company, L.P. -# -# Author: Kiall Mac Innes -# -# 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 designateclient import client - - -class TouchController(client.Controller): - def domain(self, domain_id): - """ - Touch a single Domain - """ - self.client.post('/domains/%s/touch' % domain_id) diff --git a/designateclient/v2/blacklists.py b/designateclient/v2/blacklists.py deleted file mode 100644 index 102c018..0000000 --- a/designateclient/v2/blacklists.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller - - -class BlacklistController(V2Controller): - def create(self, pattern, description=None): - data = { - 'pattern': pattern, - } - - if description is not None: - data['description'] = description - - return self._post('/blacklists', data=data) - - def list(self, criterion=None, marker=None, limit=None): - url = self.build_url('/blacklists', criterion, marker, limit) - - return self._get(url, response_key="blacklists") - - def get(self, blacklist_id): - url = '/blacklists/%s' % blacklist_id - - return self._get(url) - - def update(self, blacklist_id, values): - url = '/blacklists/%s' % blacklist_id - - return self._patch(url, data=values) - - def delete(self, blacklist_id): - url = '/blacklists/%s' % blacklist_id - - return self._delete(url) diff --git a/designateclient/v2/cli/__init__.py b/designateclient/v2/cli/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/designateclient/v2/cli/blacklists.py b/designateclient/v2/cli/blacklists.py deleted file mode 100644 index ce6ec91..0000000 --- a/designateclient/v2/cli/blacklists.py +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. - -import logging - -from osc_lib.command import command -import six - -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2.utils import get_all - - -LOG = logging.getLogger(__name__) - - -def _format_blacklist(blacklist): - # Remove unneeded fields for display output formatting - blacklist.pop('links', None) - - -class ListBlacklistsCommand(command.Lister): - """List blacklists""" - - columns = ['id', 'pattern', 'description'] - - def get_parser(self, prog_name): - parser = super(ListBlacklistsCommand, self).get_parser(prog_name) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - cols = self.columns - data = get_all(client.blacklists.list) - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowBlacklistCommand(command.ShowOne): - """Show blacklist details""" - - def get_parser(self, prog_name): - parser = super(ShowBlacklistCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Blacklist ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.blacklists.get(parsed_args.id) - _format_blacklist(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class CreateBlacklistCommand(command.ShowOne): - """Create new blacklist""" - - def get_parser(self, prog_name): - parser = super(CreateBlacklistCommand, self).get_parser(prog_name) - - parser.add_argument('--pattern', help="Blacklist pattern", - required=True) - parser.add_argument('--description', help="Description") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.blacklists.create( - parsed_args.pattern, parsed_args.description) - - _format_blacklist(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetBlacklistCommand(command.ShowOne): - """Set blacklist properties""" - - def get_parser(self, prog_name): - parser = super(SetBlacklistCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Blacklist ID") - parser.add_argument('--pattern', help="Blacklist pattern") - - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description") - description_group.add_argument('--no-description', action='store_true') - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - data = {} - - if parsed_args.pattern: - data['pattern'] = parsed_args.pattern - - if parsed_args.no_description: - data['description'] = None - elif parsed_args.description: - data['description'] = parsed_args.description - - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - updated = client.blacklists.update(parsed_args.id, data) - - _format_blacklist(updated) - return six.moves.zip(*sorted(six.iteritems(updated))) - - -class DeleteBlacklistCommand(command.Command): - """Delete blacklist""" - - def get_parser(self, prog_name): - parser = super(DeleteBlacklistCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Blacklist ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - client.blacklists.delete(parsed_args.id) - - LOG.info('Blacklist %s was deleted', parsed_args.id) diff --git a/designateclient/v2/cli/quotas.py b/designateclient/v2/cli/quotas.py deleted file mode 100644 index a9e1e32..0000000 --- a/designateclient/v2/cli/quotas.py +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. -import itertools -import logging - -from cliff import command -from cliff import show -import six - -from designateclient.v2.cli import common - -LOG = logging.getLogger(__name__) - - -DNS_QUOTAS = { - "api_export_size": "api-export-size", - "recordset_records": "recordset-records", - "zone_records": "zone-records", - "zone_recordsets": "zone-recordsets", - "zones": "zones" -} - - -class ListQuotasCommand(show.ShowOne): - """List quotas""" - - # columns = ['resource', 'hard_limit'] - - def get_parser(self, prog_name): - parser = super(ListQuotasCommand, self).get_parser(prog_name) - - common.add_all_common_options(parser) - - parser.add_argument( - '--project-id', - help="Project ID Default: current project") - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - proj_id = parsed_args.project_id or client.session.get_project_id() - - if parsed_args.project_id != client.session.get_project_id(): - common.set_all_projects(client, True) - - data = client.quotas.list(proj_id) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetQuotasCommand(show.ShowOne): - """Set blacklist properties""" - - def _build_options_list(self): - return itertools.chain(DNS_QUOTAS.items()) - - def get_parser(self, prog_name): - parser = super(SetQuotasCommand, self).get_parser(prog_name) - - common.add_all_common_options(parser) - - parser.add_argument('--project-id', help="Project ID") - for k, v in self._build_options_list(): - parser.add_argument( - '--%s' % v, - metavar='<%s>' % v, - dest=k, - type=int, - help='New value for the %s quota' % v, - ) - - return parser - - def take_action(self, parsed_args): - - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - quotas = {} - for k, v in DNS_QUOTAS.items(): - value = getattr(parsed_args, k, None) - if value is not None: - quotas[k] = value - - proj_id = parsed_args.project_id or client.session.get_project_id() - - if parsed_args.project_id != client.session.get_project_id(): - common.set_all_projects(client, True) - - updated = client.quotas.update(proj_id, quotas) - - return six.moves.zip(*sorted(six.iteritems(updated))) - - -class ResetQuotasCommand(command.Command): - """Delete blacklist""" - - def get_parser(self, prog_name): - parser = super(ResetQuotasCommand, self).get_parser(prog_name) - - common.add_all_common_options(parser) - - parser.add_argument('--project-id', help="Project ID") - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - proj_id = parsed_args.project_id or client.session.get_project_id() - - if parsed_args.project_id != client.session.get_project_id(): - common.set_all_projects(client, True) - - client.quotas.reset(proj_id) - - LOG.info('Quota for project %s was reset', parsed_args.project_id) diff --git a/designateclient/v2/cli/reverse.py b/designateclient/v2/cli/reverse.py deleted file mode 100644 index 6cbe5bf..0000000 --- a/designateclient/v2/cli/reverse.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. - -import logging - -from osc_lib.command import command -import six - -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2.utils import get_all - - -LOG = logging.getLogger(__name__) - - -def _format_floatingip(fip): - # Remove unneeded fields for display output formatting - fip.pop('links', None) - - -class ListFloatingIPCommand(command.Lister): - """List floatingip ptr records""" - - columns = ['id', 'ptrdname', 'description', 'ttl'] - - def get_parser(self, prog_name): - parser = super(ListFloatingIPCommand, self).get_parser(prog_name) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - cols = self.columns - data = get_all(client.floatingips.list) - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowFloatingIPCommand(command.ShowOne): - """Show floatingip ptr record details""" - - def get_parser(self, prog_name): - parser = super(ShowFloatingIPCommand, self).get_parser(prog_name) - - parser.add_argument('floatingip_id', help="Floating IP ID in format " - "region:floatingip_id") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.floatingips.get(parsed_args.floatingip_id) - _format_floatingip(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetFloatingIPCommand(command.ShowOne): - """Set floatingip ptr record""" - - def get_parser(self, prog_name): - parser = super(SetFloatingIPCommand, self).get_parser(prog_name) - - parser.add_argument('floatingip_id', help="Floating IP ID in format " - "region:floatingip_id") - parser.add_argument('ptrdname', help="PTRD Name") - - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description") - description_group.add_argument('--no-description', action='store_true') - - ttl_group = parser.add_mutually_exclusive_group() - ttl_group.add_argument('--ttl', type=int, help="TTL") - ttl_group.add_argument('--no-ttl', action='store_true') - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - data = {} - - if parsed_args.no_description: - data['description'] = None - elif parsed_args.description: - data['description'] = parsed_args.description - - if parsed_args.no_ttl: - data['ttl'] = None - elif parsed_args.ttl: - data['ttl'] = parsed_args.ttl - - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - fip = client.floatingips.set( - parsed_args.floatingip_id, - parsed_args.ptrdname, - parsed_args.description, - parsed_args.ttl) - - _format_floatingip(fip) - return six.moves.zip(*sorted(six.iteritems(fip))) - - -class UnsetFloatingIPCommand(command.Command): - """Unset floatingip ptr record""" - - def get_parser(self, prog_name): - parser = super(UnsetFloatingIPCommand, self).get_parser(prog_name) - - parser.add_argument('floatingip_id', help="Floating IP ID in format " - "region:floatingip_id") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - client.floatingips.unset(parsed_args.floatingip_id) - LOG.info('FloatingIP PTR %s was unset', parsed_args.floatingip_id) diff --git a/designateclient/v2/cli/service_statuses.py b/designateclient/v2/cli/service_statuses.py deleted file mode 100644 index a4bd272..0000000 --- a/designateclient/v2/cli/service_statuses.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2016 Hewlett Packard Enterprise Development Company LP -# -# Author: Endre Karlson -# -# 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. - -import logging - -from osc_lib.command import command -import six - -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2 import utils as v2_utils - - -LOG = logging.getLogger(__name__) - - -def _format_status(status): - status.pop("links", None) - # Remove unneeded fields for display output formatting - for k in ("capabilities", "stats"): - status[k] = "\n".join(status[k]) if status[k] else "-" - return status - - -class ListServiceStatusesCommand(command.Lister): - """List service statuses""" - - columns = ['id', 'hostname', 'service_name', 'status', 'stats', - 'capabilities'] - - def get_parser(self, prog_name): - parser = super(ListServiceStatusesCommand, self).get_parser(prog_name) - - parser.add_argument("--hostname", help="Hostname", required=False) - parser.add_argument("--service_name", help="Service Name", - required=False) - parser.add_argument("--status", help="Status", required=False) - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - cols = self.columns - - criterion = {} - for i in ["hostname", "service_name", "status"]: - v = getattr(parsed_args, i) - if v is not None: - criterion[i] = v - - data = v2_utils.get_all(client.service_statuses.list, - criterion=criterion) - - for i, s in enumerate(data): - data[i] = _format_status(s) - - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowServiceStatusCommand(command.ShowOne): - """Show service status details""" - - def get_parser(self, prog_name): - parser = super(ShowServiceStatusCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Service Status ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.service_statuses.get(parsed_args.id) - - _format_status(data) - return six.moves.zip(*sorted(six.iteritems(data))) diff --git a/designateclient/v2/cli/tlds.py b/designateclient/v2/cli/tlds.py deleted file mode 100644 index c41a477..0000000 --- a/designateclient/v2/cli/tlds.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. - -import logging - -from osc_lib.command import command -import six - -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2.utils import get_all - - -LOG = logging.getLogger(__name__) - - -def _format_tld(tld): - # Remove unneeded fields for display output formatting - tld.pop('links', None) - - -class ListTLDsCommand(command.Lister): - """List tlds""" - - columns = ['id', 'name', 'description'] - - def get_parser(self, prog_name): - parser = super(ListTLDsCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="TLD NAME") - - parser.add_argument('--description', help="TLD Description") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = get_all(client.tlds.list) - - cols = self.columns - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowTLDCommand(command.ShowOne): - """Show tld details""" - - def get_parser(self, prog_name): - parser = super(ShowTLDCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="TLD ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.tlds.get(parsed_args.id) - _format_tld(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class CreateTLDCommand(command.ShowOne): - """Create new tld""" - - def get_parser(self, prog_name): - parser = super(CreateTLDCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="TLD Name", required=True) - parser.add_argument('--description', help="Description") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.tlds.create(parsed_args.name, parsed_args.description) - _format_tld(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetTLDCommand(command.ShowOne): - """Set tld properties""" - - def get_parser(self, prog_name): - parser = super(SetTLDCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="TLD ID") - parser.add_argument('--name', help="TLD Name") - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description") - description_group.add_argument('--no-description', action='store_true') - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - data = {} - - if parsed_args.name: - data['name'] = parsed_args.name - - if parsed_args.no_description: - data['description'] = None - elif parsed_args.description: - data['description'] = parsed_args.description - - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.tlds.update(parsed_args.id, data) - _format_tld(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class DeleteTLDCommand(command.Command): - """Delete tld""" - - def get_parser(self, prog_name): - parser = super(DeleteTLDCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="TLD ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - client.tlds.delete(parsed_args.id) - - LOG.info('TLD %s was deleted', parsed_args.id) diff --git a/designateclient/v2/cli/tsigkeys.py b/designateclient/v2/cli/tsigkeys.py deleted file mode 100644 index b1d42ad..0000000 --- a/designateclient/v2/cli/tsigkeys.py +++ /dev/null @@ -1,170 +0,0 @@ -# Copyright 2017 SAP SE -# -# Author: Rudolf Vriend -# -# 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. - -import logging - -from osc_lib.command import command -import six - -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2.utils import get_all - -LOG = logging.getLogger(__name__) - - -def _format_tsigkey(tsigkey): - # Remove unneeded fields for display output formatting - tsigkey.pop('links', None) - - -class ListTSIGKeysCommand(command.Lister): - """List tsigkeys""" - - columns = ['id', 'name', 'algorithm', 'secret', 'scope', 'resource_id'] - - def get_parser(self, prog_name): - parser = super(ListTSIGKeysCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="TSIGKey NAME", required=False) - parser.add_argument('--algorithm', help="TSIGKey algorithm", - required=False) - parser.add_argument('--scope', help="TSIGKey scope", required=False) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - criterion = {} - if parsed_args.name is not None: - criterion["name"] = parsed_args.name - if parsed_args.algorithm is not None: - criterion["algorithm"] = parsed_args.algorithm - if parsed_args.scope is not None: - criterion["scope"] = parsed_args.scope - - data = get_all(client.tsigkeys.list, criterion) - - cols = self.columns - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowTSIGKeyCommand(command.ShowOne): - """Show tsigkey details""" - - def get_parser(self, prog_name): - parser = super(ShowTSIGKeyCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="TSIGKey ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.tsigkeys.get(parsed_args.id) - _format_tsigkey(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class CreateTSIGKeyCommand(command.ShowOne): - """Create new tsigkey""" - - def get_parser(self, prog_name): - parser = super(CreateTSIGKeyCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="TSIGKey Name", required=True) - parser.add_argument('--algorithm', help="TSIGKey algorithm", - required=True) - parser.add_argument('--secret', help="TSIGKey secret", required=True) - parser.add_argument('--scope', help="TSIGKey scope", required=True) - parser.add_argument('--resource-id', help="TSIGKey resource_id", - required=True) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - data = client.tsigkeys.create(parsed_args.name, parsed_args.algorithm, - parsed_args.secret, parsed_args.scope, - parsed_args.resource_id) - _format_tsigkey(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetTSIGKeyCommand(command.ShowOne): - """Set tsigkey properties""" - - def get_parser(self, prog_name): - parser = super(SetTSIGKeyCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="TSIGKey ID") - parser.add_argument('--name', help="TSIGKey Name") - parser.add_argument('--algorithm', help="TSIGKey algorithm") - parser.add_argument('--secret', help="TSIGKey secret") - parser.add_argument('--scope', help="TSIGKey scope") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - data = {} - - if parsed_args.name: - data['name'] = parsed_args.name - if parsed_args.algorithm: - data['algorithm'] = parsed_args.algorithm - if parsed_args.secret: - data['secret'] = parsed_args.secret - if parsed_args.scope: - data['scope'] = parsed_args.scope - - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.tsigkeys.update(parsed_args.id, data) - _format_tsigkey(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class DeleteTSIGKeyCommand(command.Command): - """Delete tsigkey""" - - def get_parser(self, prog_name): - parser = super(DeleteTSIGKeyCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="TSIGKey ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - client.tsigkeys.delete(parsed_args.id) - - LOG.info('TSIGKey %s was deleted', parsed_args.id) diff --git a/designateclient/v2/cli/zones.py b/designateclient/v2/cli/zones.py deleted file mode 100644 index 3782652..0000000 --- a/designateclient/v2/cli/zones.py +++ /dev/null @@ -1,716 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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. - -import logging - -from osc_lib.command import command -from osc_lib import exceptions as osc_exc -import six - -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2.utils import get_all - - -LOG = logging.getLogger(__name__) - - -def _format_zone(zone): - zone.pop('links', None) - zone['masters'] = ", ".join(zone['masters']) - attrib = '' - for attr in zone['attributes']: - attrib += "%s:%s\n" % (attr, zone['attributes'][attr]) - zone['attributes'] = attrib - - -def _format_zone_export_record(zone_export_record): - zone_export_record.pop('links', None) - - -def _format_zone_import_record(zone_import_record): - zone_import_record.pop('links', None) - - -class ListZonesCommand(command.Lister): - """List zones""" - - columns = ['id', 'name', 'type', 'serial', 'status', 'action'] - - def get_parser(self, prog_name): - parser = super(ListZonesCommand, self).get_parser(prog_name) - - parser.add_argument('--name', help="Zone Name", required=False) - parser.add_argument('--email', help="Zone Email", required=False) - parser.add_argument('--type', help="Zone Type", required=False) - parser.add_argument('--ttl', help="Time To Live (Seconds)", - required=False) - parser.add_argument('--description', help="Description", - required=False) - parser.add_argument('--status', help="Zone Status", required=False) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - common.set_all_common_headers(client, parsed_args) - - criterion = {} - if parsed_args.type is not None: - criterion["type"] = parsed_args.type - - if parsed_args.name is not None: - criterion["name"] = parsed_args.name - - if parsed_args.ttl is not None: - criterion["ttl"] = parsed_args.ttl - - if parsed_args.description is not None: - criterion["description"] = parsed_args.description - - if parsed_args.email is not None: - criterion["email"] = parsed_args.email - - if parsed_args.status is not None: - criterion["status"] = parsed_args.status - - data = get_all(client.zones.list, criterion) - - cols = self.columns - - if client.session.all_projects: - cols.insert(1, 'project_id') - - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowZoneCommand(command.ShowOne): - """Show zone details""" - - def get_parser(self, prog_name): - parser = super(ShowZoneCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zones.get(parsed_args.id) - - _format_zone(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class CreateZoneCommand(command.ShowOne): - """Create new zone""" - - def get_parser(self, prog_name): - parser = super(CreateZoneCommand, self).get_parser(prog_name) - - parser.add_argument('name', help="Zone Name") - parser.add_argument('--email', help="Zone Email") - parser.add_argument('--type', help="Zone Type", default='PRIMARY') - parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)") - parser.add_argument('--description', help="Description") - parser.add_argument('--masters', help="Zone Masters", nargs='+') - parser.add_argument('--attributes', help="Zone Attributes", nargs='+') - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - payload = {} - - if parsed_args.description: - payload["description"] = parsed_args.description - - if parsed_args.attributes: - payload["attributes"] = {} - for attr in parsed_args.attributes: - try: - k, v = attr.split(':') - payload["attributes"][k] = v - except ValueError: - msg = "Attribute '%s' is in an incorrect format. "\ - "Attributes are : formated" - raise osc_exc.CommandError(msg % attr) - - if parsed_args.type == 'PRIMARY': - # email is just for PRIMARY. - if not parsed_args.email: - msg = "Zone type PRIMARY requires --email." - raise osc_exc.CommandError(msg) - - payload["email"] = parsed_args.email - - # TTL is just valid for PRIMARY - if parsed_args.ttl is not None: - payload["ttl"] = parsed_args.ttl - elif parsed_args.type == 'SECONDARY': - payload["masters"] = parsed_args.masters - else: - msg = "Type %s is not supported. Please choose between " \ - "PRIMARY or SECONDARY" - raise osc_exc.CommandError(msg % parsed_args.type) - - data = client.zones.create( - parsed_args.name, parsed_args.type, **payload) - - _format_zone(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetZoneCommand(command.ShowOne): - """Set zone properties""" - - def get_parser(self, prog_name): - parser = super(SetZoneCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone ID") - parser.add_argument('--email', help="Zone Email") - parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)") - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description") - description_group.add_argument('--no-description', action='store_true') - - parser.add_argument('--masters', help="Zone Masters", nargs='+') - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = {} - - # TODO(kiall): API needs updating.. this get is silly - if parsed_args.email: - data['email'] = parsed_args.email - - if parsed_args.ttl: - data['ttl'] = parsed_args.ttl - - if parsed_args.no_description: - data['description'] = None - elif parsed_args.description: - data['description'] = parsed_args.description - - if parsed_args.masters: - data['masters'] = parsed_args.masters - - updated = client.zones.update(parsed_args.id, data) - _format_zone(updated) - return six.moves.zip(*sorted(six.iteritems(updated))) - - -class DeleteZoneCommand(command.ShowOne): - """Delete zone""" - - def get_parser(self, prog_name): - parser = super(DeleteZoneCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zones.delete(parsed_args.id) - LOG.info('Zone %s was deleted', parsed_args.id) - - _format_zone(data) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class AbandonZoneCommand(command.Command): - """Abandon a zone""" - def get_parser(self, prog_name): - parser = super(AbandonZoneCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - client.zones.abandon(parsed_args.id) - - LOG.info("Z %(zone_id)s abandoned", - {"zone_id": parsed_args.id}) - - -class AXFRZoneCommand(command.Command): - """AXFR a zone""" - def get_parser(self, prog_name): - parser = super(AXFRZoneCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - client.zones.axfr(parsed_args.id) - - LOG.info("Scheduled AXFR for zone %(zone_id)s", - {"zone_id": parsed_args.id}) - - -class CreateTransferRequestCommand(command.ShowOne): - """Create new zone transfer request""" - - def get_parser(self, prog_name): - parser = super(CreateTransferRequestCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_id', help="Zone ID to transfer.",) - parser.add_argument( - '--target-project-id', - help="Target Project ID to transfer to.") - parser.add_argument('--description', help="Description") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_transfers.create_request( - parsed_args.zone_id, parsed_args.target_project_id, - parsed_args.description) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class ListTransferRequestsCommand(command.Lister): - """List Zone Transfer Requests""" - - columns = ['id', 'zone_id', 'zone_name', 'project_id', - 'target_project_id', 'status', 'key'] - - def get_parser(self, prog_name): - parser = super(ListTransferRequestsCommand, self).get_parser( - prog_name) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_transfers.list_requests() - - cols = self.columns - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowTransferRequestCommand(command.ShowOne): - """Show Zone Transfer Request Details""" - - def get_parser(self, prog_name): - parser = super(ShowTransferRequestCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone Tranfer Request ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_transfers.get_request(parsed_args.id) - - return six.moves.zip(*sorted(six.iteritems(data))) - - -class SetTransferRequestCommand(command.ShowOne): - """Set a Zone Transfer Request""" - - def get_parser(self, prog_name): - parser = super(SetTransferRequestCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone Transfer Request ID") - description_group = parser.add_mutually_exclusive_group() - description_group.add_argument('--description', help="Description") - description_group.add_argument('--no-description', action='store_true') - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = {} - - if parsed_args.no_description: - data['description'] = None - elif parsed_args.description: - data['description'] = parsed_args.description - - updated = client.zone_transfers.update_request(parsed_args.id, data) - return six.moves.zip(*sorted(six.iteritems(updated))) - - -class DeleteTransferRequestCommand(command.Command): - """Delete a Zone Transfer Request""" - def get_parser(self, prog_name): - parser = super(DeleteTransferRequestCommand, self).get_parser( - prog_name) - - parser.add_argument('id', help="Zone Transfer Request ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - client.zone_transfers.delete_request(parsed_args.id) - - LOG.info('Zone Transfer %s was deleted', parsed_args.id) - - -class AcceptTransferRequestCommand(command.ShowOne): - """Accept a Zone Transfer Request""" - - def get_parser(self, prog_name): - parser = super(AcceptTransferRequestCommand, self).get_parser( - prog_name) - - parser.add_argument('--transfer-id', help="Transfer ID", type=str, - required=True) - parser.add_argument('--key', help="Transfer Key", type=str, - required=True) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_transfers.accept_request( - parsed_args.transfer_id, parsed_args.key) - return six.moves.zip(*sorted(six.iteritems(data))) - - -class ListTransferAcceptsCommand(command.Lister): - """List Zone Transfer Accepts""" - - columns = ['id', 'zone_id', 'project_id', - 'zone_transfer_request_id', 'status', 'key'] - - def get_parser(self, prog_name): - parser = super(ListTransferAcceptsCommand, self).get_parser( - prog_name) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_transfers.list_requests() - - cols = self.columns - return cols, (utils.get_item_properties(s, cols) for s in data) - - -class ShowTransferAcceptCommand(command.ShowOne): - """Show Zone Transfer Accept""" - - def get_parser(self, prog_name): - parser = super(ShowTransferAcceptCommand, self).get_parser(prog_name) - - parser.add_argument('id', help="Zone Tranfer Accept ID") - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_transfers.get_accept(parsed_args.id) - - return six.moves.zip(*sorted(six.iteritems(data))) - - -class ExportZoneCommand(command.ShowOne): - """Export a Zone""" - - def get_parser(self, prog_name): - parser = super(ExportZoneCommand, self).get_parser( - prog_name) - - common.add_all_common_options(parser) - - parser.add_argument('zone_id', help="Zone ID", type=str) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_exports.create(parsed_args.zone_id) - _format_zone_export_record(data) - - LOG.info('Zone Export %s was created', data['id']) - - return six.moves.zip(*sorted(six.iteritems(data))) - - -class ListZoneExportsCommand(command.Lister): - """List Zone Exports""" - - columns = [ - 'id', - 'zone_id', - 'created_at', - 'status', - ] - - def get_parser(self, prog_name): - parser = super(ListZoneExportsCommand, self).get_parser( - prog_name) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_exports.list() - - cols = self.columns - return cols, (utils.get_item_properties(s, cols) - for s in data['exports']) - - -class ShowZoneExportCommand(command.ShowOne): - """Show a Zone Export""" - - def get_parser(self, prog_name): - parser = super(ShowZoneExportCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_export_id', help="Zone Export ID", type=str) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_exports.get_export_record( - parsed_args.zone_export_id) - _format_zone_export_record(data) - - return six.moves.zip(*sorted(six.iteritems(data))) - - -class DeleteZoneExportCommand(command.Command): - """Delete a Zone Export""" - - def get_parser(self, prog_name): - parser = super(DeleteZoneExportCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_export_id', help="Zone Export ID", type=str) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - client.zone_exports.delete(parsed_args.zone_export_id) - - LOG.info('Zone Export %s was deleted', parsed_args.zone_export_id) - - -class ShowZoneExportFileCommand(command.ShowOne): - """Show the zone file for the Zone Export""" - - def get_parser(self, prog_name): - parser = super(ShowZoneExportFileCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_export_id', help="Zone Export ID", type=str) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_exports.get_export(parsed_args.zone_export_id) - - return ['data'], [data] - - -class ImportZoneCommand(command.ShowOne): - """Import a Zone from a file on the filesystem""" - - def get_parser(self, prog_name): - parser = super(ImportZoneCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_file_path', - help="Path to a zone file", type=str) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - with open(parsed_args.zone_file_path, 'r') as f: - zone_file_contents = f.read() - - data = client.zone_imports.create(zone_file_contents) - _format_zone_import_record(data) - - LOG.info('Zone Import %s was created', data['id']) - - return six.moves.zip(*sorted(six.iteritems(data))) - - -class ListZoneImportsCommand(command.Lister): - """List Zone Imports""" - - columns = [ - 'id', - 'zone_id', - 'created_at', - 'status', - 'message', - ] - - def get_parser(self, prog_name): - parser = super(ListZoneImportsCommand, self).get_parser( - prog_name) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_imports.list() - - cols = self.columns - return cols, (utils.get_item_properties(s, cols) - for s in data['imports']) - - -class ShowZoneImportCommand(command.ShowOne): - """Show a Zone Import""" - - def get_parser(self, prog_name): - parser = super(ShowZoneImportCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_import_id', help="Zone Import ID", type=str) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - data = client.zone_imports.get_import_record( - parsed_args.zone_import_id) - _format_zone_import_record(data) - - return six.moves.zip(*sorted(six.iteritems(data))) - - -class DeleteZoneImportCommand(command.Command): - """Delete a Zone Import""" - - def get_parser(self, prog_name): - parser = super(DeleteZoneImportCommand, self).get_parser( - prog_name) - - parser.add_argument('zone_import_id', help="Zone Import ID", type=str) - - common.add_all_common_options(parser) - - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.dns - common.set_all_common_headers(client, parsed_args) - - client.zone_imports.delete(parsed_args.zone_import_id) - - LOG.info('Zone Import %s was deleted', parsed_args.zone_import_id) diff --git a/designateclient/v2/limits.py b/designateclient/v2/limits.py deleted file mode 100644 index ba99629..0000000 --- a/designateclient/v2/limits.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller - - -class LimitController(V2Controller): - def get(self): - return self._get('/limits') diff --git a/designateclient/v2/nameservers.py b/designateclient/v2/nameservers.py deleted file mode 100644 index b35649d..0000000 --- a/designateclient/v2/nameservers.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller -from designateclient.v2 import utils as v2_utils - - -class NameServerController(V2Controller): - def list(self, zone): - zone = v2_utils.resolve_by_name(self.client.zones.list, zone) - - url = '/zones/%s/nameservers' % zone - - return self._get(url, response_key='nameservers') diff --git a/designateclient/v2/pools.py b/designateclient/v2/pools.py deleted file mode 100644 index e78a426..0000000 --- a/designateclient/v2/pools.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P. -# -# 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 designateclient.v2.base import V2Controller - - -class PoolController(V2Controller): - def list(self): - url = '/pools' - return self._get(url, response_key='pools') diff --git a/designateclient/v2/quotas.py b/designateclient/v2/quotas.py deleted file mode 100644 index 6377a41..0000000 --- a/designateclient/v2/quotas.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller - - -class QuotasController(V2Controller): - def list(self, project_id): - return self._get('/quotas/%s' % project_id) - - def update(self, project_id, values): - return self._patch('/quotas/%s' % project_id, data=values) - - def reset(self, project_id): - return self._delete('/quotas/%s' % project_id) diff --git a/designateclient/v2/reverse.py b/designateclient/v2/reverse.py deleted file mode 100644 index 3df78fa..0000000 --- a/designateclient/v2/reverse.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller - - -class FloatingIPController(V2Controller): - def set(self, floatingip_id, ptrdname, description=None, ttl=None): - data = { - 'ptrdname': ptrdname - } - - if description is not None: - data["description"] = description - - if ttl is not None: - data["ttl"] = ttl - - url = '/reverse/floatingips/%s' % floatingip_id - return self._patch(url, data=data) - - def list(self, criterion=None): - url = self.build_url('/reverse/floatingips', criterion) - - return self._get(url, response_key='floatingips') - - def get(self, floatingip_id): - url = '/reverse/floatingips/%s' % floatingip_id - - return self._get(url) - - def unset(self, floatingip_id): - data = {"ptrdname": None} - - url = '/reverse/floatingips/%s' % floatingip_id - - return self._patch(url, data=data) diff --git a/designateclient/v2/service_statuses.py b/designateclient/v2/service_statuses.py deleted file mode 100644 index 9477e97..0000000 --- a/designateclient/v2/service_statuses.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2016 Hewlett Packard Enterprise Development Company LP -# -# Author: Endre Karlson -# -# 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 designateclient.v2 import base - - -class ServiceStatusesController(base.V2Controller): - def list(self, criterion=None, marker=None, limit=None): - url = self.build_url('/service_statuses', criterion, marker, limit) - - return self._get(url, response_key="service_statuses") - - def get(self, service_status_id): - url = '/service_statuses/%s' % service_status_id - - return self._get(url) diff --git a/designateclient/v2/tlds.py b/designateclient/v2/tlds.py deleted file mode 100644 index d70c88a..0000000 --- a/designateclient/v2/tlds.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller -from designateclient.v2 import utils as v2_utils - - -class TLDController(V2Controller): - def create(self, name, description=None): - data = { - 'name': name, - } - - if description is not None: - data["description"] = description - - return self._post('/tlds', data=data) - - def list(self, criterion=None, marker=None, limit=None): - url = self.build_url('/tlds', criterion, marker, limit) - - return self._get(url, response_key='tlds') - - def get(self, tld): - tld = v2_utils.resolve_by_name(self.list, tld) - - return self._get('/tlds/%s' % tld) - - def update(self, tld, values): - tld = v2_utils.resolve_by_name(self.list, tld) - - return self._patch('/tlds/%s' % tld, data=values) - - def delete(self, tld): - tld = v2_utils.resolve_by_name(self.list, tld) - - return self._delete('/tlds/%s' % tld) diff --git a/designateclient/v2/tsigkeys.py b/designateclient/v2/tsigkeys.py deleted file mode 100644 index 988700f..0000000 --- a/designateclient/v2/tsigkeys.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2017 SAP SE -# -# Author: Rudolf Vriend -# -# 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 designateclient.v2.base import V2Controller -from designateclient.v2 import utils as v2_utils - - -class TSIGKeysController(V2Controller): - def create(self, name, algorithm, secret, scope, resource_id): - data = { - 'name': name, - 'algorithm': algorithm, - 'secret': secret, - 'scope': scope, - 'resource_id': resource_id - } - - return self._post('/tsigkeys', data=data) - - def list(self, criterion=None, marker=None, limit=None): - url = self.build_url('/tsigkeys', criterion, marker, limit) - - return self._get(url, response_key='tsigkeys') - - def get(self, tsigkey): - tsigkey = v2_utils.resolve_by_name(self.list, tsigkey) - - return self._get('/tsigkeys/%s' % tsigkey) - - def update(self, tsigkey, values): - tsigkey = v2_utils.resolve_by_name(self.list, tsigkey) - - return self._patch('/tsigkeys/%s' % tsigkey, data=values) - - def delete(self, tsigkey): - tsigkey = v2_utils.resolve_by_name(self.list, tsigkey) - - return self._delete('/tsigkeys/%s' % tsigkey) diff --git a/designateclient/v2/zones.py b/designateclient/v2/zones.py deleted file mode 100644 index 7e862a7..0000000 --- a/designateclient/v2/zones.py +++ /dev/null @@ -1,168 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# 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 designateclient.v2.base import V2Controller -from designateclient.v2 import utils as v2_utils - - -class ZoneController(V2Controller): - def create(self, name, type_=None, email=None, description=None, ttl=None, - masters=None, attributes=None): - type_ = type_ or "PRIMARY" - - data = { - "name": name, - "type": type_ - } - - if type_ == "PRIMARY": - if email: - data["email"] = email - - if ttl is not None: - data["ttl"] = ttl - - elif type_ == "SECONDARY" and masters: - data["masters"] = masters - - if description is not None: - data["description"] = description - - if attributes is not None: - data["attributes"] = attributes - - return self._post('/zones', data=data) - - def list(self, criterion=None, marker=None, limit=None): - url = self.build_url('/zones', criterion, marker, limit) - - return self._get(url, response_key="zones") - - def get(self, zone): - zone = v2_utils.resolve_by_name(self.list, zone) - - return self._get('/zones/%s' % zone) - - def update(self, zone, values): - zone = v2_utils.resolve_by_name(self.list, zone) - - url = self.build_url('/zones/%s' % zone) - - return self._patch(url, data=values) - - def delete(self, zone): - zone = v2_utils.resolve_by_name(self.list, zone) - - url = self.build_url('/zones/%s' % zone) - - return self._delete(url) - - def abandon(self, zone): - zone = v2_utils.resolve_by_name(self.list, zone) - - url = '/zones/%s/tasks/abandon' % zone - - self.client.session.post(url) - - def axfr(self, zone): - zone = v2_utils.resolve_by_name(self.list, zone) - - url = '/zones/%s/tasks/xfr' % zone - - self.client.session.post(url) - - -class ZoneTransfersController(V2Controller): - def create_request(self, zone, target_project_id, description=None): - zone = v2_utils.resolve_by_name(self.client.zones.list, zone) - - data = { - "target_project_id": target_project_id - } - - if description is not None: - data["description"] = description - - url = '/zones/%s/tasks/transfer_requests' % zone - - return self._post(url, data=data) - - def get_request(self, transfer_id): - url = '/zones/tasks/transfer_requests/%s' % transfer_id - return self._get(url) - - def list_requests(self): - url = '/zones/tasks/transfer_requests' - return self._get(url, response_key="transfer_requests") - - def update_request(self, transfer_id, values): - url = '/zones/tasks/transfer_requests/%s' % transfer_id - return self._patch(url, data=values) - - def delete_request(self, transfer_id): - url = '/zones/tasks/transfer_requests/%s' % transfer_id - self._delete(url) - - def accept_request(self, transfer_id, key): - url = '/zones/tasks/transfer_accepts' - - data = { - "key": key, - "zone_transfer_request_id": transfer_id - } - return self._post(url, data=data) - - def get_accept(self, accept_id): - url = '/zones/tasks/transfer_accepts/%s' % accept_id - return self._get(url) - - def list_accepts(self): - url = '/zones/tasks/transfer_accepts' - return self._get(url, response_key="transfer_accepts") - - -class ZoneExportsController(V2Controller): - def create(self, zone): - zone_id = v2_utils.resolve_by_name(self.client.zones.list, zone) - - return self._post('/zones/%s/tasks/export' % zone_id) - - def get_export_record(self, zone_export_id): - return self._get('/zones/tasks/exports/%s' % zone_export_id) - - def list(self): - return self._get('/zones/tasks/exports') - - def delete(self, zone_export_id): - return self._delete('/zones/tasks/exports/%s' % zone_export_id) - - def get_export(self, zone_export_id): - return self._get('/zones/tasks/exports/%s/export' % zone_export_id, - headers={'Accept': 'text/dns'}) - - -class ZoneImportsController(V2Controller): - def create(self, zone_file_contents): - return self._post('/zones/tasks/imports', data=zone_file_contents, - headers={'Content-Type': 'text/dns'}) - - def get_import_record(self, zone_import_id): - return self._get('/zones/tasks/imports/%s' % zone_import_id) - - def list(self): - return self._get('/zones/tasks/imports') - - def delete(self, zone_import_id): - return self._delete('/zones/tasks/imports/%s' % zone_import_id) diff --git a/doc/examples/recordset_create.py b/doc/examples/recordset_create.py index 1bad60f..6efe3a0 100644 --- a/doc/examples/recordset_create.py +++ b/doc/examples/recordset_create.py @@ -1,9 +1,9 @@ from __future__ import print_function import logging -from designateclient.v2 import client -from designateclient import exceptions -from designateclient import shell +from tatuclient.v2 import client +from tatuclient import exceptions +from tatuclient import shell from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session diff --git a/doc/examples/recordset_crud.py b/doc/examples/recordset_crud.py index f00e41e..41886c9 100644 --- a/doc/examples/recordset_crud.py +++ b/doc/examples/recordset_crud.py @@ -1,8 +1,8 @@ import logging -from designateclient.v2 import client -from designateclient import exceptions -from designateclient import shell +from tatuclient.v2 import client +from tatuclient import exceptions +from tatuclient import shell from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session diff --git a/doc/examples/zone_create_primary.py b/doc/examples/zone_create_primary.py index 91d822c..52261c6 100644 --- a/doc/examples/zone_create_primary.py +++ b/doc/examples/zone_create_primary.py @@ -2,9 +2,9 @@ from __future__ import print_function import logging -from designateclient import exceptions -from designateclient import shell -from designateclient.v2 import client +from tatuclient import exceptions +from tatuclient import shell +from tatuclient.v2 import client from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session diff --git a/doc/examples/zone_create_secondary.py b/doc/examples/zone_create_secondary.py index 876d1ba..05abe18 100644 --- a/doc/examples/zone_create_secondary.py +++ b/doc/examples/zone_create_secondary.py @@ -4,9 +4,9 @@ import uuid from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session -from designateclient import exceptions -from designateclient import shell -from designateclient.v2 import client +from tatuclient import exceptions +from tatuclient import shell +from tatuclient.v2 import client logging.basicConfig(level='DEBUG') diff --git a/doc/examples/zone_list_nameservers.py b/doc/examples/zone_list_nameservers.py index 1ee4f8e..c147d57 100644 --- a/doc/examples/zone_list_nameservers.py +++ b/doc/examples/zone_list_nameservers.py @@ -1,9 +1,9 @@ import logging import uuid -from designateclient.v2 import client -from designateclient import shell -from designateclient import utils +from tatuclient.v2 import client +from tatuclient import shell +from tatuclient import utils from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session diff --git a/doc/examples/zone_list_paging.py b/doc/examples/zone_list_paging.py index f62f6d9..61fa857 100644 --- a/doc/examples/zone_list_paging.py +++ b/doc/examples/zone_list_paging.py @@ -4,8 +4,8 @@ import logging from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session -from designateclient import shell -from designateclient.v2 import client +from tatuclient import shell +from tatuclient.v2 import client logging.basicConfig(level='DEBUG') diff --git a/doc/source/conf.py b/doc/source/conf.py index ec01574..0ac971c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# designateclient documentation build configuration file +# tatuclient documentation build configuration file # -- General configuration ----------------------------------------------------- @@ -9,8 +9,8 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'openstackdocstheme'] # openstackdocstheme options -repository_name = 'openstack/python-designateclient' -bug_project = 'python-designateclient' +repository_name = 'openstack/python-tatuclient' +bug_project = 'python-tatuclient' bug_tag = '' html_last_updated_fmt = '%Y-%m-%d %H:%M' html_theme = 'openstackdocs' @@ -25,7 +25,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'designateclient' +project = u'tatuclient' copyright = u'2012, Managed I.T. 2013-2014, Hewlett-Packard Development Company, L.P.' # The version info for the project you're documenting, acts as replacement for @@ -33,7 +33,7 @@ copyright = u'2012, Managed I.T. 2013-2014, Hewlett-Packard Development Company, # built documents. # # The short X.Y version. -from designateclient.version import version_info as designateclient_version +from tatuclient.version import version_info as designateclient_version version = designateclient_version.canonical_version_string() # The full version, including alpha/beta/rc tags. release = designateclient_version.version_string_with_vcs() @@ -46,7 +46,7 @@ exclude_patterns = [] pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -modindex_common_prefix = ['designateclient'] +modindex_common_prefix = ['tatuclient'] # -- Options for HTML output --------------------------------------------------- diff --git a/python-designateclient.sublime-project b/python-tatuclient.sublime-project similarity index 100% rename from python-designateclient.sublime-project rename to python-tatuclient.sublime-project diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 68f01db..2191f3f 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -42,8 +42,8 @@ extensions = [ ] # openstackdocstheme options -repository_name = 'openstack/python-designateclient' -bug_project = 'python-designateclient' +repository_name = 'openstack/python-tatuclient' +bug_project = 'python-tatuclient' bug_tag = '' html_last_updated_fmt = '%Y-%m-%d %H:%M' html_theme = 'openstackdocs' diff --git a/setup.cfg b/setup.cfg index 94064c1..492c27d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,12 @@ [metadata] -name = python-designateclient -summary = OpenStack DNS-as-a-Service - Client +name = python-tatuclient +summary = OpenStack SSH-as-a-Service - Client description-file = README.rst license = Apache License, Version 2.0 author = OpenStack author-email = openstack-dev@lists.openstack.org -home-page = https://docs.openstack.org/python-designateclient/latest +home-page = https://docs.openstack.org/python-tatuclient/latest classifier = Environment :: OpenStack Intended Audience :: Information Technology @@ -18,7 +18,7 @@ classifier = Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.5 - Topic :: Internet :: Name Service (DNS) + Topic :: Internet :: Name Service (SSH) [global] setup-hooks = @@ -26,133 +26,34 @@ setup-hooks = [files] packages = - designateclient + tatuclient scripts = - bin/designate + bin/tatu [entry_points] -designateclient.v1.controllers = - reports = designateclient.v1.reports:ReportsController - diagnostics = designateclient.v1.diagnostics:DiagnosticsController - domains = designateclient.v1.domains:DomainsController - records = designateclient.v1.records:RecordsController - servers = designateclient.v1.servers:ServersController - quotas = designateclient.v1.quotas:QuotasController - sync = designateclient.v1.sync:SyncController - touch = designateclient.v1.touch:TouchController - -designateclient.cli = - domain-list = designateclient.cli.domains:ListDomainsCommand - domain-get = designateclient.cli.domains:GetDomainCommand - domain-create = designateclient.cli.domains:CreateDomainCommand - domain-update = designateclient.cli.domains:UpdateDomainCommand - domain-delete = designateclient.cli.domains:DeleteDomainCommand - domain-servers-list = designateclient.cli.domains:ListDomainServersCommand - - record-list = designateclient.cli.records:ListRecordsCommand - record-get = designateclient.cli.records:GetRecordCommand - record-create = designateclient.cli.records:CreateRecordCommand - record-update = designateclient.cli.records:UpdateRecordCommand - record-delete = designateclient.cli.records:DeleteRecordCommand - - server-list = designateclient.cli.servers:ListServersCommand - server-get = designateclient.cli.servers:GetServerCommand - server-create = designateclient.cli.servers:CreateServerCommand - server-update = designateclient.cli.servers:UpdateServerCommand - server-delete = designateclient.cli.servers:DeleteServerCommand - - diagnostics-ping = designateclient.cli.diagnostics:PingCommand - - sync-all = designateclient.cli.sync:SyncAllCommand - sync-domain = designateclient.cli.sync:SyncDomainCommand - sync-record = designateclient.cli.sync:SyncRecordCommand - - touch-domain = designateclient.cli.touch:TouchDomainCommand - - report-count-all = designateclient.cli.reports:CountsCommand - report-count-domains = designateclient.cli.reports:DomainCountCommand - report-count-records = designateclient.cli.reports:RecordCountCommand - report-count-tenants = designateclient.cli.reports:TenantCountCommand - report-tenants-all = designateclient.cli.reports:TenantsCommand - report-tenant-domains = designateclient.cli.reports:TenantCommand - - quota-get = designateclient.cli.quotas:GetQuotaCommand - quota-update = designateclient.cli.quotas:UpdateQuotaCommand - quota-reset = designateclient.cli.quotas:ResetQuotaCommand - -designateclient.versions = - 1 = designateclient.v1:Client - 2 = designateclient.v2.client:Client +tatuclient.versions = + 2 = tatuclient.v2.client:Client openstack.cli.extension = - dns = designateclient.osc.plugin + ssh = tatuclient.osc.plugin -openstack.dns.v2 = - zone_blacklist_create = designateclient.v2.cli.blacklists:CreateBlacklistCommand - zone_blacklist_list = designateclient.v2.cli.blacklists:ListBlacklistsCommand - zone_blacklist_show = designateclient.v2.cli.blacklists:ShowBlacklistCommand - zone_blacklist_set = designateclient.v2.cli.blacklists:SetBlacklistCommand - zone_blacklist_delete = designateclient.v2.cli.blacklists:DeleteBlacklistCommand +openstack.ssh.v2 = + usercert_create = tatuclient.v2.cli.usercert:CreateUserCertCommand + usercert_list = tatuclient.v2.cli.usercert:ListUserCertsCommand + usercert_show = tatuclient.v2.cli.usercert:ShowUserCertCommand + usercert_revoke = tatuclient.v2.cli.usercert:RevokeUserCertCommand + usercert_delete = tatuclient.v2.cli.usercert:DeleteUserCertCommand - tld_create = designateclient.v2.cli.tlds:CreateTLDCommand - tld_list = designateclient.v2.cli.tlds:ListTLDsCommand - tld_show = designateclient.v2.cli.tlds:ShowTLDCommand - tld_set = designateclient.v2.cli.tlds:SetTLDCommand - tld_delete = designateclient.v2.cli.tlds:DeleteTLDCommand - - zone_create = designateclient.v2.cli.zones:CreateZoneCommand - zone_list = designateclient.v2.cli.zones:ListZonesCommand - zone_show = designateclient.v2.cli.zones:ShowZoneCommand - zone_set = designateclient.v2.cli.zones:SetZoneCommand - zone_delete = designateclient.v2.cli.zones:DeleteZoneCommand - - zone_abandon = designateclient.v2.cli.zones:AbandonZoneCommand - zone_axfr = designateclient.v2.cli.zones:AXFRZoneCommand - - zone_export_create = designateclient.v2.cli.zones:ExportZoneCommand - zone_export_list = designateclient.v2.cli.zones:ListZoneExportsCommand - zone_export_show = designateclient.v2.cli.zones:ShowZoneExportCommand - zone_export_delete = designateclient.v2.cli.zones:DeleteZoneExportCommand - zone_export_showfile = designateclient.v2.cli.zones:ShowZoneExportFileCommand - - zone_import_create = designateclient.v2.cli.zones:ImportZoneCommand - zone_import_list = designateclient.v2.cli.zones:ListZoneImportsCommand - zone_import_show = designateclient.v2.cli.zones:ShowZoneImportCommand - zone_import_delete = designateclient.v2.cli.zones:DeleteZoneImportCommand - - zone_transfer_request_create = designateclient.v2.cli.zones:CreateTransferRequestCommand - zone_transfer_request_list = designateclient.v2.cli.zones:ListTransferRequestsCommand - zone_transfer_request_show = designateclient.v2.cli.zones:ShowTransferRequestCommand - zone_transfer_request_set = designateclient.v2.cli.zones:SetTransferRequestCommand - zone_transfer_request_delete = designateclient.v2.cli.zones:DeleteTransferRequestCommand - zone_transfer_accept_request = designateclient.v2.cli.zones:AcceptTransferRequestCommand - zone_transfer_accept_list = designateclient.v2.cli.zones:ListTransferAcceptsCommand - zone_transfer_accept_show = designateclient.v2.cli.zones:ShowTransferAcceptCommand - - recordset_create = designateclient.v2.cli.recordsets:CreateRecordSetCommand - recordset_list = designateclient.v2.cli.recordsets:ListRecordSetsCommand - recordset_show = designateclient.v2.cli.recordsets:ShowRecordSetCommand - recordset_set = designateclient.v2.cli.recordsets:SetRecordSetCommand - recordset_delete = designateclient.v2.cli.recordsets:DeleteRecordSetCommand - - ptr_record_list = designateclient.v2.cli.reverse:ListFloatingIPCommand - ptr_record_show = designateclient.v2.cli.reverse:ShowFloatingIPCommand - ptr_record_set = designateclient.v2.cli.reverse:SetFloatingIPCommand - ptr_record_unset = designateclient.v2.cli.reverse:UnsetFloatingIPCommand - - dns_service_list = designateclient.v2.cli.service_statuses:ListServiceStatusesCommand - dns_service_show = designateclient.v2.cli.service_statuses:ShowServiceStatusCommand - - dns_quota_list = designateclient.v2.cli.quotas:ListQuotasCommand - dns_quota_set = designateclient.v2.cli.quotas:SetQuotasCommand - dns_quota_reset = designateclient.v2.cli.quotas:ResetQuotasCommand - - tsigkey_create = designateclient.v2.cli.tsigkeys:CreateTSIGKeyCommand - tsigkey_list = designateclient.v2.cli.tsigkeys:ListTSIGKeysCommand - tsigkey_show = designateclient.v2.cli.tsigkeys:ShowTSIGKeyCommand - tsigkey_set = designateclient.v2.cli.tsigkeys:SetTSIGKeyCommand - tsigkey_delete = designateclient.v2.cli.tsigkeys:DeleteTSIGKeyCommand + hostcert_create = tatuclient.v2.cli.hostcert:CreateHostCertCommand + hostcert_list = tatuclient.v2.cli.hostcert:ListHostCertsCommand + hostcert_show = tatuclient.v2.cli.hostcert:ShowHostCertCommand + hostcert_revoke = tatuclient.v2.cli.hostcert:RevokeHostCertCommand + hostcert_delete = tatuclient.v2.cli.hostcert:DeleteHostCertCommand + sshca_create = tatuclient.v2.cli.ca:CreateCACommand + sshca_list = tatuclient.v2.cli.ca:ListCAsCommand + sshca_show = tatuclient.v2.cli.ca:ShowCACommand + sshca_delete = tatuclient.v2.cli.ca:DeleteCACommand [build_sphinx] builders = html,man @@ -167,18 +68,18 @@ tag_date = 0 tag_svn_revision = 0 [compile_catalog] -directory = designateclient/locale -domain = designateclient +directory = tatuclient/locale +domain = tatuclient [update_catalog] -domain = designateclient -output_dir = designateclient/locale -input_file = designateclient/locale/designateclient.pot +domain = tatuclient +output_dir = tatuclient/locale +input_file = tatuclient/locale/tatuclient.pot [extract_messages] keywords = _ gettext ngettext l_ lazy_gettext mapping_file = babel.cfg -output_file = designateclient/locale/designateclient.pot +output_file = tatuclient/locale/tatuclient.pot [wheel] universal = 1 @@ -187,5 +88,5 @@ universal = 1 autodoc_index_modules = True api_doc_dir = reference/api autodoc_exclude_modules = - designateclient.tests.* - designateclient.functionaltests.* + tatuclient.tests.* + tatuclient.functionaltests.* diff --git a/designateclient/__init__.py b/tatuclient/__init__.py similarity index 94% rename from designateclient/__init__.py rename to tatuclient/__init__.py index e775234..cf8eefe 100644 --- a/designateclient/__init__.py +++ b/tatuclient/__init__.py @@ -13,7 +13,7 @@ # under the License. # -from designateclient import version +from tatuclient import version __version__ = version.version_info.version_string() diff --git a/designateclient/client.py b/tatuclient/client.py similarity index 97% rename from designateclient/client.py rename to tatuclient/client.py index 8b7305b..6d099d5 100644 --- a/designateclient/client.py +++ b/tatuclient/client.py @@ -20,7 +20,7 @@ import six from six.moves.urllib import parse from stevedore import extension -from designateclient import exceptions +from tatuclient import exceptions @six.add_metaclass(abc.ABCMeta) @@ -122,7 +122,7 @@ class CrudController(Controller): def get_versions(): - mgr = extension.ExtensionManager('designateclient.versions') + mgr = extension.ExtensionManager('tatuclient.versions') return dict([(ep.name, ep.plugin) for ep in mgr.extensions]) diff --git a/designateclient/exceptions.py b/tatuclient/exceptions.py similarity index 100% rename from designateclient/exceptions.py rename to tatuclient/exceptions.py diff --git a/designateclient/functionaltests/__init__.py b/tatuclient/functionaltests/__init__.py similarity index 100% rename from designateclient/functionaltests/__init__.py rename to tatuclient/functionaltests/__init__.py diff --git a/designateclient/functionaltests/base.py b/tatuclient/functionaltests/base.py similarity index 93% rename from designateclient/functionaltests/base.py rename to tatuclient/functionaltests/base.py index d3e0552..4c6aeb7 100644 --- a/designateclient/functionaltests/base.py +++ b/tatuclient/functionaltests/base.py @@ -16,8 +16,8 @@ limitations under the License. from tempest.lib.cli import base from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests import client -from designateclient.functionaltests import config +from tatuclient.functionaltests import client +from tatuclient.functionaltests import config class BaseDesignateTest(base.ClientTestBase): diff --git a/designateclient/functionaltests/client.py b/tatuclient/functionaltests/client.py similarity index 98% rename from designateclient/functionaltests/client.py rename to tatuclient/functionaltests/client.py index 1f0fc03..1ae5d38 100644 --- a/designateclient/functionaltests/client.py +++ b/tatuclient/functionaltests/client.py @@ -18,9 +18,9 @@ import os from tempest.lib.cli import base -from designateclient.functionaltests.config import cfg -from designateclient.functionaltests.models import FieldValueModel -from designateclient.functionaltests.models import ListModel +from tatuclient.functionaltests.config import cfg +from tatuclient.functionaltests.models import FieldValueModel +from tatuclient.functionaltests.models import ListModel LOG = logging.getLogger(__name__) diff --git a/designateclient/functionaltests/config.py b/tatuclient/functionaltests/config.py similarity index 95% rename from designateclient/functionaltests/config.py rename to tatuclient/functionaltests/config.py index 553f25c..deab952 100644 --- a/designateclient/functionaltests/config.py +++ b/tatuclient/functionaltests/config.py @@ -23,7 +23,7 @@ cfg.CONF.register_group(cfg.OptGroup( )) cfg.CONF.register_group(cfg.OptGroup( - name='designateclient', title="Configuration for the Designate client" + name='tatuclient', title="Configuration for the Designate client" )) cfg.CONF.register_opts([ @@ -57,7 +57,7 @@ cfg.CONF.register_opts([ cfg.CONF.register_opts([ cfg.StrOpt('directory', help='the directory containing the client executable'), -], group='designateclient') +], group='tatuclient') def find_config_file(): diff --git a/designateclient/functionaltests/datagen.py b/tatuclient/functionaltests/datagen.py similarity index 100% rename from designateclient/functionaltests/datagen.py rename to tatuclient/functionaltests/datagen.py diff --git a/designateclient/functionaltests/models.py b/tatuclient/functionaltests/models.py similarity index 100% rename from designateclient/functionaltests/models.py rename to tatuclient/functionaltests/models.py diff --git a/designateclient/cli/__init__.py b/tatuclient/functionaltests/v2/__init__.py similarity index 100% rename from designateclient/cli/__init__.py rename to tatuclient/functionaltests/v2/__init__.py diff --git a/designateclient/functionaltests/v2/fixtures.py b/tatuclient/functionaltests/v2/fixtures.py similarity index 99% rename from designateclient/functionaltests/v2/fixtures.py rename to tatuclient/functionaltests/v2/fixtures.py index 8e2ff95..614b9b1 100644 --- a/designateclient/functionaltests/v2/fixtures.py +++ b/tatuclient/functionaltests/v2/fixtures.py @@ -23,7 +23,7 @@ import fixtures from tempest.lib.exceptions import CommandFailed from testtools.runtest import MultipleExceptions -from designateclient.functionaltests.client import DesignateCLI +from tatuclient.functionaltests.client import DesignateCLI class BaseFixture(fixtures.Fixture): diff --git a/designateclient/functionaltests/v2/test_blacklist.py b/tatuclient/functionaltests/v2/test_blacklist.py similarity index 94% rename from designateclient/functionaltests/v2/test_blacklist.py rename to tatuclient/functionaltests/v2/test_blacklist.py index db8c756..baa3ccd 100644 --- a/designateclient/functionaltests/v2/test_blacklist.py +++ b/tatuclient/functionaltests/v2/test_blacklist.py @@ -15,9 +15,9 @@ limitations under the License. """ from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_blacklist -from designateclient.functionaltests.v2.fixtures import BlacklistFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_blacklist +from tatuclient.functionaltests.v2.fixtures import BlacklistFixture class TestBlacklist(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_recordsets.py b/tatuclient/functionaltests/v2/test_recordsets.py similarity index 91% rename from designateclient/functionaltests/v2/test_recordsets.py rename to tatuclient/functionaltests/v2/test_recordsets.py index c9ab529..cf33b46 100644 --- a/designateclient/functionaltests/v2/test_recordsets.py +++ b/tatuclient/functionaltests/v2/test_recordsets.py @@ -15,11 +15,11 @@ limitations under the License. """ from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_a_recordset_name -from designateclient.functionaltests.datagen import random_zone_name -from designateclient.functionaltests.v2.fixtures import RecordsetFixture -from designateclient.functionaltests.v2.fixtures import ZoneFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_a_recordset_name +from tatuclient.functionaltests.datagen import random_zone_name +from tatuclient.functionaltests.v2.fixtures import RecordsetFixture +from tatuclient.functionaltests.v2.fixtures import ZoneFixture class TestRecordset(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_tlds.py b/tatuclient/functionaltests/v2/test_tlds.py similarity index 93% rename from designateclient/functionaltests/v2/test_tlds.py rename to tatuclient/functionaltests/v2/test_tlds.py index 402dffc..d463b48 100644 --- a/designateclient/functionaltests/v2/test_tlds.py +++ b/tatuclient/functionaltests/v2/test_tlds.py @@ -15,9 +15,9 @@ limitations under the License. """ from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_tld -from designateclient.functionaltests.v2.fixtures import TLDFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_tld +from tatuclient.functionaltests.v2.fixtures import TLDFixture class TestTld(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_tsigkeys.py b/tatuclient/functionaltests/v2/test_tsigkeys.py similarity index 88% rename from designateclient/functionaltests/v2/test_tsigkeys.py rename to tatuclient/functionaltests/v2/test_tsigkeys.py index 7ed4d75..8f58f9c 100644 --- a/designateclient/functionaltests/v2/test_tsigkeys.py +++ b/tatuclient/functionaltests/v2/test_tsigkeys.py @@ -15,12 +15,12 @@ limitations under the License. """ from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_tsigkey_name -from designateclient.functionaltests.datagen import random_tsigkey_secret -from designateclient.functionaltests.datagen import random_zone_name -from designateclient.functionaltests.v2.fixtures import TSIGKeyFixture -from designateclient.functionaltests.v2.fixtures import ZoneFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_tsigkey_name +from tatuclient.functionaltests.datagen import random_tsigkey_secret +from tatuclient.functionaltests.datagen import random_zone_name +from tatuclient.functionaltests.v2.fixtures import TSIGKeyFixture +from tatuclient.functionaltests.v2.fixtures import ZoneFixture class TestTSIGKey(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_zone.py b/tatuclient/functionaltests/v2/test_zone.py similarity index 95% rename from designateclient/functionaltests/v2/test_zone.py rename to tatuclient/functionaltests/v2/test_zone.py index 4f1b803..cb3f3e3 100644 --- a/designateclient/functionaltests/v2/test_zone.py +++ b/tatuclient/functionaltests/v2/test_zone.py @@ -15,9 +15,9 @@ limitations under the License. """ from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_zone_name -from designateclient.functionaltests.v2.fixtures import ZoneFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_zone_name +from tatuclient.functionaltests.v2.fixtures import ZoneFixture class TestZone(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_zone_export.py b/tatuclient/functionaltests/v2/test_zone_export.py similarity index 90% rename from designateclient/functionaltests/v2/test_zone_export.py rename to tatuclient/functionaltests/v2/test_zone_export.py index 6052a99..ff977e9 100644 --- a/designateclient/functionaltests/v2/test_zone_export.py +++ b/tatuclient/functionaltests/v2/test_zone_export.py @@ -15,10 +15,10 @@ 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 designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_zone_name -from designateclient.functionaltests.v2.fixtures import ExportFixture -from designateclient.functionaltests.v2.fixtures import ZoneFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_zone_name +from tatuclient.functionaltests.v2.fixtures import ExportFixture +from tatuclient.functionaltests.v2.fixtures import ZoneFixture class TestZoneExport(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_zone_import.py b/tatuclient/functionaltests/v2/test_zone_import.py similarity index 91% rename from designateclient/functionaltests/v2/test_zone_import.py rename to tatuclient/functionaltests/v2/test_zone_import.py index 51c9906..3de818a 100644 --- a/designateclient/functionaltests/v2/test_zone_import.py +++ b/tatuclient/functionaltests/v2/test_zone_import.py @@ -15,9 +15,9 @@ 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 designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.datagen import random_zone_file -from designateclient.functionaltests.v2.fixtures import ImportFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.datagen import random_zone_file +from tatuclient.functionaltests.v2.fixtures import ImportFixture class TestZoneImport(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/test_zone_transfer.py b/tatuclient/functionaltests/v2/test_zone_transfer.py similarity index 92% rename from designateclient/functionaltests/v2/test_zone_transfer.py rename to tatuclient/functionaltests/v2/test_zone_transfer.py index 33cbbc0..de906fa 100644 --- a/designateclient/functionaltests/v2/test_zone_transfer.py +++ b/tatuclient/functionaltests/v2/test_zone_transfer.py @@ -17,11 +17,11 @@ import unittest from tempest.lib.exceptions import CommandFailed -from designateclient.functionaltests.base import BaseDesignateTest -from designateclient.functionaltests.client import DesignateCLI -from designateclient.functionaltests.datagen import random_zone_name -from designateclient.functionaltests.v2.fixtures import TransferRequestFixture -from designateclient.functionaltests.v2.fixtures import ZoneFixture +from tatuclient.functionaltests.base import BaseDesignateTest +from tatuclient.functionaltests.client import DesignateCLI +from tatuclient.functionaltests.datagen import random_zone_name +from tatuclient.functionaltests.v2.fixtures import TransferRequestFixture +from tatuclient.functionaltests.v2.fixtures import ZoneFixture class TestZoneTransferRequest(BaseDesignateTest): diff --git a/designateclient/functionaltests/v2/__init__.py b/tatuclient/osc/__init__.py similarity index 100% rename from designateclient/functionaltests/v2/__init__.py rename to tatuclient/osc/__init__.py diff --git a/designateclient/osc/plugin.py b/tatuclient/osc/plugin.py similarity index 75% rename from designateclient/osc/plugin.py rename to tatuclient/osc/plugin.py index eeeae7a..d0b19a0 100644 --- a/designateclient/osc/plugin.py +++ b/tatuclient/osc/plugin.py @@ -14,19 +14,19 @@ # License for the specific language governing permissions and limitations # under the License. -"""OpenStackClient plugin for DNS service.""" +"""OpenStackClient plugin for SSH service.""" from osc_lib import utils as oscutils -from designateclient import shell +from tatuclient import shell DEFAULT_API_VERSION = '2' -API_NAME = 'dns' -API_VERSION_OPTION = 'os_dns_api_version' +API_NAME = 'ssh' +API_VERSION_OPTION = 'os_ssh_api_version' API_VERSIONS = { - '2': 'designateclient.v2.client.Client', + '1': 'tatuclient.v2.client.Client', } @@ -43,11 +43,11 @@ def make_client(instance): def build_option_parser(parser): """Hook to add global options.""" parser.add_argument( - '--os-dns-api-version', - metavar='', - default=shell.env('OS_DNS_API_VERSION', default="2"), - help='DNS API version, default=' + + '--os-ssh-api-version', + metavar='', + default=shell.env('OS_SSH_API_VERSION', default="1"), + help='SSH API version, default=' + DEFAULT_API_VERSION + - ' (Env: OS_DNS_API_VERSION)') + ' (Env: OS_SSH_API_VERSION)') return parser diff --git a/designateclient/shell.py b/tatuclient/shell.py similarity index 98% rename from designateclient/shell.py rename to tatuclient/shell.py index dcd4f06..88b4b1b 100644 --- a/designateclient/shell.py +++ b/tatuclient/shell.py @@ -21,8 +21,8 @@ import traceback from cliff.app import App from cliff.commandmanager import CommandManager -from designateclient import utils -from designateclient.version import version_info as version +from tatuclient import utils +from tatuclient.version import version_info as version def env(*vars, **kwargs): @@ -47,7 +47,7 @@ class DesignateShell(App): super(DesignateShell, self).__init__( description='Designate Client', version=version.version_string(), - command_manager=CommandManager('designateclient.cli'), + command_manager=CommandManager('tatuclient.cli'), ) self.log = logging.getLogger(__name__) diff --git a/designateclient/osc/__init__.py b/tatuclient/tests/__init__.py similarity index 100% rename from designateclient/osc/__init__.py rename to tatuclient/tests/__init__.py diff --git a/designateclient/tests/base.py b/tatuclient/tests/base.py similarity index 98% rename from designateclient/tests/base.py rename to tatuclient/tests/base.py index e006861..2ce93b6 100644 --- a/designateclient/tests/base.py +++ b/tatuclient/tests/base.py @@ -22,8 +22,8 @@ from requests_mock.contrib import fixture as req_fixture import six from six.moves.urllib import parse as urlparse -from designateclient import client -from designateclient.utils import AdapterWithTimeout +from tatuclient import client +from tatuclient.utils import AdapterWithTimeout _TRUE_VALUES = ('True', 'true', '1', 'yes') diff --git a/designateclient/tests/test_designateclient.py b/tatuclient/tests/test_designateclient.py similarity index 80% rename from designateclient/tests/test_designateclient.py rename to tatuclient/tests/test_designateclient.py index 2998d69..d08214d 100644 --- a/designateclient/tests/test_designateclient.py +++ b/tatuclient/tests/test_designateclient.py @@ -14,14 +14,14 @@ test_designateclient ---------------------------------- -Tests for `designateclient` module. +Tests for `tatuclient` module. """ -import designateclient -from designateclient.tests import base +import tatuclient +from tatuclient.tests import base class ClientTestCase(base.TestCase): def test_module_version(self): - self.assertTrue(hasattr(designateclient, '__version__')) + self.assertTrue(hasattr(tatuclient, '__version__')) diff --git a/designateclient/tests/test_exceptions.py b/tatuclient/tests/test_exceptions.py similarity index 96% rename from designateclient/tests/test_exceptions.py rename to tatuclient/tests/test_exceptions.py index e016991..a3ce867 100644 --- a/designateclient/tests/test_exceptions.py +++ b/tatuclient/tests/test_exceptions.py @@ -14,8 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -from designateclient import exceptions -from designateclient.tests import base +from tatuclient import exceptions +from tatuclient.tests import base class RemoteErrorTestCase(base.TestCase): diff --git a/designateclient/tests/test_utils.py b/tatuclient/tests/test_utils.py similarity index 96% rename from designateclient/tests/test_utils.py rename to tatuclient/tests/test_utils.py index e4fa7b0..2d10759 100644 --- a/designateclient/tests/test_utils.py +++ b/tatuclient/tests/test_utils.py @@ -16,9 +16,9 @@ import uuid import mock -from designateclient import exceptions -from designateclient.tests import base -from designateclient import utils +from tatuclient import exceptions +from tatuclient.tests import base +from tatuclient import utils LIST_MOCK_RESPONSE = [ diff --git a/designateclient/tests/v2/__init__.py b/tatuclient/tests/v2/__init__.py similarity index 97% rename from designateclient/tests/v2/__init__.py rename to tatuclient/tests/v2/__init__.py index f870d15..a29352f 100644 --- a/designateclient/tests/v2/__init__.py +++ b/tatuclient/tests/v2/__init__.py @@ -15,7 +15,7 @@ # under the License. import uuid -from designateclient.tests import base +from tatuclient.tests import base class CrudMixin(object): diff --git a/designateclient/tests/v2/test_blacklists.py b/tatuclient/tests/v2/test_blacklists.py similarity index 98% rename from designateclient/tests/v2/test_blacklists.py rename to tatuclient/tests/v2/test_blacklists.py index df1ceb5..6a3b353 100644 --- a/designateclient/tests/v2/test_blacklists.py +++ b/tatuclient/tests/v2/test_blacklists.py @@ -15,7 +15,7 @@ # under the License. import uuid -from designateclient.tests import v2 +from tatuclient.tests import v2 class TestBlacklists(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/tests/v2/test_client.py b/tatuclient/tests/v2/test_client.py similarity index 94% rename from designateclient/tests/v2/test_client.py rename to tatuclient/tests/v2/test_client.py index e3ae683..836919e 100644 --- a/designateclient/tests/v2/test_client.py +++ b/tatuclient/tests/v2/test_client.py @@ -17,8 +17,8 @@ from keystoneauth1 import adapter from keystoneauth1 import session as keystone_session -from designateclient.tests.base import TestCase -from designateclient.v2.client import Client +from tatuclient.tests.base import TestCase +from tatuclient.v2.client import Client class TestClient(TestCase): diff --git a/designateclient/tests/v2/test_limits.py b/tatuclient/tests/v2/test_limits.py similarity index 96% rename from designateclient/tests/v2/test_limits.py rename to tatuclient/tests/v2/test_limits.py index 32aa46b..71dd14d 100644 --- a/designateclient/tests/v2/test_limits.py +++ b/tatuclient/tests/v2/test_limits.py @@ -13,7 +13,7 @@ # 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 designateclient.tests import v2 +from tatuclient.tests import v2 class TestLimits(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/tests/v2/test_nameservers.py b/tatuclient/tests/v2/test_nameservers.py similarity index 94% rename from designateclient/tests/v2/test_nameservers.py rename to tatuclient/tests/v2/test_nameservers.py index 5ecde20..f61c502 100644 --- a/designateclient/tests/v2/test_nameservers.py +++ b/tatuclient/tests/v2/test_nameservers.py @@ -15,8 +15,8 @@ # under the License. from mock import patch -from designateclient.tests import v2 -from designateclient.v2 import zones +from tatuclient.tests import v2 +from tatuclient.v2 import zones class TestLimits(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/tests/v2/test_recordsets.py b/tatuclient/tests/v2/test_recordsets.py similarity index 98% rename from designateclient/tests/v2/test_recordsets.py rename to tatuclient/tests/v2/test_recordsets.py index 4452396..62cde35 100644 --- a/designateclient/tests/v2/test_recordsets.py +++ b/tatuclient/tests/v2/test_recordsets.py @@ -18,9 +18,9 @@ import uuid from mock import patch import testtools -from designateclient import exceptions -from designateclient.tests import v2 -from designateclient.v2 import zones +from tatuclient import exceptions +from tatuclient.tests import v2 +from tatuclient.v2 import zones ZONE = { "id": str(uuid.uuid4()), diff --git a/designateclient/tests/v2/test_reverse.py b/tatuclient/tests/v2/test_reverse.py similarity index 97% rename from designateclient/tests/v2/test_reverse.py rename to tatuclient/tests/v2/test_reverse.py index a303f07..e313367 100644 --- a/designateclient/tests/v2/test_reverse.py +++ b/tatuclient/tests/v2/test_reverse.py @@ -15,7 +15,7 @@ # under the License. import uuid -from designateclient.tests import v2 +from tatuclient.tests import v2 FIP_ID = '%s:%s' % (str(uuid.uuid4()), "RegionOne") diff --git a/designateclient/tests/v2/test_service_statuses.py b/tatuclient/tests/v2/test_service_statuses.py similarity index 97% rename from designateclient/tests/v2/test_service_statuses.py rename to tatuclient/tests/v2/test_service_statuses.py index 9dd571d..5e05d6c 100644 --- a/designateclient/tests/v2/test_service_statuses.py +++ b/tatuclient/tests/v2/test_service_statuses.py @@ -13,7 +13,7 @@ # 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 designateclient.tests import v2 +from tatuclient.tests import v2 class TestServiceStatuses(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/tests/v2/test_timeout.py b/tatuclient/tests/v2/test_timeout.py similarity index 97% rename from designateclient/tests/v2/test_timeout.py rename to tatuclient/tests/v2/test_timeout.py index a5f4d52..db66f2c 100644 --- a/designateclient/tests/v2/test_timeout.py +++ b/tatuclient/tests/v2/test_timeout.py @@ -18,8 +18,8 @@ from keystoneauth1.identity import generic from keystoneauth1 import session as keystone_session from mock import Mock -from designateclient.tests import v2 -from designateclient.v2.client import Client +from tatuclient.tests import v2 +from tatuclient.v2.client import Client def create_session(timeout=None): diff --git a/designateclient/tests/v2/test_tlds.py b/tatuclient/tests/v2/test_tlds.py similarity index 98% rename from designateclient/tests/v2/test_tlds.py rename to tatuclient/tests/v2/test_tlds.py index 080e8fe..addc60b 100644 --- a/designateclient/tests/v2/test_tlds.py +++ b/tatuclient/tests/v2/test_tlds.py @@ -15,7 +15,7 @@ # under the License. import uuid -from designateclient.tests import v2 +from tatuclient.tests import v2 class TestTlds(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/tests/v2/test_tsigkeys.py b/tatuclient/tests/v2/test_tsigkeys.py similarity index 98% rename from designateclient/tests/v2/test_tsigkeys.py rename to tatuclient/tests/v2/test_tsigkeys.py index 6290ffa..a643173 100644 --- a/designateclient/tests/v2/test_tsigkeys.py +++ b/tatuclient/tests/v2/test_tsigkeys.py @@ -15,7 +15,7 @@ # under the License. import uuid -from designateclient.tests import v2 +from tatuclient.tests import v2 class TestTSIGKeys(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/tests/v2/test_zones.py b/tatuclient/tests/v2/test_zones.py similarity index 99% rename from designateclient/tests/v2/test_zones.py rename to tatuclient/tests/v2/test_zones.py index 5470be7..2410623 100644 --- a/designateclient/tests/v2/test_zones.py +++ b/tatuclient/tests/v2/test_zones.py @@ -16,7 +16,7 @@ import time import uuid -from designateclient.tests import v2 +from tatuclient.tests import v2 class TestZones(v2.APIV2TestCase, v2.CrudMixin): diff --git a/designateclient/utils.py b/tatuclient/utils.py similarity index 98% rename from designateclient/utils.py rename to tatuclient/utils.py index ff81f9b..7faa6e4 100644 --- a/designateclient/utils.py +++ b/tatuclient/utils.py @@ -26,7 +26,7 @@ from keystoneauth1 import token_endpoint import pkg_resources import six -from designateclient import exceptions +from tatuclient import exceptions def resource_string(*args, **kwargs): @@ -36,7 +36,7 @@ def resource_string(*args, **kwargs): package = kwargs.pop('package', None) if not package: - package = 'designateclient' + package = 'tatuclient' resource_path = os.path.join('resources', *args) diff --git a/designateclient/tests/__init__.py b/tatuclient/v2/__init__.py similarity index 100% rename from designateclient/tests/__init__.py rename to tatuclient/v2/__init__.py diff --git a/designateclient/v2/base.py b/tatuclient/v2/base.py similarity index 93% rename from designateclient/v2/base.py rename to tatuclient/v2/base.py index 1700c82..b23bbbb 100644 --- a/designateclient/v2/base.py +++ b/tatuclient/v2/base.py @@ -14,8 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -from designateclient import client -from designateclient.v2.utils import parse_query_from_url +from tatuclient import client +from tatuclient.v2.utils import parse_query_from_url class DesignateList(list): diff --git a/designateclient/v2/recordsets.py b/tatuclient/v2/ca.py similarity index 97% rename from designateclient/v2/recordsets.py rename to tatuclient/v2/ca.py index 188148c..2d3fd18 100644 --- a/designateclient/v2/recordsets.py +++ b/tatuclient/v2/ca.py @@ -16,8 +16,8 @@ from oslo_utils import uuidutils import six -from designateclient.v2.base import V2Controller -from designateclient.v2 import utils as v2_utils +from tatuclient.v2.base import V2Controller +from tatuclient.v2 import utils as v2_utils class RecordSetController(V2Controller): diff --git a/designateclient/v2/__init__.py b/tatuclient/v2/cli/__init__.py similarity index 100% rename from designateclient/v2/__init__.py rename to tatuclient/v2/cli/__init__.py diff --git a/designateclient/v2/cli/recordsets.py b/tatuclient/v2/cli/ca.py similarity index 98% rename from designateclient/v2/cli/recordsets.py rename to tatuclient/v2/cli/ca.py index 898da19..3926556 100644 --- a/designateclient/v2/cli/recordsets.py +++ b/tatuclient/v2/cli/ca.py @@ -20,9 +20,9 @@ import logging from osc_lib.command import command import six -from designateclient import utils -from designateclient.v2.cli import common -from designateclient.v2.utils import get_all +from tatuclient import utils +from tatuclient.v2.cli import common +from tatuclient.v2.utils import get_all LOG = logging.getLogger(__name__) diff --git a/designateclient/v2/cli/common.py b/tatuclient/v2/cli/common.py similarity index 100% rename from designateclient/v2/cli/common.py rename to tatuclient/v2/cli/common.py diff --git a/tatuclient/v2/cli/hostcert.py b/tatuclient/v2/cli/hostcert.py new file mode 100644 index 0000000..3926556 --- /dev/null +++ b/tatuclient/v2/cli/hostcert.py @@ -0,0 +1,260 @@ +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# 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. + +import argparse +import logging + +from osc_lib.command import command +import six + +from tatuclient import utils +from tatuclient.v2.cli import common +from tatuclient.v2.utils import get_all + + +LOG = logging.getLogger(__name__) + + +def _format_recordset(recordset): + # Remove unneeded fields for display output formatting + recordset['records'] = "\n".join(recordset['records']) + recordset.pop('links', None) + return recordset + + +def _has_project_id(data): + if len(data) < 1: + return False + if 'project_id' in data[0]: + return True + return False + + +class ListRecordSetsCommand(command.Lister): + """List recordsets""" + + columns = ['id', 'name', 'type', 'records', 'status', 'action'] + + def get_parser(self, prog_name): + parser = super(ListRecordSetsCommand, self).get_parser(prog_name) + + parser.add_argument('--name', help="RecordSet Name", required=False) + parser.add_argument('--type', help="RecordSet Type", required=False) + parser.add_argument('--data', help="RecordSet Record Data", + required=False) + parser.add_argument('--ttl', help="Time To Live (Seconds)", + required=False) + parser.add_argument('--description', help="Description", + required=False) + parser.add_argument('--status', help="RecordSet Status", + required=False) + parser.add_argument('--action', help="RecordSet Action", + required=False) + + parser.add_argument('zone_id', help="Zone ID. To list all" + " recordsets specify 'all'") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + criterion = {} + if parsed_args.type is not None: + criterion["type"] = parsed_args.type + + if parsed_args.name is not None: + criterion["name"] = parsed_args.name + + if parsed_args.data is not None: + criterion["data"] = parsed_args.data + + if parsed_args.ttl is not None: + criterion["ttl"] = parsed_args.ttl + + if parsed_args.description is not None: + criterion["description"] = parsed_args.description + + if parsed_args.status is not None: + criterion["status"] = parsed_args.status + + if parsed_args.action is not None: + criterion["action"] = parsed_args.action + + cols = self.columns + + if parsed_args.zone_id == 'all': + data = get_all(client.recordsets.list_all_zones, + criterion=criterion) + cols.insert(2, 'zone_name') + else: + data = get_all(client.recordsets.list, args=[parsed_args.zone_id], + criterion=criterion) + + if client.session.all_projects and _has_project_id(data): + cols.insert(1, 'project_id') + + for i, rs in enumerate(data): + data[i] = _format_recordset(rs) + + return cols, (utils.get_item_properties(s, cols) for s in data) + + +class ShowRecordSetCommand(command.ShowOne): + """Show recordset details""" + + def get_parser(self, prog_name): + parser = super(ShowRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('id', help="RecordSet ID") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + data = client.recordsets.get(parsed_args.zone_id, parsed_args.id) + + _format_recordset(data) + return six.moves.zip(*sorted(six.iteritems(data))) + + +class CreateRecordSetCommand(command.ShowOne): + """Create new recordset""" + + log = logging.getLogger('deprecated') + + def get_parser(self, prog_name): + parser = super(CreateRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('name', help="RecordSet Name") + req_group = parser.add_mutually_exclusive_group(required=True) + req_group.add_argument( + '--records', + help=argparse.SUPPRESS, + nargs='+') + req_group.add_argument( + '--record', + help="RecordSet Record, repeat if necessary", + action='append') + parser.add_argument('--type', help="RecordSet Type", required=True) + parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)") + parser.add_argument('--description', help="Description") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + all_records = parsed_args.record or parsed_args.records + if parsed_args.records: + self.log.warning( + "Option --records is deprecated, use --record instead.") + data = client.recordsets.create( + parsed_args.zone_id, + parsed_args.name, + parsed_args.type, + all_records, + description=parsed_args.description, + ttl=parsed_args.ttl) + + _format_recordset(data) + return six.moves.zip(*sorted(six.iteritems(data))) + + +class SetRecordSetCommand(command.ShowOne): + """Set recordset properties""" + + def get_parser(self, prog_name): + parser = super(SetRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('id', help="RecordSet ID") + parser.add_argument('--records', help="Records", nargs='+') + + description_group = parser.add_mutually_exclusive_group() + description_group.add_argument('--description', help="Description") + description_group.add_argument('--no-description', action='store_true') + + ttl_group = parser.add_mutually_exclusive_group() + ttl_group.add_argument('--ttl', type=int, help="TTL") + ttl_group.add_argument('--no-ttl', action='store_true') + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + data = {} + + if parsed_args.no_description: + data['description'] = None + elif parsed_args.description: + data['description'] = parsed_args.description + + if parsed_args.no_ttl: + data['ttl'] = None + elif parsed_args.ttl: + data['ttl'] = parsed_args.ttl + + if parsed_args.records: + data['records'] = parsed_args.records + + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + updated = client.recordsets.update( + parsed_args.zone_id, + parsed_args.id, + data) + + _format_recordset(updated) + + return six.moves.zip(*sorted(six.iteritems(updated))) + + +class DeleteRecordSetCommand(command.ShowOne): + """Delete recordset""" + + def get_parser(self, prog_name): + parser = super(DeleteRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('id', help="RecordSet ID") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + data = client.recordsets.delete(parsed_args.zone_id, parsed_args.id) + + LOG.info('RecordSet %s was deleted', parsed_args.id) + + _format_recordset(data) + return six.moves.zip(*sorted(six.iteritems(data))) diff --git a/tatuclient/v2/cli/usercert.py b/tatuclient/v2/cli/usercert.py new file mode 100644 index 0000000..3926556 --- /dev/null +++ b/tatuclient/v2/cli/usercert.py @@ -0,0 +1,260 @@ +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# 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. + +import argparse +import logging + +from osc_lib.command import command +import six + +from tatuclient import utils +from tatuclient.v2.cli import common +from tatuclient.v2.utils import get_all + + +LOG = logging.getLogger(__name__) + + +def _format_recordset(recordset): + # Remove unneeded fields for display output formatting + recordset['records'] = "\n".join(recordset['records']) + recordset.pop('links', None) + return recordset + + +def _has_project_id(data): + if len(data) < 1: + return False + if 'project_id' in data[0]: + return True + return False + + +class ListRecordSetsCommand(command.Lister): + """List recordsets""" + + columns = ['id', 'name', 'type', 'records', 'status', 'action'] + + def get_parser(self, prog_name): + parser = super(ListRecordSetsCommand, self).get_parser(prog_name) + + parser.add_argument('--name', help="RecordSet Name", required=False) + parser.add_argument('--type', help="RecordSet Type", required=False) + parser.add_argument('--data', help="RecordSet Record Data", + required=False) + parser.add_argument('--ttl', help="Time To Live (Seconds)", + required=False) + parser.add_argument('--description', help="Description", + required=False) + parser.add_argument('--status', help="RecordSet Status", + required=False) + parser.add_argument('--action', help="RecordSet Action", + required=False) + + parser.add_argument('zone_id', help="Zone ID. To list all" + " recordsets specify 'all'") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + criterion = {} + if parsed_args.type is not None: + criterion["type"] = parsed_args.type + + if parsed_args.name is not None: + criterion["name"] = parsed_args.name + + if parsed_args.data is not None: + criterion["data"] = parsed_args.data + + if parsed_args.ttl is not None: + criterion["ttl"] = parsed_args.ttl + + if parsed_args.description is not None: + criterion["description"] = parsed_args.description + + if parsed_args.status is not None: + criterion["status"] = parsed_args.status + + if parsed_args.action is not None: + criterion["action"] = parsed_args.action + + cols = self.columns + + if parsed_args.zone_id == 'all': + data = get_all(client.recordsets.list_all_zones, + criterion=criterion) + cols.insert(2, 'zone_name') + else: + data = get_all(client.recordsets.list, args=[parsed_args.zone_id], + criterion=criterion) + + if client.session.all_projects and _has_project_id(data): + cols.insert(1, 'project_id') + + for i, rs in enumerate(data): + data[i] = _format_recordset(rs) + + return cols, (utils.get_item_properties(s, cols) for s in data) + + +class ShowRecordSetCommand(command.ShowOne): + """Show recordset details""" + + def get_parser(self, prog_name): + parser = super(ShowRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('id', help="RecordSet ID") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + data = client.recordsets.get(parsed_args.zone_id, parsed_args.id) + + _format_recordset(data) + return six.moves.zip(*sorted(six.iteritems(data))) + + +class CreateRecordSetCommand(command.ShowOne): + """Create new recordset""" + + log = logging.getLogger('deprecated') + + def get_parser(self, prog_name): + parser = super(CreateRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('name', help="RecordSet Name") + req_group = parser.add_mutually_exclusive_group(required=True) + req_group.add_argument( + '--records', + help=argparse.SUPPRESS, + nargs='+') + req_group.add_argument( + '--record', + help="RecordSet Record, repeat if necessary", + action='append') + parser.add_argument('--type', help="RecordSet Type", required=True) + parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)") + parser.add_argument('--description', help="Description") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + all_records = parsed_args.record or parsed_args.records + if parsed_args.records: + self.log.warning( + "Option --records is deprecated, use --record instead.") + data = client.recordsets.create( + parsed_args.zone_id, + parsed_args.name, + parsed_args.type, + all_records, + description=parsed_args.description, + ttl=parsed_args.ttl) + + _format_recordset(data) + return six.moves.zip(*sorted(six.iteritems(data))) + + +class SetRecordSetCommand(command.ShowOne): + """Set recordset properties""" + + def get_parser(self, prog_name): + parser = super(SetRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('id', help="RecordSet ID") + parser.add_argument('--records', help="Records", nargs='+') + + description_group = parser.add_mutually_exclusive_group() + description_group.add_argument('--description', help="Description") + description_group.add_argument('--no-description', action='store_true') + + ttl_group = parser.add_mutually_exclusive_group() + ttl_group.add_argument('--ttl', type=int, help="TTL") + ttl_group.add_argument('--no-ttl', action='store_true') + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + data = {} + + if parsed_args.no_description: + data['description'] = None + elif parsed_args.description: + data['description'] = parsed_args.description + + if parsed_args.no_ttl: + data['ttl'] = None + elif parsed_args.ttl: + data['ttl'] = parsed_args.ttl + + if parsed_args.records: + data['records'] = parsed_args.records + + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + updated = client.recordsets.update( + parsed_args.zone_id, + parsed_args.id, + data) + + _format_recordset(updated) + + return six.moves.zip(*sorted(six.iteritems(updated))) + + +class DeleteRecordSetCommand(command.ShowOne): + """Delete recordset""" + + def get_parser(self, prog_name): + parser = super(DeleteRecordSetCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('id', help="RecordSet ID") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + data = client.recordsets.delete(parsed_args.zone_id, parsed_args.id) + + LOG.info('RecordSet %s was deleted', parsed_args.id) + + _format_recordset(data) + return six.moves.zip(*sorted(six.iteritems(data))) diff --git a/designateclient/v2/client.py b/tatuclient/v2/client.py similarity index 62% rename from designateclient/v2/client.py rename to tatuclient/v2/client.py index b9a42af..7a79409 100644 --- a/designateclient/v2/client.py +++ b/tatuclient/v2/client.py @@ -15,29 +15,18 @@ # under the License. from keystoneauth1 import adapter -from designateclient import exceptions -from designateclient.v2.blacklists import BlacklistController -from designateclient.v2.limits import LimitController -from designateclient.v2.nameservers import NameServerController -from designateclient.v2.pools import PoolController -from designateclient.v2.quotas import QuotasController -from designateclient.v2.recordsets import RecordSetController -from designateclient.v2.reverse import FloatingIPController -from designateclient.v2.service_statuses import ServiceStatusesController -from designateclient.v2.tlds import TLDController -from designateclient.v2.tsigkeys import TSIGKeysController -from designateclient.v2.zones import ZoneController -from designateclient.v2.zones import ZoneExportsController -from designateclient.v2.zones import ZoneImportsController -from designateclient.v2.zones import ZoneTransfersController -from designateclient import version +from tatuclient import exceptions +from tatuclient.v2.ca import CAController +from tatuclient.v2.hostcert import HostCeretController +from tatuclient.v2.usercert import UserCeretController +from tatuclient import version -class DesignateAdapter(adapter.LegacyJsonAdapter): +class TatuAdapter(adapter.LegacyJsonAdapter): """Adapter around LegacyJsonAdapter. The user can pass a timeout keyword that will apply only to - the Designate Client, in order: + the Tatu Client, in order: - timeout keyword passed to ``request()`` - timeout attribute on keystone session @@ -63,12 +52,6 @@ class DesignateAdapter(adapter.LegacyJsonAdapter): str(self.all_projects) ) - if self.edit_managed: - kwargs['headers'].setdefault( - 'X-Designate-Edit-Managed-Records', - str(self.edit_managed) - ) - if self.sudo_project_id is not None: kwargs['headers'].setdefault( 'X-Auth-Sudo-Project-ID', @@ -104,39 +87,27 @@ class DesignateAdapter(adapter.LegacyJsonAdapter): class Client(object): def __init__(self, region_name=None, endpoint_type='publicURL', - extensions=None, service_type='dns', service_name=None, + extensions=None, service_type='ssh', service_name=None, http_log_debug=False, session=None, auth=None, timeout=None, endpoint_override=None, all_projects=False, - edit_managed=False, sudo_project_id=None): + sudo_project_id=None): if session is None: raise ValueError("A session instance is required") - self.session = DesignateAdapter( + self.session = TatuAdapter( session, auth=auth, region_name=region_name, service_type=service_type, interface=endpoint_type.rstrip('URL'), - user_agent='python-designateclient-%s' % version.version_info, + user_agent='python-tatuclient-%s' % version.version_info, version=('2'), endpoint_override=endpoint_override, timeout=timeout, all_projects=all_projects, - edit_managed=edit_managed, sudo_project_id=sudo_project_id ) - self.blacklists = BlacklistController(self) - self.floatingips = FloatingIPController(self) - self.limits = LimitController(self) - self.nameservers = NameServerController(self) - self.recordsets = RecordSetController(self) - self.service_statuses = ServiceStatusesController(self) - self.tlds = TLDController(self) - self.zones = ZoneController(self) - self.zone_transfers = ZoneTransfersController(self) - self.zone_exports = ZoneExportsController(self) - self.zone_imports = ZoneImportsController(self) - self.pools = PoolController(self) - self.quotas = QuotasController(self) - self.tsigkeys = TSIGKeysController(self) + self.ca = CAController(self) + self.hostcert = HostCeretController(self) + self.usercert = UserCertController(self) diff --git a/tatuclient/v2/hostcert.py b/tatuclient/v2/hostcert.py new file mode 100644 index 0000000..2d3fd18 --- /dev/null +++ b/tatuclient/v2/hostcert.py @@ -0,0 +1,106 @@ +# Copyright 2015 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# 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 oslo_utils import uuidutils +import six + +from tatuclient.v2.base import V2Controller +from tatuclient.v2 import utils as v2_utils + + +class RecordSetController(V2Controller): + def _canonicalize_record_name(self, zone, name): + zone_info = None + + # If we get a zone name we'll need to get the ID of it before POST. + if isinstance(zone, six.string_types) and not \ + uuidutils.is_uuid_like(zone): + zone_info = self.client.zones.get(zone) + elif isinstance(zone, dict): + zone_info = zone + + # We where given a name like "www" vs www.i.io., attempt to fix it on + # the behalf of the actor. + if not name.endswith("."): + if not isinstance(zone_info, dict): + zone_info = self.client.zones.get(zone) + + name = "%s.%s" % (name, zone_info["name"]) + + return name, zone_info + + def create(self, zone, name, type_, records, description=None, + ttl=None): + name, zone_info = self._canonicalize_record_name(zone, name) + + data = { + 'name': name, + 'type': type_, + 'records': records + } + + if ttl is not None: + data['ttl'] = ttl + + if description is not None: + data['description'] = description + + if zone_info is not None: + zone_id = zone_info["id"] + else: + zone_id = zone + + url = '/zones/%s/recordsets' % zone_id + return self._post(url, data=data) + + def list(self, zone, criterion=None, marker=None, limit=None): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + + url = self.build_url( + '/zones/%s/recordsets' % zone, + criterion, marker, limit) + + return self._get(url, response_key='recordsets') + + def list_all_zones(self, criterion=None, marker=None, limit=None): + + url = self.build_url('/recordsets', criterion, marker, limit) + + return self._get(url, response_key='recordsets') + + def get(self, zone, recordset): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + recordset = v2_utils.resolve_by_name(self.list, recordset, zone) + + url = self.build_url('/zones/%s/recordsets/%s' % ( + zone, recordset)) + + return self._get(url) + + def update(self, zone, recordset, values): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + recordset = v2_utils.resolve_by_name(self.list, recordset, zone) + + url = '/zones/%s/recordsets/%s' % (zone, recordset) + + return self._put(url, data=values) + + def delete(self, zone, recordset): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + recordset = v2_utils.resolve_by_name(self.list, recordset, zone) + + url = '/zones/%s/recordsets/%s' % (zone, recordset) + + return self._delete(url) diff --git a/tatuclient/v2/usercert.py b/tatuclient/v2/usercert.py new file mode 100644 index 0000000..2d3fd18 --- /dev/null +++ b/tatuclient/v2/usercert.py @@ -0,0 +1,106 @@ +# Copyright 2015 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# 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 oslo_utils import uuidutils +import six + +from tatuclient.v2.base import V2Controller +from tatuclient.v2 import utils as v2_utils + + +class RecordSetController(V2Controller): + def _canonicalize_record_name(self, zone, name): + zone_info = None + + # If we get a zone name we'll need to get the ID of it before POST. + if isinstance(zone, six.string_types) and not \ + uuidutils.is_uuid_like(zone): + zone_info = self.client.zones.get(zone) + elif isinstance(zone, dict): + zone_info = zone + + # We where given a name like "www" vs www.i.io., attempt to fix it on + # the behalf of the actor. + if not name.endswith("."): + if not isinstance(zone_info, dict): + zone_info = self.client.zones.get(zone) + + name = "%s.%s" % (name, zone_info["name"]) + + return name, zone_info + + def create(self, zone, name, type_, records, description=None, + ttl=None): + name, zone_info = self._canonicalize_record_name(zone, name) + + data = { + 'name': name, + 'type': type_, + 'records': records + } + + if ttl is not None: + data['ttl'] = ttl + + if description is not None: + data['description'] = description + + if zone_info is not None: + zone_id = zone_info["id"] + else: + zone_id = zone + + url = '/zones/%s/recordsets' % zone_id + return self._post(url, data=data) + + def list(self, zone, criterion=None, marker=None, limit=None): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + + url = self.build_url( + '/zones/%s/recordsets' % zone, + criterion, marker, limit) + + return self._get(url, response_key='recordsets') + + def list_all_zones(self, criterion=None, marker=None, limit=None): + + url = self.build_url('/recordsets', criterion, marker, limit) + + return self._get(url, response_key='recordsets') + + def get(self, zone, recordset): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + recordset = v2_utils.resolve_by_name(self.list, recordset, zone) + + url = self.build_url('/zones/%s/recordsets/%s' % ( + zone, recordset)) + + return self._get(url) + + def update(self, zone, recordset, values): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + recordset = v2_utils.resolve_by_name(self.list, recordset, zone) + + url = '/zones/%s/recordsets/%s' % (zone, recordset) + + return self._put(url, data=values) + + def delete(self, zone, recordset): + zone = v2_utils.resolve_by_name(self.client.zones.list, zone) + recordset = v2_utils.resolve_by_name(self.list, recordset, zone) + + url = '/zones/%s/recordsets/%s' % (zone, recordset) + + return self._delete(url) diff --git a/designateclient/v2/utils.py b/tatuclient/v2/utils.py similarity index 98% rename from designateclient/v2/utils.py rename to tatuclient/v2/utils.py index b56b4ce..63f92b8 100644 --- a/designateclient/v2/utils.py +++ b/tatuclient/v2/utils.py @@ -20,7 +20,7 @@ from six import iterkeys from six.moves.urllib.parse import parse_qs from six.moves.urllib.parse import urlparse -from designateclient import exceptions +from tatuclient import exceptions def resolve_by_name(func, name, *args): diff --git a/designateclient/version.py b/tatuclient/version.py similarity index 90% rename from designateclient/version.py rename to tatuclient/version.py index cd56b54..a276ef7 100644 --- a/designateclient/version.py +++ b/tatuclient/version.py @@ -15,4 +15,4 @@ # under the License. import pbr.version -version_info = pbr.version.VersionInfo('python-designateclient') +version_info = pbr.version.VersionInfo('python-tatuclient') diff --git a/designateclient/warlock.py b/tatuclient/warlock.py similarity index 100% rename from designateclient/warlock.py rename to tatuclient/warlock.py