Browse Source

Removing v1 api support

The v1 has officially been removed from Designate since
the Queens release, and was deperecated long before that.

Change-Id: Ic5b44761ff939e2b319924af87849b3a79f9cb07
tags/3.0.0^0
Erik Olof Gunnar Andersson 1 week ago
parent
commit
093d8d7170
55 changed files with 46 additions and 5029 deletions
  1. 0
    21
      bin/designate
  2. 0
    0
      designateclient/cli/__init__.py
  3. 0
    143
      designateclient/cli/base.py
  4. 0
    38
      designateclient/cli/diagnostics.py
  5. 0
    144
      designateclient/cli/domains.py
  6. 0
    83
      designateclient/cli/quotas.py
  7. 0
    187
      designateclient/cli/records.py
  8. 0
    71
      designateclient/cli/reports.py
  9. 0
    98
      designateclient/cli/servers.py
  10. 0
    63
      designateclient/cli/sync.py
  11. 0
    37
      designateclient/cli/touch.py
  12. 3
    3
      designateclient/osc/plugin.py
  13. 0
    76
      designateclient/resources/schemas/v1/domain.json
  14. 0
    246
      designateclient/resources/schemas/v1/record.json
  15. 0
    44
      designateclient/resources/schemas/v1/server.json
  16. 0
    252
      designateclient/shell.py
  17. 0
    21
      designateclient/tests/test_utils.py
  18. 0
    53
      designateclient/tests/test_v1/__init__.py
  19. 0
    124
      designateclient/tests/test_v1/test_client.py
  20. 0
    30
      designateclient/tests/test_v1/test_diagnostics.py
  21. 0
    184
      designateclient/tests/test_v1/test_domain.py
  22. 0
    48
      designateclient/tests/test_v1/test_quotas.py
  23. 0
    222
      designateclient/tests/test_v1/test_records.py
  24. 0
    54
      designateclient/tests/test_v1/test_reports.py
  25. 0
    95
      designateclient/tests/test_v1/test_servers.py
  26. 0
    42
      designateclient/tests/test_v1/test_sync.py
  27. 0
    29
      designateclient/tests/test_v1/test_touch.py
  28. 0
    29
      designateclient/utils.py
  29. 0
    161
      designateclient/v1/__init__.py
  30. 0
    27
      designateclient/v1/diagnostics.py
  31. 0
    93
      designateclient/v1/domains.py
  32. 0
    39
      designateclient/v1/quotas.py
  33. 0
    115
      designateclient/v1/records.py
  34. 0
    67
      designateclient/v1/reports.py
  35. 0
    81
      designateclient/v1/servers.py
  36. 0
    37
      designateclient/v1/sync.py
  37. 0
    24
      designateclient/v1/touch.py
  38. 5
    5
      doc/examples/recordset_create.py
  39. 5
    5
      doc/examples/recordset_crud.py
  40. 5
    5
      doc/examples/zone_create_primary.py
  41. 5
    6
      doc/examples/zone_create_secondary.py
  42. 5
    6
      doc/examples/zone_list_nameservers.py
  43. 5
    5
      doc/examples/zone_list_paging.py
  44. 1
    0
      doc/requirements.txt
  45. 0
    958
      doc/source/cli/index.rst
  46. 0
    1
      doc/source/contributor/contributing.rst
  47. 2
    19
      doc/source/index.rst
  48. 3
    502
      doc/source/user/bindings.rst
  49. 0
    2
      doc/source/user/index.rst
  50. 0
    132
      doc/source/user/shell-examples.rst
  51. 0
    248
      doc/source/user/shell.rst
  52. 1
    1
      lower-constraints.txt
  53. 5
    0
      releasenotes/notes/remove-api-v1-4e507128b344082b.yaml
  54. 0
    52
      setup.cfg
  55. 1
    1
      test-requirements.txt

+ 0
- 21
bin/designate View File

@@ -1,21 +0,0 @@
1
-#!/usr/bin/env python
2
-# Copyright 2012 Managed I.T.
3
-#
4
-# Author: Kiall Mac Innes <kiall@managedit.ie>
5
-#
6
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
-# not use this file except in compliance with the License. You may obtain
8
-# a copy of the License at
9
-#
10
-#      http://www.apache.org/licenses/LICENSE-2.0
11
-#
12
-# Unless required by applicable law or agreed to in writing, software
13
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
-# License for the specific language governing permissions and limitations
16
-# under the License.
17
-import sys
18
-from designateclient.shell import DesignateShell
19
-
20
-shell = DesignateShell()
21
-sys.exit(shell.run(sys.argv[1:]))

+ 0
- 0
designateclient/cli/__init__.py View File


+ 0
- 143
designateclient/cli/base.py View File

@@ -1,143 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-import abc
17
-import warnings
18
-
19
-from keystoneauth1 import exceptions as ks_exceptions
20
-from osc_lib.command import command
21
-import six
22
-
23
-from designateclient import exceptions
24
-from designateclient import utils
25
-from designateclient.v1 import Client
26
-
27
-
28
-@six.add_metaclass(abc.ABCMeta)
29
-class Command(command.Command):
30
-    def run(self, parsed_args):
31
-
32
-        warnings.simplefilter('once', category=DeprecationWarning)
33
-        warnings.warn(
34
-            'The "designate" CLI is being deprecated in favour of the '
35
-            '"openstack" CLI plugin. All designate API v2 commands are '
36
-            'implemented there. When the v1 API is removed this CLI will '
37
-            'stop functioning',
38
-            DeprecationWarning)
39
-        warnings.resetwarnings()
40
-        warnings.simplefilter('ignore', category=DeprecationWarning)
41
-
42
-        self.client = Client(
43
-            region_name=self.app.options.os_region_name,
44
-            service_type=self.app.options.os_service_type,
45
-            endpoint_type=self.app.options.os_endpoint_type,
46
-            session=self.app.session,
47
-            all_tenants=self.app.options.all_tenants,
48
-            edit_managed=self.app.options.edit_managed,
49
-            endpoint=self.app.options.os_endpoint)
50
-        warnings.resetwarnings()
51
-        try:
52
-            return super(Command, self).run(parsed_args)
53
-        except exceptions.RemoteError as e:
54
-            columns = ['Code', 'Type']
55
-            values = [e.code, e.type]
56
-
57
-            if e.message:
58
-                columns.append('Message')
59
-                values.append(e.message)
60
-
61
-            if e.errors:
62
-                columns.append('Errors')
63
-                values.append(e.errors)
64
-
65
-            self.error_output(parsed_args, columns, values)
66
-        except ks_exceptions.EndpointNotFound as e:
67
-            self.app.log.error('No endpoint was found. You must provide a '
68
-                               'username or user id via --os-username, '
69
-                               '--os-user-id, env[OS_USERNAME] or '
70
-                               'env[OS_USER_ID]. You may also be using a '
71
-                               'cloud that does not have the V1 API enabled. '
72
-                               'If your cloud does not have the V1 DNS API '
73
-                               'use the openstack CLI to interact with the '
74
-                               'DNS Service.')
75
-
76
-            return 1
77
-
78
-    def error_output(self, parsed_args, column_names, data):
79
-        self.formatter.emit_one(column_names,
80
-                                data,
81
-                                self.app.stdout,
82
-                                parsed_args)
83
-        self.app.log.error('The requested action did not complete '
84
-                           'successfully')
85
-
86
-    @abc.abstractmethod
87
-    def execute(self, parsed_args):
88
-        """
89
-        Execute something, this is since we overload self.take_action()
90
-        in order to format the data
91
-
92
-        This method __NEEDS__ to be overloaded!
93
-
94
-        :param parsed_args: The parsed args that are given by take_action()
95
-        """
96
-
97
-    def post_execute(self, data):
98
-        """
99
-        Format the results locally if needed, by default we just return data
100
-
101
-        :param data: Whatever is returned by self.execute()
102
-        """
103
-        return data
104
-
105
-    def take_action(self, parsed_args):
106
-        results = self.execute(parsed_args)
107
-        return self.post_execute(results)
108
-
109
-    def find_resourceid_by_name_or_id(self, resource_plural, name_or_id):
110
-        resource_client = getattr(self.client, resource_plural)
111
-        return utils.find_resourceid_by_name_or_id(resource_client, name_or_id)
112
-
113
-
114
-class ListCommand(Command, command.Lister):
115
-    columns = None
116
-
117
-    def post_execute(self, results):
118
-        if len(results) > 0:
119
-            columns = self.columns or utils.get_columns(results)
120
-            data = [utils.get_item_properties(i, columns) for i in results]
121
-            return columns, data
122
-        else:
123
-            return [], ()
124
-
125
-
126
-class GetCommand(Command, command.ShowOne):
127
-    def post_execute(self, results):
128
-        return results.keys(), results.values()
129
-
130
-
131
-class CreateCommand(Command, command.ShowOne):
132
-    def post_execute(self, results):
133
-        return results.keys(), results.values()
134
-
135
-
136
-class UpdateCommand(Command, command.ShowOne):
137
-    def post_execute(self, results):
138
-        return results.keys(), results.values()
139
-
140
-
141
-class DeleteCommand(Command, command.ShowOne):
142
-    def post_execute(self, results):
143
-        return [], []

+ 0
- 38
designateclient/cli/diagnostics.py View File

@@ -1,38 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-
19
-from designateclient.cli import base
20
-
21
-LOG = logging.getLogger(__name__)
22
-
23
-
24
-class PingCommand(base.GetCommand):
25
-    """Ping a service on a given host"""
26
-
27
-    def get_parser(self, prog_name):
28
-        parser = super(PingCommand, self).get_parser(prog_name)
29
-
30
-        parser.add_argument('--service', help="Service name (e.g. central)",
31
-                            required=True)
32
-        parser.add_argument('--host', help="Hostname", required=True)
33
-
34
-        return parser
35
-
36
-    def execute(self, parsed_args):
37
-        return self.client.diagnostics.ping(parsed_args.service,
38
-                                            parsed_args.host)

+ 0
- 144
designateclient/cli/domains.py View File

@@ -1,144 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-
19
-from designateclient.cli import base
20
-from designateclient.v1.domains import Domain
21
-
22
-LOG = logging.getLogger(__name__)
23
-
24
-
25
-class ListDomainsCommand(base.ListCommand):
26
-    """List Domains"""
27
-
28
-    columns = ['id', 'name', 'serial']
29
-
30
-    def execute(self, parsed_args):
31
-        return self.client.domains.list()
32
-
33
-
34
-class GetDomainCommand(base.GetCommand):
35
-    """Get Domain"""
36
-
37
-    def get_parser(self, prog_name):
38
-        parser = super(GetDomainCommand, self).get_parser(prog_name)
39
-
40
-        parser.add_argument('id', help="Domain ID or name.")
41
-
42
-        return parser
43
-
44
-    def execute(self, parsed_args):
45
-        id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
46
-        return self.client.domains.get(id)
47
-
48
-
49
-class CreateDomainCommand(base.CreateCommand):
50
-    """Create Domain"""
51
-
52
-    def get_parser(self, prog_name):
53
-        parser = super(CreateDomainCommand, self).get_parser(prog_name)
54
-
55
-        parser.add_argument('--name', help="Domain name.", required=True)
56
-        parser.add_argument('--email', help="Domain email.", required=True)
57
-        parser.add_argument('--ttl', type=int, help="Time to live (seconds).")
58
-        parser.add_argument('--description', help="Description.")
59
-
60
-        return parser
61
-
62
-    def execute(self, parsed_args):
63
-        domain = Domain(
64
-            name=parsed_args.name,
65
-            email=parsed_args.email,
66
-        )
67
-
68
-        if parsed_args.description:
69
-            domain.description = parsed_args.description
70
-
71
-        if parsed_args.ttl is not None:
72
-            domain.ttl = parsed_args.ttl
73
-
74
-        return self.client.domains.create(domain)
75
-
76
-
77
-class UpdateDomainCommand(base.UpdateCommand):
78
-    """Update Domain"""
79
-
80
-    def get_parser(self, prog_name):
81
-        parser = super(UpdateDomainCommand, self).get_parser(prog_name)
82
-
83
-        parser.add_argument('id', help="Domain ID or name.")
84
-        parser.add_argument('--name', help="Domain name.")
85
-        parser.add_argument('--email', help="Domain email.")
86
-        parser.add_argument('--ttl', type=int, help="Time to live (seconds).")
87
-        description_group = parser.add_mutually_exclusive_group()
88
-        description_group.add_argument('--description', help="Description.")
89
-        description_group.add_argument('--no-description', action='store_true')
90
-
91
-        return parser
92
-
93
-    def execute(self, parsed_args):
94
-        # TODO(kiall): API needs updating.. this get is silly
95
-        id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
96
-        domain = self.client.domains.get(id)
97
-
98
-        if parsed_args.name:
99
-            domain.name = parsed_args.name
100
-
101
-        if parsed_args.email:
102
-            domain.email = parsed_args.email
103
-
104
-        if parsed_args.ttl is not None:
105
-            domain.ttl = parsed_args.ttl
106
-
107
-        if parsed_args.no_description:
108
-            domain.description = None
109
-        elif parsed_args.description:
110
-            domain.description = parsed_args.description
111
-
112
-        return self.client.domains.update(domain)
113
-
114
-
115
-class DeleteDomainCommand(base.DeleteCommand):
116
-    """Delete Domain"""
117
-
118
-    def get_parser(self, prog_name):
119
-        parser = super(DeleteDomainCommand, self).get_parser(prog_name)
120
-
121
-        parser.add_argument('id', help="Domain ID or name.")
122
-
123
-        return parser
124
-
125
-    def execute(self, parsed_args):
126
-        id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
127
-        return self.client.domains.delete(id)
128
-
129
-
130
-class ListDomainServersCommand(base.ListCommand):
131
-    """List Domain Servers"""
132
-
133
-    columns = ['name']
134
-
135
-    def get_parser(self, prog_name):
136
-        parser = super(ListDomainServersCommand, self).get_parser(prog_name)
137
-
138
-        parser.add_argument('id', help="Domain ID or name.")
139
-
140
-        return parser
141
-
142
-    def execute(self, parsed_args):
143
-        id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
144
-        return self.client.domains.list_domain_servers(id)

+ 0
- 83
designateclient/cli/quotas.py View File

@@ -1,83 +0,0 @@
1
-# Copyright 2014 Hewlett-Packard Development Company, L.P.
2
-#
3
-# Author: Endre Karlson <endre.karlson@hp.com>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-
19
-from designateclient.cli import base
20
-
21
-
22
-LOG = logging.getLogger(__name__)
23
-
24
-
25
-class GetQuotaCommand(base.GetCommand):
26
-    """Get Quota"""
27
-
28
-    def get_parser(self, prog_name):
29
-        parser = super(GetQuotaCommand, self).get_parser(prog_name)
30
-
31
-        parser.add_argument('tenant_id', help="Tenant ID")
32
-
33
-        return parser
34
-
35
-    def execute(self, parsed_args):
36
-        return self.client.quotas.get(parsed_args.tenant_id)
37
-
38
-
39
-class UpdateQuotaCommand(base.UpdateCommand):
40
-    """Update Quota"""
41
-
42
-    def get_parser(self, prog_name):
43
-        parser = super(UpdateQuotaCommand, self).get_parser(prog_name)
44
-
45
-        parser.add_argument('tenant_id', help="Tenant ID.")
46
-        parser.add_argument('--domains', help="Allowed domains.", type=int)
47
-        parser.add_argument('--domain-recordsets',
48
-                            help="Allowed domain records.",
49
-                            type=int)
50
-        parser.add_argument('--recordset-records',
51
-                            help="Allowed recordset records.",
52
-                            type=int)
53
-        parser.add_argument('--domain-records',
54
-                            help="Allowed domain records.",
55
-                            type=int)
56
-        parser.add_argument('--api-export-size',
57
-                            help="Allowed zone export recordsets.",
58
-                            type=int)
59
-        return parser
60
-
61
-    def execute(self, parsed_args):
62
-        # TODO(kiall): API needs updating.. this get is silly
63
-        quota = self.client.quotas.get(parsed_args.tenant_id)
64
-
65
-        for key, old in quota.items():
66
-            new = getattr(parsed_args, key)
67
-            if new is not None and new != old:
68
-                quota[key] = new
69
-        return self.client.quotas.update(parsed_args.tenant_id, quota)
70
-
71
-
72
-class ResetQuotaCommand(base.DeleteCommand):
73
-    """Reset Quota"""
74
-
75
-    def get_parser(self, prog_name):
76
-        parser = super(ResetQuotaCommand, self).get_parser(prog_name)
77
-
78
-        parser.add_argument('tenant_id', help="Tenant ID.")
79
-
80
-        return parser
81
-
82
-    def execute(self, parsed_args):
83
-        self.client.quotas.reset(parsed_args.tenant_id)

+ 0
- 187
designateclient/cli/records.py View File

@@ -1,187 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-
19
-from designateclient.cli import base
20
-from designateclient.v1.records import Record
21
-
22
-LOG = logging.getLogger(__name__)
23
-
24
-
25
-class ListRecordsCommand(base.ListCommand):
26
-    """List Records"""
27
-
28
-    columns = ['id', 'type', 'name', 'data']
29
-
30
-    def get_parser(self, prog_name):
31
-        parser = super(ListRecordsCommand, self).get_parser(prog_name)
32
-
33
-        parser.add_argument('domain_id', help="Domain ID or name.")
34
-
35
-        return parser
36
-
37
-    def execute(self, parsed_args):
38
-        domain_id = self.find_resourceid_by_name_or_id(
39
-            'domains', parsed_args.domain_id)
40
-        return self.client.records.list(domain_id)
41
-
42
-
43
-class GetRecordCommand(base.GetCommand):
44
-    """Get Record"""
45
-
46
-    def get_parser(self, prog_name):
47
-        parser = super(GetRecordCommand, self).get_parser(prog_name)
48
-
49
-        parser.add_argument('domain_id', help="Domain ID or name.")
50
-        parser.add_argument('id', help="Record ID.")
51
-
52
-        return parser
53
-
54
-    def execute(self, parsed_args):
55
-        domain_id = self.find_resourceid_by_name_or_id(
56
-            'domains', parsed_args.domain_id)
57
-        return self.client.records.get(domain_id, parsed_args.id)
58
-
59
-
60
-class CreateRecordCommand(base.CreateCommand):
61
-    """Create Record"""
62
-
63
-    def get_parser(self, prog_name):
64
-        parser = super(CreateRecordCommand, self).get_parser(prog_name)
65
-
66
-        parser.add_argument('domain_id', help="Domain ID or name.")
67
-        parser.add_argument(
68
-            '--name', help="Record (relative|absolute) name.", required=True)
69
-        parser.add_argument('--type', help="Record type.", required=True)
70
-        parser.add_argument('--data', help="Record data.", required=True)
71
-        parser.add_argument('--ttl', type=int, help="Record TTL.")
72
-        parser.add_argument('--priority', type=int, help="Record priority.")
73
-        parser.add_argument('--description', help="Description.")
74
-
75
-        return parser
76
-
77
-    def execute(self, parsed_args):
78
-        domain_id = self.find_resourceid_by_name_or_id(
79
-            'domains', parsed_args.domain_id)
80
-
81
-        if not parsed_args.name.endswith('.'):
82
-            # Relative name?
83
-            domain_name = self.client.domains.get(domain_id)['name']
84
-            absolute = parsed_args.name + '.'
85
-            relative = absolute + domain_name
86
-            if absolute.endswith('.' + domain_name):
87
-                # Relative name or absolute name missing final period?
88
-                msg = ('"%s" is a relative name but looks like an absolute '
89
-                       'name, use --name "%s" or "%s"'
90
-                       % (parsed_args.name, absolute, relative))
91
-                raise ValueError(msg)
92
-            parsed_args.name = relative
93
-
94
-        record = Record(
95
-            name=parsed_args.name,
96
-            type=parsed_args.type,
97
-            data=parsed_args.data,
98
-        )
99
-
100
-        if parsed_args.ttl is not None:
101
-            record.ttl = parsed_args.ttl
102
-
103
-        if parsed_args.priority is not None:
104
-            record.priority = parsed_args.priority
105
-
106
-        if parsed_args.description:
107
-            record.description = parsed_args.description
108
-
109
-        return self.client.records.create(domain_id, record)
110
-
111
-
112
-class UpdateRecordCommand(base.UpdateCommand):
113
-    """Update Record"""
114
-
115
-    def get_parser(self, prog_name):
116
-        parser = super(UpdateRecordCommand, self).get_parser(prog_name)
117
-
118
-        parser.add_argument('domain_id', help="Domain ID or name.")
119
-        parser.add_argument('id', help="Record ID.")
120
-        parser.add_argument('--name', help="Record name.")
121
-        parser.add_argument('--type', help="Record type.")
122
-        parser.add_argument('--data', help="Record data.")
123
-
124
-        description_group = parser.add_mutually_exclusive_group()
125
-        description_group.add_argument('--description', help="Description.")
126
-        description_group.add_argument('--no-description', action='store_true')
127
-
128
-        ttl_group = parser.add_mutually_exclusive_group()
129
-        ttl_group.add_argument('--ttl', type=int,
130
-                               help="Record time to live (seconds).")
131
-        ttl_group.add_argument('--no-ttl', action='store_true')
132
-
133
-        priotity_group = parser.add_mutually_exclusive_group()
134
-        priotity_group.add_argument('--priority', type=int,
135
-                                    help="Record priority.")
136
-        priotity_group.add_argument('--no-priority', action='store_true')
137
-
138
-        return parser
139
-
140
-    def execute(self, parsed_args):
141
-        # TODO(kiall): API needs updating.. this get is silly
142
-        record = self.client.records.get(parsed_args.domain_id, parsed_args.id)
143
-
144
-        if parsed_args.name:
145
-            record.name = parsed_args.name
146
-
147
-        if parsed_args.type:
148
-            record.type = parsed_args.type
149
-
150
-        if parsed_args.data:
151
-            record.data = parsed_args.data
152
-
153
-        if parsed_args.no_ttl:
154
-            record.ttl = None
155
-        elif parsed_args.ttl is not None:
156
-            record.ttl = parsed_args.ttl
157
-
158
-        if parsed_args.no_priority:
159
-            record.priority = None
160
-        elif parsed_args.priority is not None:
161
-            record.priority = parsed_args.priority
162
-
163
-        if parsed_args.no_description:
164
-            record.description = None
165
-        elif parsed_args.description:
166
-            record.description = parsed_args.description
167
-
168
-        domain_id = self.find_resourceid_by_name_or_id(
169
-            'domains', parsed_args.domain_id)
170
-        return self.client.records.update(domain_id, record)
171
-
172
-
173
-class DeleteRecordCommand(base.DeleteCommand):
174
-    """Delete Record"""
175
-
176
-    def get_parser(self, prog_name):
177
-        parser = super(DeleteRecordCommand, self).get_parser(prog_name)
178
-
179
-        parser.add_argument('domain_id', help="Domain ID or name.")
180
-        parser.add_argument('id', help="Record ID.")
181
-
182
-        return parser
183
-
184
-    def execute(self, parsed_args):
185
-        domain_id = self.find_resourceid_by_name_or_id(
186
-            'domains', parsed_args.domain_id)
187
-        return self.client.records.delete(domain_id, parsed_args.id)

+ 0
- 71
designateclient/cli/reports.py View File

@@ -1,71 +0,0 @@
1
-# Copyright 2013 Hewlett-Packard Development Company, L.P. All Rights Reserved.
2
-#
3
-# Author: Patrick Galbraith <patg@patg.net>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-from designateclient.cli import base
17
-
18
-
19
-class DomainCountCommand(base.GetCommand):
20
-    """Get counts for total domains"""
21
-
22
-    def execute(self, parsed_args):
23
-        return self.client.reports.count_domains()
24
-
25
-
26
-class RecordCountCommand(base.GetCommand):
27
-    """Get counts for total records"""
28
-
29
-    def execute(self, parsed_args):
30
-        return self.client.reports.count_records()
31
-
32
-
33
-class TenantCountCommand(base.GetCommand):
34
-    """Get counts for total tenants"""
35
-
36
-    def execute(self, parsed_args):
37
-        return self.client.reports.count_tenants()
38
-
39
-
40
-class CountsCommand(base.GetCommand):
41
-    """Get count totals for all tenants, domains and records"""
42
-
43
-    def execute(self, parsed_args):
44
-        return self.client.reports.count_all()
45
-
46
-
47
-class TenantsCommand(base.ListCommand):
48
-    """Get list of tenants and domain count for each"""
49
-
50
-    columns = ['domain_count', 'id']
51
-
52
-    def execute(self, parsed_args):
53
-        return self.client.reports.tenants_all()
54
-
55
-
56
-class TenantCommand(base.ListCommand):
57
-    """Get a list of domains for given tenant"""
58
-
59
-    columns = ['domain']
60
-
61
-    def get_parser(self, prog_name):
62
-        parser = super(TenantCommand, self).get_parser(prog_name)
63
-
64
-        parser.add_argument('--report-tenant-id',
65
-                            help="The tenant_id being reported on.",
66
-                            required=True)
67
-
68
-        return parser
69
-
70
-    def execute(self, parsed_args):
71
-        return self.client.reports.tenant_domains(parsed_args.report_tenant_id)

+ 0
- 98
designateclient/cli/servers.py View File

@@ -1,98 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-
19
-from designateclient.cli import base
20
-from designateclient.v1.servers import Server
21
-
22
-LOG = logging.getLogger(__name__)
23
-
24
-
25
-class ListServersCommand(base.ListCommand):
26
-    """List Servers"""
27
-
28
-    columns = ['id', 'name']
29
-
30
-    def execute(self, parsed_args):
31
-        return self.client.servers.list()
32
-
33
-
34
-class GetServerCommand(base.GetCommand):
35
-    """Get Server"""
36
-
37
-    def get_parser(self, prog_name):
38
-        parser = super(GetServerCommand, self).get_parser(prog_name)
39
-
40
-        parser.add_argument('id', help="Server ID.")
41
-
42
-        return parser
43
-
44
-    def execute(self, parsed_args):
45
-        return self.client.servers.get(parsed_args.id)
46
-
47
-
48
-class CreateServerCommand(base.CreateCommand):
49
-    """Create Server"""
50
-
51
-    def get_parser(self, prog_name):
52
-        parser = super(CreateServerCommand, self).get_parser(prog_name)
53
-
54
-        parser.add_argument('--name', help="Server name.", required=True)
55
-
56
-        return parser
57
-
58
-    def execute(self, parsed_args):
59
-        server = Server(
60
-            name=parsed_args.name,
61
-        )
62
-
63
-        return self.client.servers.create(server)
64
-
65
-
66
-class UpdateServerCommand(base.UpdateCommand):
67
-    """Update Server"""
68
-
69
-    def get_parser(self, prog_name):
70
-        parser = super(UpdateServerCommand, self).get_parser(prog_name)
71
-
72
-        parser.add_argument('id', help="Server ID.")
73
-        parser.add_argument('--name', help="Server name.")
74
-
75
-        return parser
76
-
77
-    def execute(self, parsed_args):
78
-        # TODO(kiall): API needs updating.. this get is silly
79
-        server = self.client.servers.get(parsed_args.id)
80
-
81
-        if parsed_args.name:
82
-            server.name = parsed_args.name
83
-
84
-        return self.client.servers.update(server)
85
-
86
-
87
-class DeleteServerCommand(base.DeleteCommand):
88
-    """Delete Server"""
89
-
90
-    def get_parser(self, prog_name):
91
-        parser = super(DeleteServerCommand, self).get_parser(prog_name)
92
-
93
-        parser.add_argument('id', help="Server ID.")
94
-
95
-        return parser
96
-
97
-    def execute(self, parsed_args):
98
-        return self.client.servers.delete(parsed_args.id)

+ 0
- 63
designateclient/cli/sync.py View File

@@ -1,63 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-import logging
17
-
18
-from designateclient.cli import base
19
-
20
-LOG = logging.getLogger(__name__)
21
-
22
-
23
-class SyncAllCommand(base.DeleteCommand):
24
-    """Sync Everything"""
25
-
26
-    def execute(self, parsed_args):
27
-        self.client.sync.sync_all()
28
-
29
-        LOG.info('Synchronization of all domains scheduled')
30
-
31
-
32
-class SyncDomainCommand(base.DeleteCommand):
33
-    """Sync a single Domain"""
34
-
35
-    def get_parser(self, prog_name):
36
-        parser = super(SyncDomainCommand, self).get_parser(prog_name)
37
-
38
-        parser.add_argument('domain_id', help="Domain ID")
39
-
40
-        return parser
41
-
42
-    def execute(self, parsed_args):
43
-        self.client.sync.sync_domain(parsed_args.domain_id)
44
-
45
-        LOG.info('Synchronization of domain scheduled')
46
-
47
-
48
-class SyncRecordCommand(base.DeleteCommand):
49
-    """Sync a single Record"""
50
-
51
-    def get_parser(self, prog_name):
52
-        parser = super(SyncRecordCommand, self).get_parser(prog_name)
53
-
54
-        parser.add_argument('domain_id', help="Domain ID")
55
-        parser.add_argument('record_id', help="Record ID")
56
-
57
-        return parser
58
-
59
-    def execute(self, parsed_args):
60
-        self.client.sync.sync_record(parsed_args.domain_id,
61
-                                     parsed_args.record_id)
62
-
63
-        LOG.info('Synchronization of record scheduled')

+ 0
- 37
designateclient/cli/touch.py View File

@@ -1,37 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-
19
-from designateclient.cli import base
20
-
21
-LOG = logging.getLogger(__name__)
22
-
23
-
24
-class TouchDomainCommand(base.DeleteCommand):
25
-    """Touch a single Domain"""
26
-
27
-    def get_parser(self, prog_name):
28
-        parser = super(TouchDomainCommand, self).get_parser(prog_name)
29
-
30
-        parser.add_argument('domain_id', help="Domain ID")
31
-
32
-        return parser
33
-
34
-    def execute(self, parsed_args):
35
-        self.client.touch.domain(parsed_args.domain_id)
36
-
37
-        LOG.info('Domain touched successfully')

+ 3
- 3
designateclient/osc/plugin.py View File

@@ -16,9 +16,9 @@
16 16
 
17 17
 """OpenStackClient plugin for DNS service."""
18 18
 
19
-from osc_lib import utils as oscutils
19
+import os
20 20
 
21
-from designateclient import shell
21
+from osc_lib import utils as oscutils
22 22
 
23 23
 
24 24
 DEFAULT_API_VERSION = '2'
@@ -45,7 +45,7 @@ def build_option_parser(parser):
45 45
     parser.add_argument(
46 46
         '--os-dns-api-version',
47 47
         metavar='<dns-api-version>',
48
-        default=shell.env('OS_DNS_API_VERSION', default="2"),
48
+        default=os.environ.get('OS_DNS_API_VERSION', '2'),
49 49
         help='DNS API version, default=' +
50 50
              DEFAULT_API_VERSION +
51 51
              ' (Env: OS_DNS_API_VERSION)')

+ 0
- 76
designateclient/resources/schemas/v1/domain.json View File

@@ -1,76 +0,0 @@
1
-{
2
-    "id": "domain",
3
-
4
-    "$schema": "http://json-schema.org/draft-03/hyper-schema",
5
-
6
-    "title": "domain",
7
-    "description": "Domain",
8
-    "additionalProperties": false,
9
-
10
-    "properties": {
11
-        "id": {
12
-            "type": "string",
13
-            "description": "Domain Identifier",
14
-            "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}$",
15
-            "readonly": true
16
-        },
17
-        "name": {
18
-            "type": "string",
19
-            "description": "Domain name",
20
-            "format": "domain-name",
21
-            "maxLength": 255,
22
-            "required": true,
23
-            "readonly": true
24
-        },
25
-        "email": {
26
-            "type": "string",
27
-            "description": "Hostmaster email address",
28
-            "format": "email",
29
-            "maxLength": 255,
30
-            "required": true
31
-        },
32
-        "ttl": {
33
-            "type": "integer",
34
-            "description": "Time to live",
35
-            "minimum": 1,
36
-            "maximum": 2147483647
37
-        },
38
-        "serial": {
39
-            "type": "integer",
40
-            "description": "Serial Number",
41
-            "minimum": 1,
42
-            "maximum": 4294967295,
43
-            "readonly": true
44
-        },
45
-        "description": {
46
-            "type": ["string", "null"],
47
-            "description": "Description for the Domain",
48
-            "maxLength": 160
49
-        },
50
-        "created_at": {
51
-            "type": "string",
52
-            "description": "Date and time of domain creation",
53
-            "format": "date-time",
54
-            "readonly": true
55
-        },
56
-        "updated_at": {
57
-            "type": ["string", "null"],
58
-            "description": "Date and time of last domain update",
59
-            "format": "date-time",
60
-            "readonly": true
61
-        }
62
-    },
63
-    "links": [{
64
-        "rel": "self",
65
-        "href": "/domains/{id}"
66
-    }, {
67
-        "rel": "records",
68
-        "href": "/domains/{id}/records"
69
-    }, {
70
-        "rel": "servers",
71
-        "href": "/domains/{id}/servers"
72
-    }, {
73
-        "rel": "collection",
74
-        "href": "/domains"
75
-    }]
76
-}

+ 0
- 246
designateclient/resources/schemas/v1/record.json View File

@@ -1,246 +0,0 @@
1
-{
2
-    "id": "record",
3
-
4
-    "$schema": "http://json-schema.org/draft-03/hyper-schema",
5
-
6
-    "title": "record",
7
-    "description": "Record",
8
-    "additionalProperties": false,
9
-
10
-    "properties": {
11
-        "id": {
12
-            "type": "string",
13
-            "description": "Record Identifier",
14
-            "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}$",
15
-            "readonly": true
16
-        },
17
-        "domain_id": {
18
-            "type": "string",
19
-            "description": "Domain Identifier",
20
-            "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}$",
21
-            "readonly": true
22
-        },
23
-        "name": {
24
-            "type": "string",
25
-            "description": "DNS Record Name",
26
-            "format": "host-name",
27
-            "maxLength": 255,
28
-            "required": true
29
-        },
30
-        "type": {
31
-            "type": "string",
32
-            "description": "DNS Record Type",
33
-            "enum": ["A", "AAAA", "CNAME", "MX", "SRV", "TXT", "SPF", "NS", "PTR", "SSHFP", "SOA"],
34
-            "required": true
35
-        },
36
-        "data": {
37
-            "type": "string",
38
-            "description": "DNS Record Value",
39
-            "maxLength": 255,
40
-            "required": true
41
-        },
42
-        "priority": {
43
-            "type": ["integer", "null"],
44
-            "description": "DNS Record Priority",
45
-            "minimum": 0,
46
-            "maximum": 65535
47
-        },
48
-        "ttl": {
49
-            "type": ["integer", "null"],
50
-            "description": "Time to live",
51
-            "minimum": 1,
52
-            "maximum": 2147483647
53
-        },
54
-        "description": {
55
-            "type": ["string", "null"],
56
-            "description": "Description for the record",
57
-            "maxLength": 160
58
-        },
59
-        "created_at": {
60
-            "type": "string",
61
-            "description": "Date and time of record creation",
62
-            "format": "date-time",
63
-            "readonly": true
64
-        },
65
-        "updated_at": {
66
-            "type": ["string", "null"],
67
-            "description": "Date and time of last record update",
68
-            "format": "date-time",
69
-            "readonly": true
70
-        }
71
-    },
72
-    "oneOf": [{
73
-        "description": "An A Record",
74
-        "properties": {
75
-            "type": {
76
-                "type": "string",
77
-                "enum": ["A"]
78
-            },
79
-            "data": {
80
-                "format": "ip-address",
81
-                "required": true
82
-            },
83
-            "priority": {
84
-                "type": "null"
85
-            }
86
-        }
87
-    }, {
88
-        "description": "An AAAA Record",
89
-        "properties": {
90
-            "type": {
91
-                "type": "string",
92
-                "enum": ["AAAA"]
93
-            },
94
-            "data": {
95
-                "format": "ipv6",
96
-                "required": true
97
-            },
98
-            "priority": {
99
-                "type": "null"
100
-            }
101
-        }
102
-    }, {
103
-        "description": "A CNAME Record",
104
-        "properties": {
105
-            "type": {
106
-                "type": "string",
107
-                "enum": ["CNAME"]
108
-            },
109
-            "data": {
110
-                "format": "host-name",
111
-                "required": true
112
-            },
113
-            "priority": {
114
-                "type": "null"
115
-            }
116
-        }
117
-    }, {
118
-        "description": "A MX Record",
119
-        "properties": {
120
-            "type": {
121
-                "type": "string",
122
-                "enum": ["MX"]
123
-            },
124
-            "data": {
125
-                "format": "host-name",
126
-                "required": true
127
-            },
128
-            "priority": {
129
-                "type": "integer",
130
-                "required": true
131
-            }
132
-        }
133
-    }, {
134
-        "description": "A SRV Record",
135
-        "properties": {
136
-            "type": {
137
-                "type": "string",
138
-                "enum": ["SRV"]
139
-            },
140
-            "name": {
141
-                "type": "string",
142
-                "pattern": "^(?:_[A-Za-z0-9_\\-]{1,62}\\.){2}"
143
-            },
144
-            "data": {
145
-                "type": "string",
146
-                "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}(?<!\\-)\\.)+$"
147
-            },
148
-            "priority": {
149
-                "type": "integer",
150
-                "required": true
151
-            }
152
-        }
153
-    }, {
154
-        "description": "A TXT Record",
155
-        "properties": {
156
-            "type": {
157
-                "type": "string",
158
-                "enum": ["TXT"]
159
-            },
160
-            "priority": {
161
-                "type": "null"
162
-            }
163
-        }
164
-    }, {
165
-        "description": "A SPF Record",
166
-        "properties": {
167
-            "type": {
168
-                "type": "string",
169
-                "enum": ["SPF"]
170
-            },
171
-            "priority": {
172
-                "type": "null"
173
-            }
174
-        }
175
-    }, {
176
-        "description": "A NS Record",
177
-        "properties": {
178
-            "type": {
179
-                "type": "string",
180
-                "enum": ["NS"]
181
-            },
182
-            "data": {
183
-                "format": "host-name",
184
-                "required": true
185
-            },
186
-            "priority": {
187
-                "type": "null"
188
-            }
189
-        }
190
-    }, {
191
-        "description": "A PTR Record",
192
-        "properties": {
193
-            "type": {
194
-                "type": "string",
195
-                "enum": ["PTR"]
196
-            },
197
-            "name": {
198
-                "type": "string",
199
-                "pattern": "^(?:(?:\\d{1,3}\\.){4}in-addr\\.arpa\\.|(?:[a-f|\\d]\\.){32}ip6\\.arpa\\.)$"
200
-            },
201
-            "data": {
202
-                "format": "host-name",
203
-                "required": true
204
-            },
205
-            "priority": {
206
-                "type": "null"
207
-            }
208
-        }
209
-    }, {
210
-        "description": "A SSHFP Record",
211
-        "properties": {
212
-            "type": {
213
-                "type": "string",
214
-                "enum": ["SSHFP"]
215
-            },
216
-            "data": {
217
-                "pattern": "^[1-2] 1 [0-9A-Fa-f]{40}$",
218
-                "required": true
219
-            },
220
-            "priority": {
221
-                "type": "null"
222
-            }
223
-        }
224
-    }, {
225
-        "description": "A SOA Record",
226
-        "properties": {
227
-            "type": {
228
-                "type": "string",
229
-                "enum": ["SOA"]
230
-            },
231
-            "priority": {
232
-                "type": "null"
233
-            }
234
-        }
235
-    }],
236
-    "links": [{
237
-        "rel": "self",
238
-        "href": "/domains/{domain_id}/records/{id}"
239
-    }, {
240
-        "rel": "domain",
241
-        "href": "/domains/{domain_id}"
242
-    }, {
243
-        "rel": "collection",
244
-        "href": "/domains/{domain_id}/records"
245
-    }]
246
-}

+ 0
- 44
designateclient/resources/schemas/v1/server.json View File

@@ -1,44 +0,0 @@
1
-{
2
-    "id": "server",
3
-
4
-    "$schema": "http://json-schema.org/draft-03/hyper-schema",
5
-
6
-    "title": "server",
7
-    "description": "Server",
8
-    "additionalProperties": false,
9
-
10
-    "properties": {
11
-        "id": {
12
-            "type": "string",
13
-            "description": "Server Identifier",
14
-            "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}$",
15
-            "readonly": true
16
-        },
17
-        "name": {
18
-            "type": "string",
19
-            "description": "Server DNS name",
20
-            "format": "host-name",
21
-            "maxLength": 255,
22
-            "required": true
23
-        },
24
-        "created_at": {
25
-            "type": "string",
26
-            "description": "Date and time of server creation",
27
-            "format": "date-time",
28
-            "readonly": true
29
-        },
30
-        "updated_at": {
31
-            "type": ["string", "null"],
32
-            "description": "Date and time of last server update",
33
-            "format": "date-time",
34
-            "readonly": true
35
-        }
36
-    },
37
-    "links": [{
38
-        "rel": "self",
39
-        "href": "/servers/{id}"
40
-    }, {
41
-        "rel": "collection",
42
-        "href": "/servers"
43
-    }]
44
-}

+ 0
- 252
designateclient/shell.py View File

@@ -1,252 +0,0 @@
1
-# Copyright 2012 Managed I.T.
2
-#
3
-# Author: Kiall Mac Innes <kiall@managedit.ie>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-import logging
18
-import os
19
-import traceback
20
-
21
-from cliff.app import App
22
-from cliff.commandmanager import CommandManager
23
-
24
-from designateclient import utils
25
-from designateclient.version import version_info as version
26
-
27
-
28
-def env(*vars, **kwargs):
29
-    """Search for the first defined of possibly many env vars
30
-
31
-    Returns the first environment variable defined in vars, or
32
-    returns the default defined in kwargs.
33
-
34
-    """
35
-    for v in vars:
36
-        value = os.environ.get(v)
37
-        if value:
38
-            return value
39
-    return kwargs.get('default', '')
40
-
41
-
42
-class DesignateShell(App):
43
-    CONSOLE_MESSAGE_FORMAT = '%(levelname)s: %(message)s'
44
-    DEFAULT_VERBOSE_LEVEL = 0
45
-
46
-    def __init__(self):
47
-        super(DesignateShell, self).__init__(
48
-            description='Designate Client',
49
-            version=version.version_string(),
50
-            command_manager=CommandManager('designateclient.cli'),
51
-        )
52
-
53
-        self.log = logging.getLogger(__name__)
54
-
55
-    def build_option_parser(self, description, version):
56
-        parser = super(DesignateShell, self).build_option_parser(
57
-            description, version)
58
-
59
-        parser.add_argument('--os-username',
60
-                            default=env('OS_USERNAME'),
61
-                            help='Name used for authentication with the '
62
-                                 'OpenStack Identity service. '
63
-                                 'Defaults to env[OS_USERNAME].')
64
-
65
-        parser.add_argument('--os-user-id',
66
-                            default=env('OS_USER_ID'),
67
-                            help='User ID used for authentication with the '
68
-                                 'OpenStack Identity service. '
69
-                                 'Defaults to env[OS_USER_ID].')
70
-
71
-        parser.add_argument('--os-user-domain-id',
72
-                            default=env('OS_USER_DOMAIN_ID'),
73
-                            help='Defaults to env[OS_USER_DOMAIN_ID].')
74
-
75
-        parser.add_argument('--os-user-domain-name',
76
-                            default=env('OS_USER_DOMAIN_NAME'),
77
-                            help='Defaults to env[OS_USER_DOMAIN_NAME].')
78
-
79
-        parser.add_argument('--os-password',
80
-                            default=env('OS_PASSWORD'),
81
-                            help='Password used for authentication with the '
82
-                                 'OpenStack Identity service. '
83
-                                 'Defaults to env[OS_PASSWORD].')
84
-
85
-        parser.add_argument('--os-tenant-name',
86
-                            default=env('OS_TENANT_NAME'),
87
-                            help='Tenant to request authorization on. '
88
-                                 'Defaults to env[OS_TENANT_NAME].')
89
-
90
-        parser.add_argument('--os-tenant-id',
91
-                            default=env('OS_TENANT_ID'),
92
-                            help='Tenant to request authorization on. '
93
-                                 'Defaults to env[OS_TENANT_ID].')
94
-
95
-        parser.add_argument('--os-project-name',
96
-                            default=env('OS_PROJECT_NAME'),
97
-                            help='Project to request authorization on. '
98
-                                 'Defaults to env[OS_PROJECT_NAME].')
99
-
100
-        parser.add_argument('--os-domain-name',
101
-                            default=env('OS_DOMAIN_NAME'),
102
-                            help='Project to request authorization on. '
103
-                                 'Defaults to env[OS_DOMAIN_NAME].')
104
-
105
-        parser.add_argument('--os-domain-id',
106
-                            default=env('OS_DOMAIN_ID'),
107
-                            help='Defaults to env[OS_DOMAIN_ID].')
108
-
109
-        parser.add_argument('--os-project-id',
110
-                            default=env('OS_PROJECT_ID'),
111
-                            help='Project to request authorization on. '
112
-                                 'Defaults to env[OS_PROJECT_ID].')
113
-
114
-        parser.add_argument('--os-project-domain-id',
115
-                            default=env('OS_PROJECT_DOMAIN_ID'),
116
-                            help='Defaults to env[OS_PROJECT_DOMAIN_ID].')
117
-
118
-        parser.add_argument('--os-project-domain-name',
119
-                            default=env('OS_PROJECT_DOMAIN_NAME'),
120
-                            help='Defaults to env[OS_PROJECT_DOMAIN_NAME].')
121
-
122
-        parser.add_argument('--os-auth-url',
123
-                            default=env('OS_AUTH_URL'),
124
-                            help='Specify the Identity endpoint to use for '
125
-                                 'authentication. '
126
-                                 'Defaults to env[OS_AUTH_URL].')
127
-
128
-        parser.add_argument('--os-region-name',
129
-                            default=env('OS_REGION_NAME'),
130
-                            help='Specify the region to use. '
131
-                                 'Defaults to env[OS_REGION_NAME].')
132
-
133
-        parser.add_argument('--os-token',
134
-                            default=env('OS_SERVICE_TOKEN'),
135
-                            help='Specify an existing token to use instead of '
136
-                                 'retrieving one via authentication (e.g. '
137
-                                 'with username & password). '
138
-                                 'Defaults to env[OS_SERVICE_TOKEN].')
139
-
140
-        parser.add_argument('--os-endpoint',
141
-                            default=env('OS_DNS_ENDPOINT',
142
-                                        'OS_SERVICE_ENDPOINT'),
143
-                            help='Specify an endpoint to use instead of '
144
-                                 'retrieving one from the service catalog '
145
-                                 '(via authentication). '
146
-                                 'Defaults to env[OS_DNS_ENDPOINT].')
147
-
148
-        parser.add_argument('--os-endpoint-type',
149
-                            default=env('OS_ENDPOINT_TYPE',
150
-                                        default='publicURL'),
151
-                            help='Defaults to env[OS_ENDPOINT_TYPE].')
152
-
153
-        parser.add_argument('--os-service-type',
154
-                            default=env('OS_DNS_SERVICE_TYPE', default='dns'),
155
-                            help=("Defaults to env[OS_DNS_SERVICE_TYPE], or "
156
-                                  "'dns'."))
157
-
158
-        parser.add_argument('--os-cacert',
159
-                            default=env('OS_CACERT'),
160
-                            help=('CA certificate bundle file. Defaults to '
161
-                                  'env[OS_CACERT].'))
162
-
163
-        parser.add_argument('--insecure', action='store_true',
164
-                            help="Explicitly allow 'insecure' SSL requests.")
165
-
166
-        parser.add_argument('--all-tenants', action='store_true',
167
-                            help="Allows to list all domains from all "
168
-                            "tenants.")
169
-
170
-        parser.add_argument('--edit-managed', action='store_true',
171
-                            help='Allows to edit records that are marked as '
172
-                            'managed.')
173
-
174
-        return parser
175
-
176
-    def configure_logging(self):
177
-        """Configure logging for the app
178
-
179
-        Cliff sets some defaults we don't want so re-work it a bit
180
-        """
181
-
182
-        if self.options.debug:
183
-            # --debug forces verbose_level 3
184
-            # Set this here so cliff.app.configure_logging() can work
185
-            self.options.verbose_level = 3
186
-
187
-        super(DesignateShell, self).configure_logging()
188
-        root_logger = logging.getLogger('')
189
-
190
-        # Requests logs some stuff at INFO that we don't want
191
-        # unless we have DEBUG
192
-        requests_log = logging.getLogger("requests")
193
-        requests_log.setLevel(logging.ERROR)
194
-
195
-        # Other modules we don't want DEBUG output for so
196
-        # don't reset them below
197
-        iso8601_log = logging.getLogger("iso8601")
198
-        iso8601_log.setLevel(logging.ERROR)
199
-
200
-        # Set logging to the requested level
201
-        self.dump_stack_trace = False
202
-        if self.options.verbose_level == 0:
203
-            # --quiet
204
-            root_logger.setLevel(logging.ERROR)
205
-        elif self.options.verbose_level == 1:
206
-            # This is the default case, no --debug, --verbose or --quiet
207
-            root_logger.setLevel(logging.WARNING)
208
-        elif self.options.verbose_level == 2:
209
-            # One --verbose
210
-            root_logger.setLevel(logging.INFO)
211
-        elif self.options.verbose_level >= 3:
212
-            # Two or more --verbose
213
-            root_logger.setLevel(logging.DEBUG)
214
-            requests_log.setLevel(logging.DEBUG)
215
-
216
-        if self.options.debug:
217
-            # --debug forces traceback
218
-            self.dump_stack_trace = True
219
-
220
-    def initialize_app(self, argv):
221
-        super(DesignateShell, self).initialize_app(argv)
222
-        self.session = utils.get_session(
223
-            auth_url=self.options.os_auth_url,
224
-            endpoint=self.options.os_endpoint,
225
-            domain_id=self.options.os_domain_id,
226
-            domain_name=self.options.os_domain_name,
227
-            project_id=self.options.os_project_id or self.options.os_tenant_id,
228
-            project_name=(self.options.os_project_name or
229
-                          self.options.os_tenant_name),
230
-            project_domain_name=self.options.os_project_domain_name,
231
-            project_domain_id=self.options.os_project_domain_id,
232
-            username=self.options.os_username,
233
-            user_id=self.options.os_user_id,
234
-            password=self.options.os_password,
235
-            user_domain_id=self.options.os_user_domain_id,
236
-            user_domain_name=self.options.os_user_domain_name,
237
-            token=self.options.os_token,
238
-            insecure=self.options.insecure,
239
-            cacert=self.options.os_cacert
240
-        )
241
-
242
-    def run(self, argv):
243
-        try:
244
-            return super(DesignateShell, self).run(argv)
245
-        except Exception as e:
246
-            if not logging.getLogger('').handlers:
247
-                logging.basicConfig()
248
-            if self.dump_stack_trace:
249
-                self.log.error(traceback.format_exc(e))
250
-            else:
251
-                self.log.error('Exception raised: ' + str(e))
252
-            return 1

+ 0
- 21
designateclient/tests/test_utils.py View File

@@ -62,24 +62,3 @@ class UtilsTestCase(base.TestCase):
62 62
         self.assertRaises(exceptions.NoUniqueMatch,
63 63
                           self._find_resourceid_by_name_or_id,
64 64
                           'baba', by_name=True)
65
-
66
-    def test_load_schema(self):
67
-        schema = utils.load_schema('v1', 'domain')
68
-        self.assertIsInstance(schema, dict)
69
-
70
-    def test_load_schema_missing(self):
71
-        self.assertRaises(exceptions.ResourceNotFound, utils.load_schema,
72
-                          'v1', 'missing')
73
-
74
-    def test_resource_string_empty_param(self):
75
-        self.assertRaises(ValueError, utils.resource_string)
76
-
77
-    def test_resource_string(self):
78
-        name = ['schemas', 'v1', 'domain.json']
79
-        resource_string = utils.resource_string(*name)
80
-        self.assertIsNotNone(resource_string)
81
-
82
-    def test_resource_string_missing(self):
83
-        name = ['schemas', 'v1', 'missing']
84
-        self.assertRaises(exceptions.ResourceNotFound, utils.resource_string,
85
-                          *name)

+ 0
- 53
designateclient/tests/test_v1/__init__.py View File

@@ -1,53 +0,0 @@
1
-# Copyright 2015 Hewlett-Packard Development Company, L.P.
2
-#
3
-# Author: Kiall Mac Innes <kiall@hp.com>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-import uuid
17
-
18
-from designateclient.tests import base
19
-
20
-
21
-class CrudMixin(object):
22
-    path_prefix = None
23
-
24
-    def new_ref(self, **kwargs):
25
-        kwargs.setdefault('id', uuid.uuid4().hex)
26
-        return kwargs
27
-
28
-    def stub_entity(self, method, parts=None, entity=None, id=None, **kwargs):
29
-        if entity:
30
-            kwargs['json'] = entity
31
-
32
-        if not parts:
33
-            parts = [self.RESOURCE]
34
-
35
-            if self.path_prefix:
36
-                parts.insert(0, self.path_prefix)
37
-
38
-        if id:
39
-            if not parts:
40
-                parts = []
41
-
42
-            parts.append(id)
43
-
44
-        self.stub_url(method, parts=parts, **kwargs)
45
-
46
-    def assertList(self, expected, actual):
47
-        self.assertEqual(len(expected), len(actual))
48
-        for i in expected:
49
-            self.assertIn(i, actual)
50
-
51
-
52
-class APIV1TestCase(base.APITestCase):
53
-    VERSION = "1"

+ 0
- 124
designateclient/tests/test_v1/test_client.py View File

@@ -1,124 +0,0 @@
1
-# Copyright 2015 Hewlett-Packard Development Company, L.P.
2
-#
3
-# Author: Kiall Mac Innes <kiall@hp.com>
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-from designateclient.tests import test_v1
18
-from designateclient import utils
19
-from designateclient import v1
20
-
21
-from keystoneauth1 import session as keystone_session
22
-
23
-
24
-class TestClient(test_v1.APIV1TestCase):
25
-    def test_all_tenants(self):
26
-        # Create a client with the all_tenants flag set to True
27
-        client = v1.Client(all_tenants=True)
28
-
29
-        # Verify this has been picked up
30
-        self.assertTrue(client.all_tenants)
31
-
32
-    def test_all_tenants_not_supplied(self):
33
-        # Create a client without supplying any all_tenants flag
34
-        client = v1.Client()
35
-
36
-        # Verify all_tenants is False
37
-        self.assertFalse(client.all_tenants)
38
-        self.assertIsNotNone(client.all_tenants)
39
-
40
-    def test_all_tenants_through_session(self):
41
-        # Create a session with the all_tenants flag set to True
42
-        session = utils.get_session(
43
-            auth_url='Anything',
44
-            endpoint='Anything',
45
-            domain_id='Anything',
46
-            domain_name='Anything',
47
-            project_id='Anything',
48
-            project_name='Anything',
49
-            project_domain_name='Anything',
50
-            project_domain_id='Anything',
51
-            username='Anything',
52
-            user_id='Anything',
53
-            password='Anything',
54
-            user_domain_id='Anything',
55
-            user_domain_name='Anything',
56
-            token=None,
57
-            insecure=False,
58
-            cacert=None,
59
-            all_tenants=True)
60
-
61
-        # Create a client using the pre-created session
62
-        client = v1.Client(session=session)
63
-
64
-        # Verify the all_tenants flag has been picked up
65
-        self.assertTrue(client.all_tenants)
66
-
67
-    def test_edit_managed(self):
68
-        # Create a client with the edit_managed flag set to True
69
-        client = v1.Client(edit_managed=True)
70
-
71
-        # Verify this has been picked up
72
-        self.assertTrue(client.edit_managed)
73
-
74
-    def test_edit_managed_not_supplied(self):
75
-        # Create a client without supplying any edit_managed flag
76
-        client = v1.Client()
77
-
78
-        # Verify edit_managed is False
79
-        self.assertFalse(client.edit_managed)
80
-        self.assertIsNotNone(client.edit_managed)
81
-
82
-    def test_edit_managed_through_session(self):
83
-        # Create a session with the edit_managed flag set to True
84
-        session = utils.get_session(
85
-            auth_url='Anything',
86
-            endpoint='Anything',
87
-            domain_id='Anything',
88
-            domain_name='Anything',
89
-            project_id='Anything',
90
-            project_name='Anything',
91
-            project_domain_name='Anything',
92
-            project_domain_id='Anything',
93
-            username='Anything',
94
-            user_id='Anything',
95
-            password='Anything',
96
-            user_domain_id='Anything',
97
-            user_domain_name='Anything',
98
-            token=None,
99
-            insecure=False,
100
-            cacert=None,
101
-            edit_managed=True)
102
-
103
-        # Create a client using the pre-created session
104
-        client = v1.Client(session=session)
105
-
106
-        # Verify the edit_managed flag has been picked up
107
-        self.assertTrue(client.edit_managed)
108
-
109
-    def test_timeout_new_session(self):
110
-        client = v1.Client(
111
-            auth_url="http://127.0.0.1:22/",
112
-            timeout=1,
113
-        )
114
-        assert client.session.timeout == 1
115
-
116
-    def test_timeout_override_session_timeout(self):
117
-        # The adapter timeout should override the session timeout
118
-        session = keystone_session.Session(timeout=10)
119
-        client = v1.Client(
120
-            auth_url="http://127.0.0.1:22/",
121
-            session=session,
122
-            timeout=2,
123
-        )
124
-        self.assertEqual(2, client.session.timeout)

+ 0
- 30
designateclient/tests/test_v1/test_diagnostics.py View File

@@ -1,30 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import mock
16
-from mock import patch
17
-
18
-from designateclient.tests import test_v1
19
-from designateclient.v1 import diagnostics
20
-
21
-
22
-class TestDiagnostics(test_v1.APIV1TestCase, test_v1.CrudMixin):
23
-
24
-    @patch.object(diagnostics.DiagnosticsController, "ping")
25
-    def test_ping(self, ping):
26
-        args = mock.MagicMock()
27
-        args.service = "foo"
28
-        args.host = "host1"
29
-        self.client.diagnostics.ping(args.host, args.service)
30
-        self.client.diagnostics.ping.assert_called_with("host1", "foo")

+ 0
- 184
designateclient/tests/test_v1/test_domain.py View File

@@ -1,184 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import uuid
16
-
17
-from mock import patch
18
-
19
-from designateclient.tests import test_v1
20
-from designateclient import utils
21
-from designateclient.v1 import domains
22
-from designateclient import warlock
23
-
24
-Domain = warlock.model_factory(utils.load_schema('v1', 'domain'))
25
-
26
-
27
-class TestDomain(test_v1.APIV1TestCase, test_v1.CrudMixin):
28
-    RESOURCE = 'domains'
29
-
30
-    def new_ref(self, **kwargs):
31
-        ref = super(TestDomain, self).new_ref(**kwargs)
32
-        ref.setdefault("name", uuid.uuid4().hex)
33
-        ref.setdefault("email", "abc@example.com.")
34
-        ref.setdefault("ttl", 3600)
35
-        return ref
36
-
37
-    def test_create(self):
38
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
39
-               "name": "domain1.com.",
40
-               "email": "nsadmin@example.org",
41
-               "ttl": 60}
42
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
43
-
44
-        values = ref.copy()
45
-        del values["id"]
46
-
47
-        response = self.client.domains.create(values["name"])
48
-        self.assertEqual(ref['id'], response['id'])
49
-
50
-    def test_create_with_description(self):
51
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
52
-               "name": "domain1.com.",
53
-               "email": "nsadmin@example.org",
54
-               "ttl": 60,
55
-               "description": "fully qualified domain"}
56
-
57
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
58
-
59
-        values = ref.copy()
60
-        del values["id"]
61
-
62
-        response = self.client.domains.create(values["name"])
63
-        self.assertEqual(ref['id'], response['id'])
64
-
65
-    def test_create_with_description_too_long(self):
66
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
67
-               "name": "domain1.com.",
68
-               "email": "nsadmin@example.org",
69
-               "ttl": 60,
70
-               "description": "d" * 161}
71
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
72
-
73
-        values = ref.copy()
74
-        del values["id"]
75
-
76
-        self.assertRaises(ValueError, self.client.domains.create,
77
-                          values["name"])
78
-
79
-    def test_create_with_zero_ttl(self):
80
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
81
-               "name": "domain1.com.",
82
-               "email": "nsadmin@example.org",
83
-               "ttl": 0}
84
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
85
-
86
-        values = ref.copy()
87
-        del values["id"]
88
-
89
-        self.assertRaises(ValueError, self.client.domains.create,
90
-                          values["name"])
91
-
92
-    def test_create_with_negative_ttl(self):
93
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
94
-               "name": "domain1.com.",
95
-               "email": "nsadmin@example.org",
96
-               "ttl": -1}
97
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
98
-
99
-        values = ref.copy()
100
-        del values["id"]
101
-
102
-        self.assertRaises(ValueError, self.client.domains.create,
103
-                          values["name"])
104
-
105
-    def test_create_with_no_ttl(self):
106
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
107
-               "name": "domain1.com.",
108
-               "email": "nsadmin@example.org",
109
-               "ttl": ""}
110
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
111
-
112
-        values = ref.copy()
113
-        del values["id"]
114
-
115
-        self.assertRaises(ValueError, self.client.domains.create,
116
-                          values["name"])
117
-
118
-    def test_create_with_name_too_long(self):
119
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
120
-               "name": "domain" + "a" * 255 + ".com.",
121
-               "email": "nsadmin@example.org",
122
-               "ttl": 60}
123
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
124
-
125
-        values = ref.copy()
126
-        del values["id"]
127
-
128
-        self.assertRaises(ValueError, self.client.domains.create,
129
-                          values["name"])
130
-
131
-    def test_list(self):
132
-        items = [
133
-            self.new_ref(email="abc@example.org",
134
-                         id="89acac79-38e7-497d-807c-a011e1310438"),
135
-            self.new_ref(email="root@example.org",
136
-                         id="89acac79-38e7-497d-807c-a011e1310435")
137
-        ]
138
-
139
-        self.stub_url("GET", parts=[self.RESOURCE], json={"domains": items})
140
-
141
-        listed = self.client.domains.list()
142
-        self.assertList(items, listed)
143
-        self.assertQueryStringIs("")
144
-
145
-    def test_get(self):
146
-        ref = self.new_ref(email="abc@example.org",
147
-                           id="89acac79-38e7-497d-807c-a011e1310438")
148
-
149
-        self.stub_entity("GET", entity=ref, id=ref["id"])
150
-
151
-        response = self.client.domains.get(ref["id"])
152
-        self.assertEqual(ref, response)
153
-
154
-    def test_delete(self):
155
-        ref = self.new_ref(email="abc@example.org",
156
-                           id="89acac79-38e7-497d-807c-a011e1310438")
157
-
158
-        self.stub_entity("DELETE", entity=ref, id=ref["id"])
159
-
160
-        self.client.domains.delete(ref["id"])
161
-        self.assertRequestBodyIs(None)
162
-
163
-    def test_update(self):
164
-        ref = self.new_ref(id="89acac79-38e7-497d-807c-a011e1310438")
165
-
166
-        self.stub_entity("PUT", entity=ref, id=ref["id"])
167
-
168
-        values = ref.copy()
169
-
170
-        self.client.domains.update(Domain(values))
171
-
172
-    @patch.object(domains.DomainsController, "list_domain_servers")
173
-    def test_list_domain_servers(self, domains_get):
174
-        domains_get.return_value = [{"id": "foo", "name": "ns1.example.com."}]
175
-
176
-        ref = [{
177
-            "id": "foo",
178
-            "name": "ns1.example.com.",
179
-        }]
180
-        parts = ["domains", "foo", "servers"]
181
-        self.stub_url("GET", parts=parts, json={"servers": ref})
182
-
183
-        response = self.client.domains.list_domain_servers("foo")
184
-        self.assertEqual(ref, response)

+ 0
- 48
designateclient/tests/test_v1/test_quotas.py View File

@@ -1,48 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import mock
16
-from mock import patch
17
-
18
-from designateclient.tests import test_v1
19
-from designateclient.v1 import quotas
20
-
21
-
22
-class TestQuota(test_v1.APIV1TestCase, test_v1.CrudMixin):
23
-
24
-    @patch.object(quotas.QuotasController, "get")
25
-    def test_get(self, quota_get):
26
-        QUOTA = {"domains": 10,
27
-                 "recordset_records": 20,
28
-                 "domain_records": 500,
29
-                 "domain_recordsets": 500}
30
-        quota_get.return_value = QUOTA
31
-        response = self.client.quotas.get("foo")
32
-        self.assertEqual(QUOTA, response)
33
-
34
-    @patch.object(quotas.QuotasController, "update")
35
-    def test_update(self, quota_update):
36
-        args = mock.MagicMock()
37
-        args.tenant_id = "1234"
38
-        args.value = {"domains": 1000}
39
-        self.client.quotas.update(args.tenant_id, args.value)
40
-        self.client.quotas.update.assert_called_with(args.tenant_id,
41
-                                                     args.value)
42
-
43
-    @patch.object(quotas.QuotasController, "reset")
44
-    def test_reset(self, quota_reset):
45
-        args = mock.MagicMock()
46
-        args.tenant_id = "1234"
47
-        self.client.quotas.reset(args.tenant_id)
48
-        self.client.quotas.reset.assert_called_with("1234")

+ 0
- 222
designateclient/tests/test_v1/test_records.py View File

@@ -1,222 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import uuid
16
-
17
-from designateclient.tests import test_v1
18
-from designateclient import utils
19
-from designateclient import warlock
20
-
21
-
22
-Record = warlock.model_factory(utils.load_schema('v1', 'record'))
23
-
24
-DOMAIN = {
25
-    "id": str(uuid.uuid4()),
26
-    "name": "example.com."
27
-}
28
-
29
-
30
-class TestRecords(test_v1.APIV1TestCase, test_v1.CrudMixin):
31
-    RESOURCE = 'records'
32
-
33
-    def new_ref(self, **kwargs):
34
-        ref = super(TestRecords, self).new_ref(**kwargs)
35
-        ref.setdefault("name", uuid.uuid4().hex)
36
-        ref.setdefault("type", "A")
37
-        ref.setdefault("data", "10.0.0.1")
38
-        return ref
39
-
40
-    def test_create_record(self):
41
-        ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad")
42
-
43
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
44
-        self.stub_url("POST", parts=parts, json=ref)
45
-
46
-        values = ref.copy()
47
-        del values["id"]
48
-
49
-        self.client.records.create(DOMAIN['id'], Record(values))
50
-        self.assertRequestBodyIs(json=values)
51
-
52
-    def test_create_AAAA_record(self):
53
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778888",
54
-                           type="AAAA",
55
-                           data="2001:db8:0:1234:0:5678:9:12")
56
-
57
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
58
-        self.stub_url("POST", parts=parts, json=ref)
59
-
60
-        values = ref.copy()
61
-        del values["id"]
62
-
63
-        self.client.records.create(DOMAIN['id'], Record(values))
64
-        self.assertRequestBodyIs(json=values)
65
-
66
-    def test_create_MX_record(self):
67
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778989",
68
-                           type="MX",
69
-                           data="mail.example.com.",
70
-                           priority=10)
71
-
72
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
73
-        self.stub_url("POST", parts=parts, json=ref)
74
-
75
-        values = ref.copy()
76
-        del values["id"]
77
-
78
-        self.client.records.create(DOMAIN['id'], Record(values))
79
-        self.assertRequestBodyIs(json=values)
80
-
81
-    def test_create_CNAME_record(self):
82
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778890",
83
-                           type="CNAME",
84
-                           data="example.com.")
85
-
86
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
87
-        self.stub_url("POST", parts=parts, json=ref)
88
-
89
-        values = ref.copy()
90
-        del values["id"]
91
-
92
-        self.client.records.create(DOMAIN['id'], Record(values))
93
-        self.assertRequestBodyIs(json=values)
94
-
95
-    def test_create_TXT_record(self):
96
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778889",
97
-                           type="TXT",
98
-                           data="This is a TXT record")
99
-
100
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
101
-        self.stub_url("POST", parts=parts, json=ref)
102
-
103
-        values = ref.copy()
104
-        del values["id"]
105
-
106
-        self.client.records.create(DOMAIN['id'], Record(values))
107
-        self.assertRequestBodyIs(json=values)
108
-
109
-    def test_create_SRV_record(self):
110
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778888",
111
-                           type="SRV",
112
-                           data="0 5060 sip.example.com.",
113
-                           priority=30)
114
-
115
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
116
-        self.stub_url("POST", parts=parts, json=ref)
117
-
118
-        values = ref.copy()
119
-        del values["id"]
120
-
121
-        self.client.records.create(DOMAIN['id'], Record(values))
122
-        self.assertRequestBodyIs(json=values)
123
-
124
-    def test_create_NS_record(self):
125
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677779999",
126
-                           type="NS",
127
-                           data="ns1.example.com.")
128
-
129
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
130
-        self.stub_url("POST", parts=parts, json=ref)
131
-
132
-        values = ref.copy()
133
-        del values["id"]
134
-
135
-        self.client.records.create(DOMAIN['id'], Record(values))
136
-        self.assertRequestBodyIs(json=values)
137
-
138
-    def test_create_PTR_record(self):
139
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778891",
140
-                           type="PTR",
141
-                           data="www.example.com.")
142
-
143
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
144
-        self.stub_url("POST", parts=parts, json=ref)
145
-
146
-        values = ref.copy()
147
-        del values["id"]
148
-
149
-        self.client.records.create(DOMAIN['id'], Record(values))
150
-        self.assertRequestBodyIs(json=values)
151
-
152
-    def test_create_SPF_record(self):
153
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778899",
154
-                           type="SPF",
155
-                           data="v=spf1 +mx a:colo.example.com/28 -all")
156
-
157
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
158
-        self.stub_url("POST", parts=parts, json=ref)
159
-
160
-        values = ref.copy()
161
-        del values["id"]
162
-
163
-        self.client.records.create(DOMAIN['id'], Record(values))
164
-        self.assertRequestBodyIs(json=values)
165
-
166
-    def test_create_SSHFP_record(self):
167
-        ref = self.new_ref(id="11112222-3333-4444-5555-666677778888",
168
-                           type="SSHFP",
169
-                           data="2 1 6c3c958af43d953f91f40e0d84157f4fe7b4a898")
170
-
171
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
172
-        self.stub_url("POST", parts=parts, json=ref)
173
-
174
-        values = ref.copy()
175
-        del values["id"]
176
-
177
-        self.client.records.create(DOMAIN['id'], Record(values))
178
-        self.assertRequestBodyIs(json=values)
179
-
180
-    def test_get(self):
181
-        ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad")
182
-
183
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
184
-        self.stub_entity("GET", entity=ref, id=ref["id"], parts=parts)
185
-
186
-        response = self.client.records.get(DOMAIN["id"], ref["id"])
187
-        self.assertEqual(ref, response)
188
-
189
-    def test_list(self):
190
-        items = [
191
-            self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad"),
192
-            self.new_ref(id="11112222-3333-4444-5555-666677778888")
193
-        ]
194
-
195
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
196
-        self.stub_url("GET", parts=parts, json={"records": items})
197
-
198
-        listed = self.client.records.list(DOMAIN["id"])
199
-        self.assertList(items, listed)
200
-        self.assertQueryStringIs("")
201
-
202
-    def test_update(self):
203
-        ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad",
204
-                           type="A",
205
-                           data="192.0.2.5")
206
-
207
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
208
-        self.stub_entity("PUT", entity=ref, id=ref["id"], parts=parts)
209
-
210
-        values = ref.copy()
211
-        del values["id"]
212
-
213
-        self.client.records.update(DOMAIN["id"], Record(ref))
214
-
215
-    def test_delete(self):
216
-        ref = self.new_ref()
217
-
218
-        parts = ["domains", DOMAIN["id"], self.RESOURCE]
219
-        self.stub_entity("DELETE", id=ref["id"], parts=parts)
220
-
221
-        self.client.records.delete(DOMAIN["id"], ref["id"])
222
-        self.assertRequestBodyIs(None)

+ 0
- 54
designateclient/tests/test_v1/test_reports.py View File

@@ -1,54 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import mock
16
-from mock import patch
17
-
18
-from designateclient.tests import test_v1
19
-from designateclient.v1 import reports
20
-
21
-
22
-class TestReports(test_v1.APIV1TestCase, test_v1.CrudMixin):
23
-
24
-    @patch.object(reports.ReportsController, "count_all")
25
-    def test_count_all(self, count_all):
26
-        self.client.reports.count_all()
27
-        self.client.reports.count_all.assert_called_with()
28
-
29
-    @patch.object(reports.ReportsController, "count_domains")
30
-    def test_count_domain(self, count_domains):
31
-        self.client.reports.count_domains()
32
-        self.client.reports.count_domains.assert_called_once_with()
33
-
34
-    @patch.object(reports.ReportsController, "count_tenants")
35
-    def test_count_tenants(self, count_tenants):
36
-        self.client.reports.count_tenants()
37
-        self.client.reports.count_tenants.assert_called_once_with()
38
-
39
-    @patch.object(reports.ReportsController, "count_records")
40
-    def test_count_records(self, count_records):
41
-        self.client.reports.count_records()
42
-        self.client.reports.count_records.assert_called_once_with()
43
-
44
-    @patch.object(reports.ReportsController, "tenants_all")
45
-    def test_tenants_all(self, tenants_all):
46
-        self.client.reports.tenants_all()
47
-        self.client.reports.tenants_all.assert_called_once_with()
48
-
49
-    @patch.object(reports.ReportsController, "tenant_domains")
50
-    def test_tenant_domains(self, tenant_domains):
51
-        args = mock.MagicMock()
52
-        args.other_tenant_id = "uuid"
53
-        self.client.reports.tenant_domains(args.other_tenant_id)
54
-        self.client.reports.tenant_domains.assert_called_once_with("uuid")

+ 0
- 95
designateclient/tests/test_v1/test_servers.py View File

@@ -1,95 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import uuid
16
-
17
-import mock
18
-from mock import patch
19
-
20
-from designateclient.tests import test_v1
21
-from designateclient.v1 import servers
22
-
23
-
24
-class TestServers(test_v1.APIV1TestCase, test_v1.CrudMixin):
25
-    RESOURCE = 'servers'
26
-
27
-    def new_ref(self, **kwargs):
28
-        ref = super(TestServers, self).new_ref(**kwargs)
29
-        ref.setdefault("name", uuid.uuid4().hex)
30
-        return ref
31
-
32
-    def test_list(self):
33
-        items = [
34
-            self.new_ref(name="ns1.example.org.",
35
-                         id="89acac79-38e7-497d-807c-a011e1310438"),
36
-            self.new_ref(name="ns2.example.org.",
37
-                         id="89acac79-38e7-497d-807c-a011e1310435")
38
-        ]
39
-
40
-        self.stub_url("GET", parts=[self.RESOURCE], json={"servers": items})
41
-
42
-        listed = self.client.servers.list()
43
-        self.assertList(items, listed)
44
-        self.assertQueryStringIs("")
45
-
46
-    def test_get(self):
47
-        ref = self.new_ref(name="ns1.example.org.",
48
-                           id="89acac79-38e7-497d-807c-a011e1310438")
49
-
50
-        self.stub_entity("GET", entity=ref, id=ref["id"])
51
-
52
-        response = self.client.servers.get(ref["id"])
53
-        self.assertEqual(ref, response)
54
-
55
-    def test_create(self):
56
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
57
-               "name": "ns1.example.org."}
58
-
59
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
60
-
61
-        values = ref.copy()
62
-        del values["id"]
63
-
64
-        self.client.servers.create({"name": "ns1.example.org."})
65
-        self.assertRequestBodyIs(json=values)
66
-
67
-    def test_create_with_name_too_long(self):
68
-        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
69
-               "name": "ns1." + "foo" * 85 + ".org."}
70
-
71
-        self.stub_url("POST", parts=[self.RESOURCE], json=ref)
72
-
73
-        values = ref.copy()
74
-        del values["id"]
75
-
76
-        self.assertRaises(ValueError, self.client.servers.create,
77
-                          {"name": "ns1.example.org."})
78
-
79
-    @patch.object(servers.ServersController, "update")
80
-    def test_update(self, server_update):
81
-        ref = self.new_ref()
82
-
83
-        self.stub_entity("PUT", entity=ref, id=ref["id"])
84
-
85
-        mock_server = mock.MagicMock()
86
-        self.client.servers.update(mock_server)
87
-        self.client.servers.update.assert_called_with(mock_server)
88
-
89
-    def test_delete(self):
90
-        ref = self.new_ref()
91
-
92
-        self.stub_entity("DELETE", id=ref["id"])
93
-
94
-        self.client.servers.delete(ref["id"])
95
-        self.assertRequestBodyIs(None)

+ 0
- 42
designateclient/tests/test_v1/test_sync.py View File

@@ -1,42 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import mock
16
-from mock import patch
17
-
18
-from designateclient.tests import test_v1
19
-from designateclient.v1 import sync
20
-
21
-
22
-class TestSync(test_v1.APIV1TestCase, test_v1.CrudMixin):
23
-
24
-    @patch.object(sync.SyncController, "sync_all")
25
-    def test_sync_all(self, sync_all):
26
-        self.client.sync.sync_all()
27
-        self.client.sync.sync_all.assert_called_with()
28
-
29
-    @patch.object(sync.SyncController, "sync_domain")
30
-    def test_sync_domain(self, sync_domain):
31
-        args = mock.MagicMock()
32
-        args.tenant_id = "1234"
33
-        self.client.sync.sync_domain(args.tenant_id)
34
-        self.client.sync.sync_domain.assert_called_with("1234")
35
-
36
-    @patch.object(sync.SyncController, "sync_record")
37
-    def test_sync_record(self, sync_record):
38
-        args = mock.MagicMock()
39
-        args.tenant_id = "1234"
40
-        args.record_id = "uuid"
41
-        self.client.sync.sync_record(args.tenant_id, args.record_id)
42
-        self.client.sync.sync_record.assert_called_with("1234", "uuid")

+ 0
- 29
designateclient/tests/test_v1/test_touch.py View File

@@ -1,29 +0,0 @@
1
-# Copyright 2015 NEC Corporation.  All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-import mock
16
-from mock import patch
17
-
18
-from designateclient.tests import test_v1