Initial and incomplete conversion from designate to tatu.
This commit is contained in:
parent
65cc292267
commit
2f684da0aa
@ -15,7 +15,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import sys
|
import sys
|
||||||
from designateclient.shell import DesignateShell
|
from tatuclient.shell import DesignateShell
|
||||||
|
|
||||||
shell = DesignateShell()
|
shell = DesignateShell()
|
||||||
sys.exit(shell.run(sys.argv[1:]))
|
sys.exit(shell.run(sys.argv[1:]))
|
||||||
|
@ -1,139 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import abc
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exceptions
|
|
||||||
from osc_lib.command import command
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import exceptions
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v1 import Client
|
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
|
||||||
class Command(command.Command):
|
|
||||||
def run(self, parsed_args):
|
|
||||||
|
|
||||||
warnings.simplefilter('once', category=DeprecationWarning)
|
|
||||||
warnings.warn(
|
|
||||||
'The "designate" CLI is being deprecated in favour of the '
|
|
||||||
'"openstack" CLI plugin. All designate API v2 commands are '
|
|
||||||
'implemented there. When the v1 API is removed this CLI will '
|
|
||||||
'stop functioning',
|
|
||||||
DeprecationWarning)
|
|
||||||
warnings.resetwarnings()
|
|
||||||
warnings.simplefilter('ignore', category=DeprecationWarning)
|
|
||||||
|
|
||||||
self.client = Client(
|
|
||||||
region_name=self.app.options.os_region_name,
|
|
||||||
service_type=self.app.options.os_service_type,
|
|
||||||
endpoint_type=self.app.options.os_endpoint_type,
|
|
||||||
session=self.app.session,
|
|
||||||
all_tenants=self.app.options.all_tenants,
|
|
||||||
edit_managed=self.app.options.edit_managed,
|
|
||||||
endpoint=self.app.options.os_endpoint)
|
|
||||||
warnings.resetwarnings()
|
|
||||||
try:
|
|
||||||
return super(Command, self).run(parsed_args)
|
|
||||||
except exceptions.RemoteError as e:
|
|
||||||
columns = ['Code', 'Type']
|
|
||||||
values = [e.code, e.type]
|
|
||||||
|
|
||||||
if e.message:
|
|
||||||
columns.append('Message')
|
|
||||||
values.append(e.message)
|
|
||||||
|
|
||||||
if e.errors:
|
|
||||||
columns.append('Errors')
|
|
||||||
values.append(e.errors)
|
|
||||||
|
|
||||||
self.error_output(parsed_args, columns, values)
|
|
||||||
except ks_exceptions.EndpointNotFound as e:
|
|
||||||
self.app.log.error('No endpoint was found. You must provide a '
|
|
||||||
'username or user id via --os-username, '
|
|
||||||
'--os-user-id, env[OS_USERNAME] or '
|
|
||||||
'env[OS_USER_ID]')
|
|
||||||
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def error_output(self, parsed_args, column_names, data):
|
|
||||||
self.formatter.emit_one(column_names,
|
|
||||||
data,
|
|
||||||
self.app.stdout,
|
|
||||||
parsed_args)
|
|
||||||
self.app.log.error('The requested action did not complete '
|
|
||||||
'successfully')
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
"""
|
|
||||||
Execute something, this is since we overload self.take_action()
|
|
||||||
in order to format the data
|
|
||||||
|
|
||||||
This method __NEEDS__ to be overloaded!
|
|
||||||
|
|
||||||
:param parsed_args: The parsed args that are given by take_action()
|
|
||||||
"""
|
|
||||||
|
|
||||||
def post_execute(self, data):
|
|
||||||
"""
|
|
||||||
Format the results locally if needed, by default we just return data
|
|
||||||
|
|
||||||
:param data: Whatever is returned by self.execute()
|
|
||||||
"""
|
|
||||||
return data
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
results = self.execute(parsed_args)
|
|
||||||
return self.post_execute(results)
|
|
||||||
|
|
||||||
def find_resourceid_by_name_or_id(self, resource_plural, name_or_id):
|
|
||||||
resource_client = getattr(self.client, resource_plural)
|
|
||||||
return utils.find_resourceid_by_name_or_id(resource_client, name_or_id)
|
|
||||||
|
|
||||||
|
|
||||||
class ListCommand(Command, command.Lister):
|
|
||||||
columns = None
|
|
||||||
|
|
||||||
def post_execute(self, results):
|
|
||||||
if len(results) > 0:
|
|
||||||
columns = self.columns or utils.get_columns(results)
|
|
||||||
data = [utils.get_item_properties(i, columns) for i in results]
|
|
||||||
return columns, data
|
|
||||||
else:
|
|
||||||
return [], ()
|
|
||||||
|
|
||||||
|
|
||||||
class GetCommand(Command, command.ShowOne):
|
|
||||||
def post_execute(self, results):
|
|
||||||
return list(six.iterkeys(results)), list(six.itervalues(results))
|
|
||||||
|
|
||||||
|
|
||||||
class CreateCommand(Command, command.ShowOne):
|
|
||||||
def post_execute(self, results):
|
|
||||||
return list(six.iterkeys(results)), list(six.itervalues(results))
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateCommand(Command, command.ShowOne):
|
|
||||||
def post_execute(self, results):
|
|
||||||
return list(six.iterkeys(results)), list(six.itervalues(results))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteCommand(Command, command.ShowOne):
|
|
||||||
def post_execute(self, results):
|
|
||||||
return [], []
|
|
@ -1,38 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class PingCommand(base.GetCommand):
|
|
||||||
"""Ping a service on a given host"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(PingCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--service', help="Service name (e.g. central)",
|
|
||||||
required=True)
|
|
||||||
parser.add_argument('--host', help="Hostname", required=True)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.diagnostics.ping(parsed_args.service,
|
|
||||||
parsed_args.host)
|
|
@ -1,144 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
from designateclient.v1.domains import Domain
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class ListDomainsCommand(base.ListCommand):
|
|
||||||
"""List Domains"""
|
|
||||||
|
|
||||||
columns = ['id', 'name', 'serial']
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.domains.list()
|
|
||||||
|
|
||||||
|
|
||||||
class GetDomainCommand(base.GetCommand):
|
|
||||||
"""Get Domain"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(GetDomainCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Domain ID or name.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
|
|
||||||
return self.client.domains.get(id)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateDomainCommand(base.CreateCommand):
|
|
||||||
"""Create Domain"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateDomainCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="Domain name.", required=True)
|
|
||||||
parser.add_argument('--email', help="Domain email.", required=True)
|
|
||||||
parser.add_argument('--ttl', type=int, help="Time to live (seconds).")
|
|
||||||
parser.add_argument('--description', help="Description.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
domain = Domain(
|
|
||||||
name=parsed_args.name,
|
|
||||||
email=parsed_args.email,
|
|
||||||
)
|
|
||||||
|
|
||||||
if parsed_args.description:
|
|
||||||
domain.description = parsed_args.description
|
|
||||||
|
|
||||||
if parsed_args.ttl is not None:
|
|
||||||
domain.ttl = parsed_args.ttl
|
|
||||||
|
|
||||||
return self.client.domains.create(domain)
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateDomainCommand(base.UpdateCommand):
|
|
||||||
"""Update Domain"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(UpdateDomainCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Domain ID or name.")
|
|
||||||
parser.add_argument('--name', help="Domain name.")
|
|
||||||
parser.add_argument('--email', help="Domain email.")
|
|
||||||
parser.add_argument('--ttl', type=int, help="Time to live (seconds).")
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description.")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
# TODO(kiall): API needs updating.. this get is silly
|
|
||||||
id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
|
|
||||||
domain = self.client.domains.get(id)
|
|
||||||
|
|
||||||
if parsed_args.name:
|
|
||||||
domain.name = parsed_args.name
|
|
||||||
|
|
||||||
if parsed_args.email:
|
|
||||||
domain.email = parsed_args.email
|
|
||||||
|
|
||||||
if parsed_args.ttl is not None:
|
|
||||||
domain.ttl = parsed_args.ttl
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
domain.description = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
domain.description = parsed_args.description
|
|
||||||
|
|
||||||
return self.client.domains.update(domain)
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteDomainCommand(base.DeleteCommand):
|
|
||||||
"""Delete Domain"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteDomainCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Domain ID or name.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
|
|
||||||
return self.client.domains.delete(id)
|
|
||||||
|
|
||||||
|
|
||||||
class ListDomainServersCommand(base.ListCommand):
|
|
||||||
"""List Domain Servers"""
|
|
||||||
|
|
||||||
columns = ['name']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListDomainServersCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Domain ID or name.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
id = self.find_resourceid_by_name_or_id('domains', parsed_args.id)
|
|
||||||
return self.client.domains.list_domain_servers(id)
|
|
@ -1,83 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class GetQuotaCommand(base.GetCommand):
|
|
||||||
"""Get Quota"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(GetQuotaCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('tenant_id', help="Tenant ID")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.quotas.get(parsed_args.tenant_id)
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateQuotaCommand(base.UpdateCommand):
|
|
||||||
"""Update Quota"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(UpdateQuotaCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('tenant_id', help="Tenant ID.")
|
|
||||||
parser.add_argument('--domains', help="Allowed domains.", type=int)
|
|
||||||
parser.add_argument('--domain-recordsets',
|
|
||||||
help="Allowed domain records.",
|
|
||||||
type=int)
|
|
||||||
parser.add_argument('--recordset-records',
|
|
||||||
help="Allowed recordset records.",
|
|
||||||
type=int)
|
|
||||||
parser.add_argument('--domain-records',
|
|
||||||
help="Allowed domain records.",
|
|
||||||
type=int)
|
|
||||||
parser.add_argument('--api-export-size',
|
|
||||||
help="Allowed zone export recordsets.",
|
|
||||||
type=int)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
# TODO(kiall): API needs updating.. this get is silly
|
|
||||||
quota = self.client.quotas.get(parsed_args.tenant_id)
|
|
||||||
|
|
||||||
for key, old in quota.items():
|
|
||||||
new = getattr(parsed_args, key)
|
|
||||||
if new is not None and new != old:
|
|
||||||
quota[key] = new
|
|
||||||
return self.client.quotas.update(parsed_args.tenant_id, quota)
|
|
||||||
|
|
||||||
|
|
||||||
class ResetQuotaCommand(base.DeleteCommand):
|
|
||||||
"""Reset Quota"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ResetQuotaCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('tenant_id', help="Tenant ID.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
self.client.quotas.reset(parsed_args.tenant_id)
|
|
@ -1,187 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
from designateclient.v1.records import Record
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class ListRecordsCommand(base.ListCommand):
|
|
||||||
"""List Records"""
|
|
||||||
|
|
||||||
columns = ['id', 'type', 'name', 'data']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListRecordsCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID or name.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
domain_id = self.find_resourceid_by_name_or_id(
|
|
||||||
'domains', parsed_args.domain_id)
|
|
||||||
return self.client.records.list(domain_id)
|
|
||||||
|
|
||||||
|
|
||||||
class GetRecordCommand(base.GetCommand):
|
|
||||||
"""Get Record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(GetRecordCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID or name.")
|
|
||||||
parser.add_argument('id', help="Record ID.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
domain_id = self.find_resourceid_by_name_or_id(
|
|
||||||
'domains', parsed_args.domain_id)
|
|
||||||
return self.client.records.get(domain_id, parsed_args.id)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRecordCommand(base.CreateCommand):
|
|
||||||
"""Create Record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateRecordCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID or name.")
|
|
||||||
parser.add_argument(
|
|
||||||
'--name', help="Record (relative|absolute) name.", required=True)
|
|
||||||
parser.add_argument('--type', help="Record type.", required=True)
|
|
||||||
parser.add_argument('--data', help="Record data.", required=True)
|
|
||||||
parser.add_argument('--ttl', type=int, help="Record TTL.")
|
|
||||||
parser.add_argument('--priority', type=int, help="Record priority.")
|
|
||||||
parser.add_argument('--description', help="Description.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
domain_id = self.find_resourceid_by_name_or_id(
|
|
||||||
'domains', parsed_args.domain_id)
|
|
||||||
|
|
||||||
if not parsed_args.name.endswith('.'):
|
|
||||||
# Relative name?
|
|
||||||
domain_name = self.client.domains.get(domain_id)['name']
|
|
||||||
absolute = parsed_args.name + '.'
|
|
||||||
relative = absolute + domain_name
|
|
||||||
if absolute.endswith('.' + domain_name):
|
|
||||||
# Relative name or absolute name missing final period?
|
|
||||||
msg = ('"%s" is a relative name but looks like an absolute '
|
|
||||||
'name, use --name "%s" or "%s"'
|
|
||||||
% (parsed_args.name, absolute, relative))
|
|
||||||
raise ValueError(msg)
|
|
||||||
parsed_args.name = relative
|
|
||||||
|
|
||||||
record = Record(
|
|
||||||
name=parsed_args.name,
|
|
||||||
type=parsed_args.type,
|
|
||||||
data=parsed_args.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
if parsed_args.ttl is not None:
|
|
||||||
record.ttl = parsed_args.ttl
|
|
||||||
|
|
||||||
if parsed_args.priority is not None:
|
|
||||||
record.priority = parsed_args.priority
|
|
||||||
|
|
||||||
if parsed_args.description:
|
|
||||||
record.description = parsed_args.description
|
|
||||||
|
|
||||||
return self.client.records.create(domain_id, record)
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateRecordCommand(base.UpdateCommand):
|
|
||||||
"""Update Record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(UpdateRecordCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID or name.")
|
|
||||||
parser.add_argument('id', help="Record ID.")
|
|
||||||
parser.add_argument('--name', help="Record name.")
|
|
||||||
parser.add_argument('--type', help="Record type.")
|
|
||||||
parser.add_argument('--data', help="Record data.")
|
|
||||||
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description.")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
ttl_group = parser.add_mutually_exclusive_group()
|
|
||||||
ttl_group.add_argument('--ttl', type=int,
|
|
||||||
help="Record time to live (seconds).")
|
|
||||||
ttl_group.add_argument('--no-ttl', action='store_true')
|
|
||||||
|
|
||||||
priotity_group = parser.add_mutually_exclusive_group()
|
|
||||||
priotity_group.add_argument('--priority', type=int,
|
|
||||||
help="Record priority.")
|
|
||||||
priotity_group.add_argument('--no-priority', action='store_true')
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
# TODO(kiall): API needs updating.. this get is silly
|
|
||||||
record = self.client.records.get(parsed_args.domain_id, parsed_args.id)
|
|
||||||
|
|
||||||
if parsed_args.name:
|
|
||||||
record.name = parsed_args.name
|
|
||||||
|
|
||||||
if parsed_args.type:
|
|
||||||
record.type = parsed_args.type
|
|
||||||
|
|
||||||
if parsed_args.data:
|
|
||||||
record.data = parsed_args.data
|
|
||||||
|
|
||||||
if parsed_args.no_ttl:
|
|
||||||
record.ttl = None
|
|
||||||
elif parsed_args.ttl is not None:
|
|
||||||
record.ttl = parsed_args.ttl
|
|
||||||
|
|
||||||
if parsed_args.no_priority:
|
|
||||||
record.priority = None
|
|
||||||
elif parsed_args.priority is not None:
|
|
||||||
record.priority = parsed_args.priority
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
record.description = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
record.description = parsed_args.description
|
|
||||||
|
|
||||||
domain_id = self.find_resourceid_by_name_or_id(
|
|
||||||
'domains', parsed_args.domain_id)
|
|
||||||
return self.client.records.update(domain_id, record)
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteRecordCommand(base.DeleteCommand):
|
|
||||||
"""Delete Record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteRecordCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID or name.")
|
|
||||||
parser.add_argument('id', help="Record ID.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
domain_id = self.find_resourceid_by_name_or_id(
|
|
||||||
'domains', parsed_args.domain_id)
|
|
||||||
return self.client.records.delete(domain_id, parsed_args.id)
|
|
@ -1,71 +0,0 @@
|
|||||||
# Copyright 2013 Hewlett-Packard Development Company, L.P. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Author: Patrick Galbraith <patg@patg.net>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.cli import base
|
|
||||||
|
|
||||||
|
|
||||||
class DomainCountCommand(base.GetCommand):
|
|
||||||
"""Get counts for total domains"""
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.reports.count_domains()
|
|
||||||
|
|
||||||
|
|
||||||
class RecordCountCommand(base.GetCommand):
|
|
||||||
"""Get counts for total records"""
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.reports.count_records()
|
|
||||||
|
|
||||||
|
|
||||||
class TenantCountCommand(base.GetCommand):
|
|
||||||
"""Get counts for total tenants"""
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.reports.count_tenants()
|
|
||||||
|
|
||||||
|
|
||||||
class CountsCommand(base.GetCommand):
|
|
||||||
"""Get count totals for all tenants, domains and records"""
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.reports.count_all()
|
|
||||||
|
|
||||||
|
|
||||||
class TenantsCommand(base.ListCommand):
|
|
||||||
"""Get list of tenants and domain count for each"""
|
|
||||||
|
|
||||||
columns = ['domain_count', 'id']
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.reports.tenants_all()
|
|
||||||
|
|
||||||
|
|
||||||
class TenantCommand(base.ListCommand):
|
|
||||||
"""Get a list of domains for given tenant"""
|
|
||||||
|
|
||||||
columns = ['domain']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(TenantCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--report-tenant-id',
|
|
||||||
help="The tenant_id being reported on.",
|
|
||||||
required=True)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.reports.tenant_domains(parsed_args.report_tenant_id)
|
|
@ -1,98 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
from designateclient.v1.servers import Server
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class ListServersCommand(base.ListCommand):
|
|
||||||
"""List Servers"""
|
|
||||||
|
|
||||||
columns = ['id', 'name']
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.servers.list()
|
|
||||||
|
|
||||||
|
|
||||||
class GetServerCommand(base.GetCommand):
|
|
||||||
"""Get Server"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(GetServerCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Server ID.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.servers.get(parsed_args.id)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateServerCommand(base.CreateCommand):
|
|
||||||
"""Create Server"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateServerCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="Server name.", required=True)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
server = Server(
|
|
||||||
name=parsed_args.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
return self.client.servers.create(server)
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateServerCommand(base.UpdateCommand):
|
|
||||||
"""Update Server"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(UpdateServerCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Server ID.")
|
|
||||||
parser.add_argument('--name', help="Server name.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
# TODO(kiall): API needs updating.. this get is silly
|
|
||||||
server = self.client.servers.get(parsed_args.id)
|
|
||||||
|
|
||||||
if parsed_args.name:
|
|
||||||
server.name = parsed_args.name
|
|
||||||
|
|
||||||
return self.client.servers.update(server)
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteServerCommand(base.DeleteCommand):
|
|
||||||
"""Delete Server"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteServerCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Server ID.")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
return self.client.servers.delete(parsed_args.id)
|
|
@ -1,63 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class SyncAllCommand(base.DeleteCommand):
|
|
||||||
"""Sync Everything"""
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
self.client.sync.sync_all()
|
|
||||||
|
|
||||||
LOG.info('Synchronization of all domains scheduled')
|
|
||||||
|
|
||||||
|
|
||||||
class SyncDomainCommand(base.DeleteCommand):
|
|
||||||
"""Sync a single Domain"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SyncDomainCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
self.client.sync.sync_domain(parsed_args.domain_id)
|
|
||||||
|
|
||||||
LOG.info('Synchronization of domain scheduled')
|
|
||||||
|
|
||||||
|
|
||||||
class SyncRecordCommand(base.DeleteCommand):
|
|
||||||
"""Sync a single Record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SyncRecordCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID")
|
|
||||||
parser.add_argument('record_id', help="Record ID")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
self.client.sync.sync_record(parsed_args.domain_id,
|
|
||||||
parsed_args.record_id)
|
|
||||||
|
|
||||||
LOG.info('Synchronization of record scheduled')
|
|
@ -1,37 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from designateclient.cli import base
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class TouchDomainCommand(base.DeleteCommand):
|
|
||||||
"""Touch a single Domain"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(TouchDomainCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('domain_id', help="Domain ID")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def execute(self, parsed_args):
|
|
||||||
self.client.touch.domain(parsed_args.domain_id)
|
|
||||||
|
|
||||||
LOG.info('Domain touched successfully')
|
|
@ -1,76 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "domain",
|
|
||||||
|
|
||||||
"$schema": "http://json-schema.org/draft-03/hyper-schema",
|
|
||||||
|
|
||||||
"title": "domain",
|
|
||||||
"description": "Domain",
|
|
||||||
"additionalProperties": false,
|
|
||||||
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Domain Identifier",
|
|
||||||
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Domain name",
|
|
||||||
"format": "domain-name",
|
|
||||||
"maxLength": 255,
|
|
||||||
"required": true,
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Hostmaster email address",
|
|
||||||
"format": "email",
|
|
||||||
"maxLength": 255,
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"ttl": {
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Time to live",
|
|
||||||
"minimum": 1,
|
|
||||||
"maximum": 2147483647
|
|
||||||
},
|
|
||||||
"serial": {
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Serial Number",
|
|
||||||
"minimum": 1,
|
|
||||||
"maximum": 4294967295,
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"type": ["string", "null"],
|
|
||||||
"description": "Description for the Domain",
|
|
||||||
"maxLength": 160
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Date and time of domain creation",
|
|
||||||
"format": "date-time",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"updated_at": {
|
|
||||||
"type": ["string", "null"],
|
|
||||||
"description": "Date and time of last domain update",
|
|
||||||
"format": "date-time",
|
|
||||||
"readonly": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"links": [{
|
|
||||||
"rel": "self",
|
|
||||||
"href": "/domains/{id}"
|
|
||||||
}, {
|
|
||||||
"rel": "records",
|
|
||||||
"href": "/domains/{id}/records"
|
|
||||||
}, {
|
|
||||||
"rel": "servers",
|
|
||||||
"href": "/domains/{id}/servers"
|
|
||||||
}, {
|
|
||||||
"rel": "collection",
|
|
||||||
"href": "/domains"
|
|
||||||
}]
|
|
||||||
}
|
|
@ -1,246 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "record",
|
|
||||||
|
|
||||||
"$schema": "http://json-schema.org/draft-03/hyper-schema",
|
|
||||||
|
|
||||||
"title": "record",
|
|
||||||
"description": "Record",
|
|
||||||
"additionalProperties": false,
|
|
||||||
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Record Identifier",
|
|
||||||
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"domain_id": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Domain Identifier",
|
|
||||||
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "DNS Record Name",
|
|
||||||
"format": "host-name",
|
|
||||||
"maxLength": 255,
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "DNS Record Type",
|
|
||||||
"enum": ["A", "AAAA", "CNAME", "MX", "SRV", "TXT", "SPF", "NS", "PTR", "SSHFP", "SOA"],
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "DNS Record Value",
|
|
||||||
"maxLength": 255,
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": ["integer", "null"],
|
|
||||||
"description": "DNS Record Priority",
|
|
||||||
"minimum": 0,
|
|
||||||
"maximum": 65535
|
|
||||||
},
|
|
||||||
"ttl": {
|
|
||||||
"type": ["integer", "null"],
|
|
||||||
"description": "Time to live",
|
|
||||||
"minimum": 1,
|
|
||||||
"maximum": 2147483647
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"type": ["string", "null"],
|
|
||||||
"description": "Description for the record",
|
|
||||||
"maxLength": 160
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Date and time of record creation",
|
|
||||||
"format": "date-time",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"updated_at": {
|
|
||||||
"type": ["string", "null"],
|
|
||||||
"description": "Date and time of last record update",
|
|
||||||
"format": "date-time",
|
|
||||||
"readonly": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oneOf": [{
|
|
||||||
"description": "An A Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["A"]
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"format": "ip-address",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "An AAAA Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["AAAA"]
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"format": "ipv6",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A CNAME Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["CNAME"]
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"format": "host-name",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A MX Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["MX"]
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"format": "host-name",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "integer",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A SRV Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["SRV"]
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^(?:_[A-Za-z0-9_\\-]{1,62}\\.){2}"
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^(?:(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])\\s){2}(?!.{255,})((?!\\-)[A-Za-z0-9_\\-]{1,63}(?<!\\-)\\.)+$"
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "integer",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A TXT Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["TXT"]
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A SPF Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["SPF"]
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A NS Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["NS"]
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"format": "host-name",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A PTR Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["PTR"]
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^(?:(?:\\d{1,3}\\.){4}in-addr\\.arpa\\.|(?:[a-f|\\d]\\.){32}ip6\\.arpa\\.)$"
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"format": "host-name",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A SSHFP Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["SSHFP"]
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"pattern": "^[1-2] 1 [0-9A-Fa-f]{40}$",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"description": "A SOA Record",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["SOA"]
|
|
||||||
},
|
|
||||||
"priority": {
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
"links": [{
|
|
||||||
"rel": "self",
|
|
||||||
"href": "/domains/{domain_id}/records/{id}"
|
|
||||||
}, {
|
|
||||||
"rel": "domain",
|
|
||||||
"href": "/domains/{domain_id}"
|
|
||||||
}, {
|
|
||||||
"rel": "collection",
|
|
||||||
"href": "/domains/{domain_id}/records"
|
|
||||||
}]
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "server",
|
|
||||||
|
|
||||||
"$schema": "http://json-schema.org/draft-03/hyper-schema",
|
|
||||||
|
|
||||||
"title": "server",
|
|
||||||
"description": "Server",
|
|
||||||
"additionalProperties": false,
|
|
||||||
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Server Identifier",
|
|
||||||
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Server DNS name",
|
|
||||||
"format": "host-name",
|
|
||||||
"maxLength": 255,
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Date and time of server creation",
|
|
||||||
"format": "date-time",
|
|
||||||
"readonly": true
|
|
||||||
},
|
|
||||||
"updated_at": {
|
|
||||||
"type": ["string", "null"],
|
|
||||||
"description": "Date and time of last server update",
|
|
||||||
"format": "date-time",
|
|
||||||
"readonly": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"links": [{
|
|
||||||
"rel": "self",
|
|
||||||
"href": "/servers/{id}"
|
|
||||||
}, {
|
|
||||||
"rel": "collection",
|
|
||||||
"href": "/servers"
|
|
||||||
}]
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from designateclient.tests import base
|
|
||||||
|
|
||||||
|
|
||||||
class CrudMixin(object):
|
|
||||||
path_prefix = None
|
|
||||||
|
|
||||||
def new_ref(self, **kwargs):
|
|
||||||
kwargs.setdefault('id', uuid.uuid4().hex)
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
def stub_entity(self, method, parts=None, entity=None, id=None, **kwargs):
|
|
||||||
if entity:
|
|
||||||
kwargs['json'] = entity
|
|
||||||
|
|
||||||
if not parts:
|
|
||||||
parts = [self.RESOURCE]
|
|
||||||
|
|
||||||
if self.path_prefix:
|
|
||||||
parts.insert(0, self.path_prefix)
|
|
||||||
|
|
||||||
if id:
|
|
||||||
if not parts:
|
|
||||||
parts = []
|
|
||||||
|
|
||||||
parts.append(id)
|
|
||||||
|
|
||||||
self.stub_url(method, parts=parts, **kwargs)
|
|
||||||
|
|
||||||
def assertList(self, expected, actual):
|
|
||||||
self.assertEqual(len(expected), len(actual))
|
|
||||||
for i in expected:
|
|
||||||
self.assertIn(i, actual)
|
|
||||||
|
|
||||||
|
|
||||||
class APIV1TestCase(base.APITestCase):
|
|
||||||
VERSION = "1"
|
|
@ -1,124 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient import v1
|
|
||||||
|
|
||||||
from keystoneauth1 import session as keystone_session
|
|
||||||
|
|
||||||
|
|
||||||
class TestClient(test_v1.APIV1TestCase):
|
|
||||||
def test_all_tenants(self):
|
|
||||||
# Create a client with the all_tenants flag set to True
|
|
||||||
client = v1.Client(all_tenants=True)
|
|
||||||
|
|
||||||
# Verify this has been picked up
|
|
||||||
self.assertTrue(client.all_tenants)
|
|
||||||
|
|
||||||
def test_all_tenants_not_supplied(self):
|
|
||||||
# Create a client without supplying any all_tenants flag
|
|
||||||
client = v1.Client()
|
|
||||||
|
|
||||||
# Verify all_tenants is False
|
|
||||||
self.assertFalse(client.all_tenants)
|
|
||||||
self.assertIsNotNone(client.all_tenants)
|
|
||||||
|
|
||||||
def test_all_tenants_through_session(self):
|
|
||||||
# Create a session with the all_tenants flag set to True
|
|
||||||
session = utils.get_session(
|
|
||||||
auth_url='Anything',
|
|
||||||
endpoint='Anything',
|
|
||||||
domain_id='Anything',
|
|
||||||
domain_name='Anything',
|
|
||||||
project_id='Anything',
|
|
||||||
project_name='Anything',
|
|
||||||
project_domain_name='Anything',
|
|
||||||
project_domain_id='Anything',
|
|
||||||
username='Anything',
|
|
||||||
user_id='Anything',
|
|
||||||
password='Anything',
|
|
||||||
user_domain_id='Anything',
|
|
||||||
user_domain_name='Anything',
|
|
||||||
token=None,
|
|
||||||
insecure=False,
|
|
||||||
cacert=None,
|
|
||||||
all_tenants=True)
|
|
||||||
|
|
||||||
# Create a client using the pre-created session
|
|
||||||
client = v1.Client(session=session)
|
|
||||||
|
|
||||||
# Verify the all_tenants flag has been picked up
|
|
||||||
self.assertTrue(client.all_tenants)
|
|
||||||
|
|
||||||
def test_edit_managed(self):
|
|
||||||
# Create a client with the edit_managed flag set to True
|
|
||||||
client = v1.Client(edit_managed=True)
|
|
||||||
|
|
||||||
# Verify this has been picked up
|
|
||||||
self.assertTrue(client.edit_managed)
|
|
||||||
|
|
||||||
def test_edit_managed_not_supplied(self):
|
|
||||||
# Create a client without supplying any edit_managed flag
|
|
||||||
client = v1.Client()
|
|
||||||
|
|
||||||
# Verify edit_managed is False
|
|
||||||
self.assertFalse(client.edit_managed)
|
|
||||||
self.assertIsNotNone(client.edit_managed)
|
|
||||||
|
|
||||||
def test_edit_managed_through_session(self):
|
|
||||||
# Create a session with the edit_managed flag set to True
|
|
||||||
session = utils.get_session(
|
|
||||||
auth_url='Anything',
|
|
||||||
endpoint='Anything',
|
|
||||||
domain_id='Anything',
|
|
||||||
domain_name='Anything',
|
|
||||||
project_id='Anything',
|
|
||||||
project_name='Anything',
|
|
||||||
project_domain_name='Anything',
|
|
||||||
project_domain_id='Anything',
|
|
||||||
username='Anything',
|
|
||||||
user_id='Anything',
|
|
||||||
password='Anything',
|
|
||||||
user_domain_id='Anything',
|
|
||||||
user_domain_name='Anything',
|
|
||||||
token=None,
|
|
||||||
insecure=False,
|
|
||||||
cacert=None,
|
|
||||||
edit_managed=True)
|
|
||||||
|
|
||||||
# Create a client using the pre-created session
|
|
||||||
client = v1.Client(session=session)
|
|
||||||
|
|
||||||
# Verify the edit_managed flag has been picked up
|
|
||||||
self.assertTrue(client.edit_managed)
|
|
||||||
|
|
||||||
def test_timeout_new_session(self):
|
|
||||||
client = v1.Client(
|
|
||||||
auth_url="http://127.0.0.1:22/",
|
|
||||||
timeout=1,
|
|
||||||
)
|
|
||||||
assert client.session.timeout == 1
|
|
||||||
|
|
||||||
def test_timeout_override_session_timeout(self):
|
|
||||||
# The adapter timeout should override the session timeout
|
|
||||||
session = keystone_session.Session(timeout=10)
|
|
||||||
client = v1.Client(
|
|
||||||
auth_url="http://127.0.0.1:22/",
|
|
||||||
session=session,
|
|
||||||
timeout=2,
|
|
||||||
)
|
|
||||||
self.assertEqual(2, client.session.timeout)
|
|
@ -1,30 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient.v1 import diagnostics
|
|
||||||
|
|
||||||
|
|
||||||
class TestDiagnostics(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
|
|
||||||
@patch.object(diagnostics.DiagnosticsController, "ping")
|
|
||||||
def test_ping(self, ping):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.service = "foo"
|
|
||||||
args.host = "host1"
|
|
||||||
self.client.diagnostics.ping(args.host, args.service)
|
|
||||||
self.client.diagnostics.ping.assert_called_with("host1", "foo")
|
|
@ -1,184 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v1 import domains
|
|
||||||
from designateclient import warlock
|
|
||||||
|
|
||||||
Domain = warlock.model_factory(utils.load_schema('v1', 'domain'))
|
|
||||||
|
|
||||||
|
|
||||||
class TestDomain(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
RESOURCE = 'domains'
|
|
||||||
|
|
||||||
def new_ref(self, **kwargs):
|
|
||||||
ref = super(TestDomain, self).new_ref(**kwargs)
|
|
||||||
ref.setdefault("name", uuid.uuid4().hex)
|
|
||||||
ref.setdefault("email", "abc@example.com.")
|
|
||||||
ref.setdefault("ttl", 3600)
|
|
||||||
return ref
|
|
||||||
|
|
||||||
def test_create(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain1.com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": 60}
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
response = self.client.domains.create(values["name"])
|
|
||||||
self.assertEqual(ref['id'], response['id'])
|
|
||||||
|
|
||||||
def test_create_with_description(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain1.com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": 60,
|
|
||||||
"description": "fully qualified domain"}
|
|
||||||
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
response = self.client.domains.create(values["name"])
|
|
||||||
self.assertEqual(ref['id'], response['id'])
|
|
||||||
|
|
||||||
def test_create_with_description_too_long(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain1.com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": 60,
|
|
||||||
"description": "d" * 161}
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.assertRaises(ValueError, self.client.domains.create,
|
|
||||||
values["name"])
|
|
||||||
|
|
||||||
def test_create_with_zero_ttl(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain1.com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": 0}
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.assertRaises(ValueError, self.client.domains.create,
|
|
||||||
values["name"])
|
|
||||||
|
|
||||||
def test_create_with_negative_ttl(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain1.com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": -1}
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.assertRaises(ValueError, self.client.domains.create,
|
|
||||||
values["name"])
|
|
||||||
|
|
||||||
def test_create_with_no_ttl(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain1.com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": ""}
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.assertRaises(ValueError, self.client.domains.create,
|
|
||||||
values["name"])
|
|
||||||
|
|
||||||
def test_create_with_name_too_long(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "domain" + "a" * 255 + ".com.",
|
|
||||||
"email": "nsadmin@example.org",
|
|
||||||
"ttl": 60}
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.assertRaises(ValueError, self.client.domains.create,
|
|
||||||
values["name"])
|
|
||||||
|
|
||||||
def test_list(self):
|
|
||||||
items = [
|
|
||||||
self.new_ref(email="abc@example.org",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310438"),
|
|
||||||
self.new_ref(email="root@example.org",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310435")
|
|
||||||
]
|
|
||||||
|
|
||||||
self.stub_url("GET", parts=[self.RESOURCE], json={"domains": items})
|
|
||||||
|
|
||||||
listed = self.client.domains.list()
|
|
||||||
self.assertList(items, listed)
|
|
||||||
self.assertQueryStringIs("")
|
|
||||||
|
|
||||||
def test_get(self):
|
|
||||||
ref = self.new_ref(email="abc@example.org",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310438")
|
|
||||||
|
|
||||||
self.stub_entity("GET", entity=ref, id=ref["id"])
|
|
||||||
|
|
||||||
response = self.client.domains.get(ref["id"])
|
|
||||||
self.assertEqual(ref, response)
|
|
||||||
|
|
||||||
def test_delete(self):
|
|
||||||
ref = self.new_ref(email="abc@example.org",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310438")
|
|
||||||
|
|
||||||
self.stub_entity("DELETE", entity=ref, id=ref["id"])
|
|
||||||
|
|
||||||
self.client.domains.delete(ref["id"])
|
|
||||||
self.assertRequestBodyIs(None)
|
|
||||||
|
|
||||||
def test_update(self):
|
|
||||||
ref = self.new_ref(id="89acac79-38e7-497d-807c-a011e1310438")
|
|
||||||
|
|
||||||
self.stub_entity("PUT", entity=ref, id=ref["id"])
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
|
|
||||||
self.client.domains.update(Domain(values))
|
|
||||||
|
|
||||||
@patch.object(domains.DomainsController, "list_domain_servers")
|
|
||||||
def test_list_domain_servers(self, domains_get):
|
|
||||||
domains_get.return_value = [{"id": "foo", "name": "ns1.example.com."}]
|
|
||||||
|
|
||||||
ref = [{
|
|
||||||
"id": "foo",
|
|
||||||
"name": "ns1.example.com.",
|
|
||||||
}]
|
|
||||||
parts = ["domains", "foo", "servers"]
|
|
||||||
self.stub_url("GET", parts=parts, json={"servers": ref})
|
|
||||||
|
|
||||||
response = self.client.domains.list_domain_servers("foo")
|
|
||||||
self.assertEqual(ref, response)
|
|
@ -1,48 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient.v1 import quotas
|
|
||||||
|
|
||||||
|
|
||||||
class TestQuota(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
|
|
||||||
@patch.object(quotas.QuotasController, "get")
|
|
||||||
def test_get(self, quota_get):
|
|
||||||
QUOTA = {"domains": 10,
|
|
||||||
"recordset_records": 20,
|
|
||||||
"domain_records": 500,
|
|
||||||
"domain_recordsets": 500}
|
|
||||||
quota_get.return_value = QUOTA
|
|
||||||
response = self.client.quotas.get("foo")
|
|
||||||
self.assertEqual(QUOTA, response)
|
|
||||||
|
|
||||||
@patch.object(quotas.QuotasController, "update")
|
|
||||||
def test_update(self, quota_update):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.tenant_id = "1234"
|
|
||||||
args.value = {"domains": 1000}
|
|
||||||
self.client.quotas.update(args.tenant_id, args.value)
|
|
||||||
self.client.quotas.update.assert_called_with(args.tenant_id,
|
|
||||||
args.value)
|
|
||||||
|
|
||||||
@patch.object(quotas.QuotasController, "reset")
|
|
||||||
def test_reset(self, quota_reset):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.tenant_id = "1234"
|
|
||||||
self.client.quotas.reset(args.tenant_id)
|
|
||||||
self.client.quotas.reset.assert_called_with("1234")
|
|
@ -1,222 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient import warlock
|
|
||||||
|
|
||||||
|
|
||||||
Record = warlock.model_factory(utils.load_schema('v1', 'record'))
|
|
||||||
|
|
||||||
DOMAIN = {
|
|
||||||
"id": str(uuid.uuid4()),
|
|
||||||
"name": "example.com."
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TestRecords(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
RESOURCE = 'records'
|
|
||||||
|
|
||||||
def new_ref(self, **kwargs):
|
|
||||||
ref = super(TestRecords, self).new_ref(**kwargs)
|
|
||||||
ref.setdefault("name", uuid.uuid4().hex)
|
|
||||||
ref.setdefault("type", "A")
|
|
||||||
ref.setdefault("data", "10.0.0.1")
|
|
||||||
return ref
|
|
||||||
|
|
||||||
def test_create_record(self):
|
|
||||||
ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_AAAA_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778888",
|
|
||||||
type="AAAA",
|
|
||||||
data="2001:db8:0:1234:0:5678:9:12")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_MX_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778989",
|
|
||||||
type="MX",
|
|
||||||
data="mail.example.com.",
|
|
||||||
priority=10)
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_CNAME_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778890",
|
|
||||||
type="CNAME",
|
|
||||||
data="example.com.")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_TXT_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778889",
|
|
||||||
type="TXT",
|
|
||||||
data="This is a TXT record")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_SRV_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778888",
|
|
||||||
type="SRV",
|
|
||||||
data="0 5060 sip.example.com.",
|
|
||||||
priority=30)
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_NS_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677779999",
|
|
||||||
type="NS",
|
|
||||||
data="ns1.example.com.")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_PTR_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778891",
|
|
||||||
type="PTR",
|
|
||||||
data="www.example.com.")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_SPF_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778899",
|
|
||||||
type="SPF",
|
|
||||||
data="v=spf1 +mx a:colo.example.com/28 -all")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_SSHFP_record(self):
|
|
||||||
ref = self.new_ref(id="11112222-3333-4444-5555-666677778888",
|
|
||||||
type="SSHFP",
|
|
||||||
data="2 1 6c3c958af43d953f91f40e0d84157f4fe7b4a898")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("POST", parts=parts, json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.create(DOMAIN['id'], Record(values))
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_get(self):
|
|
||||||
ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_entity("GET", entity=ref, id=ref["id"], parts=parts)
|
|
||||||
|
|
||||||
response = self.client.records.get(DOMAIN["id"], ref["id"])
|
|
||||||
self.assertEqual(ref, response)
|
|
||||||
|
|
||||||
def test_list(self):
|
|
||||||
items = [
|
|
||||||
self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad"),
|
|
||||||
self.new_ref(id="11112222-3333-4444-5555-666677778888")
|
|
||||||
]
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_url("GET", parts=parts, json={"records": items})
|
|
||||||
|
|
||||||
listed = self.client.records.list(DOMAIN["id"])
|
|
||||||
self.assertList(items, listed)
|
|
||||||
self.assertQueryStringIs("")
|
|
||||||
|
|
||||||
def test_update(self):
|
|
||||||
ref = self.new_ref(id="2e32e609-3a4f-45ba-bdef-e50eacd345ad",
|
|
||||||
type="A",
|
|
||||||
data="192.0.2.5")
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_entity("PUT", entity=ref, id=ref["id"], parts=parts)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.records.update(DOMAIN["id"], Record(ref))
|
|
||||||
|
|
||||||
def test_delete(self):
|
|
||||||
ref = self.new_ref()
|
|
||||||
|
|
||||||
parts = ["domains", DOMAIN["id"], self.RESOURCE]
|
|
||||||
self.stub_entity("DELETE", id=ref["id"], parts=parts)
|
|
||||||
|
|
||||||
self.client.records.delete(DOMAIN["id"], ref["id"])
|
|
||||||
self.assertRequestBodyIs(None)
|
|
@ -1,54 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient.v1 import reports
|
|
||||||
|
|
||||||
|
|
||||||
class TestReports(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
|
|
||||||
@patch.object(reports.ReportsController, "count_all")
|
|
||||||
def test_count_all(self, count_all):
|
|
||||||
self.client.reports.count_all()
|
|
||||||
self.client.reports.count_all.assert_called_with()
|
|
||||||
|
|
||||||
@patch.object(reports.ReportsController, "count_domains")
|
|
||||||
def test_count_domain(self, count_domains):
|
|
||||||
self.client.reports.count_domains()
|
|
||||||
self.client.reports.count_domains.assert_called_once_with()
|
|
||||||
|
|
||||||
@patch.object(reports.ReportsController, "count_tenants")
|
|
||||||
def test_count_tenants(self, count_tenants):
|
|
||||||
self.client.reports.count_tenants()
|
|
||||||
self.client.reports.count_tenants.assert_called_once_with()
|
|
||||||
|
|
||||||
@patch.object(reports.ReportsController, "count_records")
|
|
||||||
def test_count_records(self, count_records):
|
|
||||||
self.client.reports.count_records()
|
|
||||||
self.client.reports.count_records.assert_called_once_with()
|
|
||||||
|
|
||||||
@patch.object(reports.ReportsController, "tenants_all")
|
|
||||||
def test_tenants_all(self, tenants_all):
|
|
||||||
self.client.reports.tenants_all()
|
|
||||||
self.client.reports.tenants_all.assert_called_once_with()
|
|
||||||
|
|
||||||
@patch.object(reports.ReportsController, "tenant_domains")
|
|
||||||
def test_tenant_domains(self, tenant_domains):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.other_tenant_id = "uuid"
|
|
||||||
self.client.reports.tenant_domains(args.other_tenant_id)
|
|
||||||
self.client.reports.tenant_domains.assert_called_once_with("uuid")
|
|
@ -1,95 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient.v1 import servers
|
|
||||||
|
|
||||||
|
|
||||||
class TestServers(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
RESOURCE = 'servers'
|
|
||||||
|
|
||||||
def new_ref(self, **kwargs):
|
|
||||||
ref = super(TestServers, self).new_ref(**kwargs)
|
|
||||||
ref.setdefault("name", uuid.uuid4().hex)
|
|
||||||
return ref
|
|
||||||
|
|
||||||
def test_list(self):
|
|
||||||
items = [
|
|
||||||
self.new_ref(name="ns1.example.org.",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310438"),
|
|
||||||
self.new_ref(name="ns2.example.org.",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310435")
|
|
||||||
]
|
|
||||||
|
|
||||||
self.stub_url("GET", parts=[self.RESOURCE], json={"servers": items})
|
|
||||||
|
|
||||||
listed = self.client.servers.list()
|
|
||||||
self.assertList(items, listed)
|
|
||||||
self.assertQueryStringIs("")
|
|
||||||
|
|
||||||
def test_get(self):
|
|
||||||
ref = self.new_ref(name="ns1.example.org.",
|
|
||||||
id="89acac79-38e7-497d-807c-a011e1310438")
|
|
||||||
|
|
||||||
self.stub_entity("GET", entity=ref, id=ref["id"])
|
|
||||||
|
|
||||||
response = self.client.servers.get(ref["id"])
|
|
||||||
self.assertEqual(ref, response)
|
|
||||||
|
|
||||||
def test_create(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "ns1.example.org."}
|
|
||||||
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.client.servers.create({"name": "ns1.example.org."})
|
|
||||||
self.assertRequestBodyIs(json=values)
|
|
||||||
|
|
||||||
def test_create_with_name_too_long(self):
|
|
||||||
ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
|
|
||||||
"name": "ns1." + "foo" * 85 + ".org."}
|
|
||||||
|
|
||||||
self.stub_url("POST", parts=[self.RESOURCE], json=ref)
|
|
||||||
|
|
||||||
values = ref.copy()
|
|
||||||
del values["id"]
|
|
||||||
|
|
||||||
self.assertRaises(ValueError, self.client.servers.create,
|
|
||||||
{"name": "ns1.example.org."})
|
|
||||||
|
|
||||||
@patch.object(servers.ServersController, "update")
|
|
||||||
def test_update(self, server_update):
|
|
||||||
ref = self.new_ref()
|
|
||||||
|
|
||||||
self.stub_entity("PUT", entity=ref, id=ref["id"])
|
|
||||||
|
|
||||||
mock_server = mock.MagicMock()
|
|
||||||
self.client.servers.update(mock_server)
|
|
||||||
self.client.servers.update.assert_called_with(mock_server)
|
|
||||||
|
|
||||||
def test_delete(self):
|
|
||||||
ref = self.new_ref()
|
|
||||||
|
|
||||||
self.stub_entity("DELETE", id=ref["id"])
|
|
||||||
|
|
||||||
self.client.servers.delete(ref["id"])
|
|
||||||
self.assertRequestBodyIs(None)
|
|
@ -1,42 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient.v1 import sync
|
|
||||||
|
|
||||||
|
|
||||||
class TestSync(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
|
|
||||||
@patch.object(sync.SyncController, "sync_all")
|
|
||||||
def test_sync_all(self, sync_all):
|
|
||||||
self.client.sync.sync_all()
|
|
||||||
self.client.sync.sync_all.assert_called_with()
|
|
||||||
|
|
||||||
@patch.object(sync.SyncController, "sync_domain")
|
|
||||||
def test_sync_domain(self, sync_domain):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.tenant_id = "1234"
|
|
||||||
self.client.sync.sync_domain(args.tenant_id)
|
|
||||||
self.client.sync.sync_domain.assert_called_with("1234")
|
|
||||||
|
|
||||||
@patch.object(sync.SyncController, "sync_record")
|
|
||||||
def test_sync_record(self, sync_record):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.tenant_id = "1234"
|
|
||||||
args.record_id = "uuid"
|
|
||||||
self.client.sync.sync_record(args.tenant_id, args.record_id)
|
|
||||||
self.client.sync.sync_record.assert_called_with("1234", "uuid")
|
|
@ -1,29 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from designateclient.tests import test_v1
|
|
||||||
from designateclient.v1 import touch
|
|
||||||
|
|
||||||
|
|
||||||
class TestTouch(test_v1.APIV1TestCase, test_v1.CrudMixin):
|
|
||||||
|
|
||||||
@patch.object(touch.TouchController, "domain")
|
|
||||||
def test_domain(self, domain):
|
|
||||||
args = mock.MagicMock()
|
|
||||||
args.domain_id = "1234"
|
|
||||||
self.client.touch.domain(args.domain_id)
|
|
||||||
self.client.touch.domain.assert_called_with("1234")
|
|
@ -1,161 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from debtcollector import removals
|
|
||||||
from stevedore import extension
|
|
||||||
|
|
||||||
from designateclient import exceptions
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient import version
|
|
||||||
|
|
||||||
|
|
||||||
@removals.removed_class(
|
|
||||||
'designateclient.v1.Client',
|
|
||||||
replacement='designateclient.v2.client.Client',
|
|
||||||
message='Designate v1 API is being retired, and the v1 Client class will '
|
|
||||||
'stop functioning. Please update code to the '
|
|
||||||
'designateclient.v2.client.Client class. The API is deprecated',
|
|
||||||
version='2.2.0',
|
|
||||||
removal_version='?',
|
|
||||||
stacklevel=3)
|
|
||||||
class Client(object):
|
|
||||||
"""Client for the Designate v1 API"""
|
|
||||||
|
|
||||||
def __init__(self, endpoint=None, username=None, user_id=None,
|
|
||||||
user_domain_id=None, user_domain_name=None, password=None,
|
|
||||||
tenant_name=None, tenant_id=None, domain_name=None,
|
|
||||||
domain_id=None, project_name=None,
|
|
||||||
project_id=None, project_domain_name=None,
|
|
||||||
project_domain_id=None, auth_url=None, token=None,
|
|
||||||
endpoint_type='publicURL', region_name=None,
|
|
||||||
service_type='dns', insecure=False, session=None,
|
|
||||||
cacert=None, all_tenants=None, edit_managed=None,
|
|
||||||
timeout=None):
|
|
||||||
"""
|
|
||||||
:param endpoint: Endpoint URL
|
|
||||||
:param token: A token instead of username / password
|
|
||||||
:param insecure: Allow "insecure" HTTPS requests
|
|
||||||
"""
|
|
||||||
|
|
||||||
if endpoint:
|
|
||||||
endpoint = endpoint.rstrip('/')
|
|
||||||
if not endpoint.endswith('v1'):
|
|
||||||
endpoint = "%s/v1" % endpoint
|
|
||||||
|
|
||||||
# Compatibility code to mimic the old behaviour of the client
|
|
||||||
if session is None:
|
|
||||||
session = utils.get_session(
|
|
||||||
auth_url=auth_url,
|
|
||||||
endpoint=endpoint,
|
|
||||||
domain_id=domain_id,
|
|
||||||
domain_name=domain_name,
|
|
||||||
project_id=project_id or tenant_id,
|
|
||||||
project_name=project_name or tenant_name,
|
|
||||||
project_domain_name=project_domain_name,
|
|
||||||
project_domain_id=project_domain_id,
|
|
||||||
username=username,
|
|
||||||
user_id=user_id,
|
|
||||||
password=password,
|
|
||||||
user_domain_id=user_domain_id,
|
|
||||||
user_domain_name=user_domain_name,
|
|
||||||
token=token,
|
|
||||||
insecure=insecure,
|
|
||||||
cacert=cacert,
|
|
||||||
)
|
|
||||||
|
|
||||||
# NOTE: all_tenants and edit_managed are pulled from the session for
|
|
||||||
# backwards compat reasons, do not pull additional modifiers from
|
|
||||||
# here. Once removed, the kwargs above should default to False.
|
|
||||||
if all_tenants is None:
|
|
||||||
self.all_tenants = getattr(session, 'all_tenants', False)
|
|
||||||
else:
|
|
||||||
self.all_tenants = all_tenants
|
|
||||||
|
|
||||||
if edit_managed is None:
|
|
||||||
self.edit_managed = getattr(session, 'edit_managed', False)
|
|
||||||
else:
|
|
||||||
self.edit_managed = edit_managed
|
|
||||||
|
|
||||||
# Since we have to behave nicely like a legacy client/bindings we use
|
|
||||||
# an adapter around the session to not modify it's state.
|
|
||||||
interface = endpoint_type.rstrip('URL')
|
|
||||||
|
|
||||||
self.session = utils.AdapterWithTimeout(
|
|
||||||
session,
|
|
||||||
auth=session.auth,
|
|
||||||
endpoint_override=endpoint,
|
|
||||||
region_name=region_name,
|
|
||||||
service_type=service_type,
|
|
||||||
interface=interface,
|
|
||||||
user_agent='python-designateclient-%s' % version.version_info,
|
|
||||||
version='1',
|
|
||||||
timeout=timeout,
|
|
||||||
)
|
|
||||||
|
|
||||||
def _load_controller(ext):
|
|
||||||
controller = ext.plugin(client=self)
|
|
||||||
setattr(self, ext.name, controller)
|
|
||||||
|
|
||||||
# Load all controllers
|
|
||||||
mgr = extension.ExtensionManager('designateclient.v1.controllers')
|
|
||||||
mgr.map(_load_controller)
|
|
||||||
|
|
||||||
def wrap_api_call(self, func, *args, **kw):
|
|
||||||
"""
|
|
||||||
Wrap a self.<rest function> with exception handling
|
|
||||||
|
|
||||||
:param func: The function to wrap
|
|
||||||
"""
|
|
||||||
kw['raise_exc'] = False
|
|
||||||
kw.setdefault('headers', {})
|
|
||||||
kw['headers'].setdefault('Content-Type', 'application/json')
|
|
||||||
if self.all_tenants:
|
|
||||||
kw['headers'].update({'X-Auth-All-Projects': 'true'})
|
|
||||||
if self.edit_managed:
|
|
||||||
kw['headers'].update({'X-Designate-Edit-Managed-Records': 'true'})
|
|
||||||
|
|
||||||
# Trigger the request
|
|
||||||
response = func(*args, **kw)
|
|
||||||
|
|
||||||
# Decode is response, if possible
|
|
||||||
try:
|
|
||||||
response_payload = response.json()
|
|
||||||
except ValueError:
|
|
||||||
response_payload = {}
|
|
||||||
|
|
||||||
if response.status_code == 400:
|
|
||||||
raise exceptions.BadRequest(**response_payload)
|
|
||||||
elif response.status_code in (401, 403, 413):
|
|
||||||
raise exceptions.Forbidden(**response_payload)
|
|
||||||
elif response.status_code == 404:
|
|
||||||
raise exceptions.NotFound(**response_payload)
|
|
||||||
elif response.status_code == 409:
|
|
||||||
raise exceptions.Conflict(**response_payload)
|
|
||||||
elif response.status_code >= 500:
|
|
||||||
raise exceptions.Unknown(**response_payload)
|
|
||||||
else:
|
|
||||||
return response
|
|
||||||
|
|
||||||
def get(self, path, **kw):
|
|
||||||
return self.wrap_api_call(self.session.get, path, **kw)
|
|
||||||
|
|
||||||
def post(self, path, **kw):
|
|
||||||
return self.wrap_api_call(self.session.post, path, **kw)
|
|
||||||
|
|
||||||
def put(self, path, **kw):
|
|
||||||
return self.wrap_api_call(self.session.put, path, **kw)
|
|
||||||
|
|
||||||
def delete(self, path, **kw):
|
|
||||||
return self.wrap_api_call(self.session.delete, path, **kw)
|
|
@ -1,27 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient import client
|
|
||||||
|
|
||||||
|
|
||||||
class DiagnosticsController(client.Controller):
|
|
||||||
def ping(self, service, host):
|
|
||||||
"""
|
|
||||||
Ping a service on a given host
|
|
||||||
"""
|
|
||||||
response = self.client.get('/diagnostics/ping/%s/%s' %
|
|
||||||
(service, host))
|
|
||||||
|
|
||||||
return response.json()
|
|
@ -1,92 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import json
|
|
||||||
|
|
||||||
from designateclient import client
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient import warlock
|
|
||||||
|
|
||||||
|
|
||||||
Domain = warlock.model_factory(utils.load_schema('v1', 'domain'))
|
|
||||||
Server = warlock.model_factory(utils.load_schema('v1', 'server'))
|
|
||||||
|
|
||||||
|
|
||||||
class DomainsController(client.CrudController):
|
|
||||||
def list(self):
|
|
||||||
"""
|
|
||||||
Retrieve a list of domains
|
|
||||||
|
|
||||||
:returns: A list of :class:`Domain`
|
|
||||||
"""
|
|
||||||
response = self.client.get('/domains')
|
|
||||||
|
|
||||||
return [Domain(i) for i in response.json()['domains']]
|
|
||||||
|
|
||||||
def get(self, domain_id):
|
|
||||||
"""
|
|
||||||
Retrieve a domain
|
|
||||||
|
|
||||||
:param domain_id: Domain Identifier
|
|
||||||
:returns: :class:`Domain`
|
|
||||||
"""
|
|
||||||
response = self.client.get('/domains/%s' % domain_id)
|
|
||||||
|
|
||||||
return Domain(response.json())
|
|
||||||
|
|
||||||
def create(self, domain):
|
|
||||||
"""
|
|
||||||
Create a domain
|
|
||||||
|
|
||||||
:param domain: A :class:`Domain` to create
|
|
||||||
:returns: :class:`Domain`
|
|
||||||
"""
|
|
||||||
response = self.client.post('/domains', data=json.dumps(domain))
|
|
||||||
|
|
||||||
return Domain(response.json())
|
|
||||||
|
|
||||||
def update(self, domain):
|
|
||||||
"""
|
|
||||||
Update a domain
|
|
||||||
|
|
||||||
:param domain: A :class:`Domain` to update
|
|
||||||
:returns: :class:`Domain`
|
|
||||||
"""
|
|
||||||
response = self.client.put('/domains/%s' % domain.id,
|
|
||||||
data=json.dumps(domain.changes))
|
|
||||||
|
|
||||||
return Domain(response.json())
|
|
||||||
|
|
||||||
def delete(self, domain):
|
|
||||||
"""
|
|
||||||
Delete a domain
|
|
||||||
|
|
||||||
:param domain: A :class:`Domain`, or Domain Identifier to delete
|
|
||||||
"""
|
|
||||||
if isinstance(domain, Domain):
|
|
||||||
self.client.delete('/domains/%s' % domain.id)
|
|
||||||
else:
|
|
||||||
self.client.delete('/domains/%s' % domain)
|
|
||||||
|
|
||||||
def list_domain_servers(self, domain_id):
|
|
||||||
"""
|
|
||||||
Retrieve the list of nameservers for a domain
|
|
||||||
|
|
||||||
:param domain_id: Domain Identifier
|
|
||||||
:returns: A list of :class:`Server`
|
|
||||||
"""
|
|
||||||
response = self.client.get('/domains/%s/servers' % domain_id)
|
|
||||||
|
|
||||||
return [Server(i) for i in response.json()['servers']]
|
|
@ -1,38 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import json
|
|
||||||
|
|
||||||
from designateclient import client
|
|
||||||
|
|
||||||
|
|
||||||
class QuotasController(client.Controller):
|
|
||||||
def get(self, tenant_id):
|
|
||||||
"""
|
|
||||||
Ping a service on a given host
|
|
||||||
"""
|
|
||||||
response = self.client.get('/quotas/%s' % tenant_id)
|
|
||||||
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def update(self, tenant_id, values):
|
|
||||||
response = self.client.put('/quotas/%s' % tenant_id,
|
|
||||||
data=json.dumps(values))
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def reset(self, tenant_id):
|
|
||||||
response = self.client.delete('/quotas/%s' % tenant_id)
|
|
||||||
|
|
||||||
return response
|
|
@ -1,115 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from designateclient import client
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v1.domains import Domain
|
|
||||||
from designateclient import warlock
|
|
||||||
|
|
||||||
|
|
||||||
Record = warlock.model_factory(utils.load_schema('v1', 'record'))
|
|
||||||
|
|
||||||
|
|
||||||
class RecordsController(client.CrudController):
|
|
||||||
def list(self, domain):
|
|
||||||
"""
|
|
||||||
Retrieve a list of records
|
|
||||||
|
|
||||||
:param domain: :class:`Domain` or Domain Identifier
|
|
||||||
:returns: A list of :class:`Record`
|
|
||||||
"""
|
|
||||||
domain_id = domain.id if isinstance(domain, Domain) else domain
|
|
||||||
|
|
||||||
response = self.client.get('/domains/%(domain_id)s/records' % {
|
|
||||||
'domain_id': domain_id
|
|
||||||
})
|
|
||||||
|
|
||||||
return [Record(i) for i in response.json()['records']]
|
|
||||||
|
|
||||||
def get(self, domain, record_id):
|
|
||||||
"""
|
|
||||||
Retrieve a record
|
|
||||||
|
|
||||||
:param domain: :class:`Domain` or Domain Identifier
|
|
||||||
:param record_id: Record Identifier
|
|
||||||
:returns: :class:`Record`
|
|
||||||
"""
|
|
||||||
domain_id = domain.id if isinstance(domain, Domain) else domain
|
|
||||||
|
|
||||||
uri = '/domains/%(domain_id)s/records/%(record_id)s' % {
|
|
||||||
'domain_id': domain_id,
|
|
||||||
'record_id': record_id
|
|
||||||
}
|
|
||||||
|
|
||||||
response = self.client.get(uri)
|
|
||||||
|
|
||||||
return Record(response.json())
|
|
||||||
|
|
||||||
def create(self, domain, record):
|
|
||||||
"""
|
|
||||||
Create a record
|
|
||||||
|
|
||||||
:param domain: :class:`Domain` or Domain Identifier
|
|
||||||
:param record: A :class:`Record` to create
|
|
||||||
:returns: :class:`Record`
|
|
||||||
"""
|
|
||||||
domain_id = domain.id if isinstance(domain, Domain) else domain
|
|
||||||
|
|
||||||
uri = '/domains/%(domain_id)s/records' % {
|
|
||||||
'domain_id': domain_id
|
|
||||||
}
|
|
||||||
|
|
||||||
response = self.client.post(uri, data=json.dumps(record))
|
|
||||||
|
|
||||||
return Record(response.json())
|
|
||||||
|
|
||||||
def update(self, domain, record):
|
|
||||||
"""
|
|
||||||
Update a record
|
|
||||||
|
|
||||||
:param domain: :class:`Domain` or Domain Identifier
|
|
||||||
:param record: A :class:`Record` to update
|
|
||||||
:returns: :class:`Record`
|
|
||||||
"""
|
|
||||||
domain_id = domain.id if isinstance(domain, Domain) else domain
|
|
||||||
|
|
||||||
uri = '/domains/%(domain_id)s/records/%(record_id)s' % {
|
|
||||||
'domain_id': domain_id,
|
|
||||||
'record_id': record.id
|
|
||||||
}
|
|
||||||
|
|
||||||
response = self.client.put(uri, data=json.dumps(record.changes))
|
|
||||||
|
|
||||||
return Record(response.json())
|
|
||||||
|
|
||||||
def delete(self, domain, record):
|
|
||||||
"""
|
|
||||||
Delete a record
|
|
||||||
|
|
||||||
:param domain: :class:`Domain` or Domain Identifier
|
|
||||||
:param record: A :class:`Record`, or Record Identifier to delete
|
|
||||||
"""
|
|
||||||
domain_id = domain.id if isinstance(domain, Domain) else domain
|
|
||||||
record_id = record.id if isinstance(record, Record) else record
|
|
||||||
|
|
||||||
uri = '/domains/%(domain_id)s/records/%(record_id)s' % {
|
|
||||||
'domain_id': domain_id,
|
|
||||||
'record_id': record_id
|
|
||||||
}
|
|
||||||
|
|
||||||
self.client.delete(uri)
|
|
@ -1,67 +0,0 @@
|
|||||||
# Copyright 2013 Hewlett-Packard Development Company, L.P. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Author: Patrick Galbraith <patg@patg.net>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient import client
|
|
||||||
|
|
||||||
|
|
||||||
class ReportsController(client.Controller):
|
|
||||||
def count_all(self):
|
|
||||||
"""
|
|
||||||
Domain, Records and tenant total count
|
|
||||||
"""
|
|
||||||
response = self.client.get('/reports/counts')
|
|
||||||
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def count_domains(self):
|
|
||||||
"""
|
|
||||||
Domain total count
|
|
||||||
"""
|
|
||||||
response = self.client.get('/reports/counts/domains')
|
|
||||||
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def count_tenants(self):
|
|
||||||
"""
|
|
||||||
Tenant total count
|
|
||||||
"""
|
|
||||||
response = self.client.get('/reports/counts/tenants')
|
|
||||||
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def count_records(self):
|
|
||||||
"""
|
|
||||||
Record total count
|
|
||||||
"""
|
|
||||||
response = self.client.get('/reports/counts/records')
|
|
||||||
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def tenants_all(self):
|
|
||||||
"""
|
|
||||||
Per tenant count
|
|
||||||
"""
|
|
||||||
response = self.client.get('/reports/tenants')
|
|
||||||
|
|
||||||
return response.json()['tenants']
|
|
||||||
|
|
||||||
def tenant_domains(self, other_tenant_id):
|
|
||||||
"""
|
|
||||||
Tenant's domain count
|
|
||||||
"""
|
|
||||||
response = self.client.get('/reports/tenants/%s' %
|
|
||||||
other_tenant_id)
|
|
||||||
|
|
||||||
return [{'domain': d} for d in response.json()['domains']]
|
|
@ -1,81 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from designateclient import client
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient import warlock
|
|
||||||
|
|
||||||
|
|
||||||
Server = warlock.model_factory(utils.load_schema('v1', 'server'))
|
|
||||||
|
|
||||||
|
|
||||||
class ServersController(client.CrudController):
|
|
||||||
def list(self):
|
|
||||||
"""
|
|
||||||
Retrieve a list of servers
|
|
||||||
|
|
||||||
:returns: A list of :class:`Server`
|
|
||||||
"""
|
|
||||||
response = self.client.get('/servers')
|
|
||||||
|
|
||||||
return [Server(i) for i in response.json()['servers']]
|
|
||||||
|
|
||||||
def get(self, server_id):
|
|
||||||
"""
|
|
||||||
Retrieve a server
|
|
||||||
|
|
||||||
:param server_id: Server Identifier
|
|
||||||
:returns: :class:`Server`
|
|
||||||
"""
|
|
||||||
response = self.client.get('/servers/%s' % server_id)
|
|
||||||
|
|
||||||
return Server(response.json())
|
|
||||||
|
|
||||||
def create(self, server):
|
|
||||||
"""
|
|
||||||
Create a server
|
|
||||||
|
|
||||||
:param server: A :class:`Server` to create
|
|
||||||
:returns: :class:`Server`
|
|
||||||
"""
|
|
||||||
response = self.client.post('/servers', data=json.dumps(server))
|
|
||||||
|
|
||||||
return Server(response.json())
|
|
||||||
|
|
||||||
def update(self, server):
|
|
||||||
"""
|
|
||||||
Update a server
|
|
||||||
|
|
||||||
:param server: A :class:`Server` to update
|
|
||||||
:returns: :class:`Server`
|
|
||||||
"""
|
|
||||||
response = self.client.put('/servers/%s' % server.id,
|
|
||||||
data=json.dumps(server.changes))
|
|
||||||
|
|
||||||
return Server(response.json())
|
|
||||||
|
|
||||||
def delete(self, server):
|
|
||||||
"""
|
|
||||||
Delete a server
|
|
||||||
|
|
||||||
:param server: A :class:`Server`, or Server Identifier to delete
|
|
||||||
"""
|
|
||||||
if isinstance(server, Server):
|
|
||||||
self.client.delete('/servers/%s' % server.id)
|
|
||||||
else:
|
|
||||||
self.client.delete('/servers/%s' % server)
|
|
@ -1,37 +0,0 @@
|
|||||||
# Copyright 2012 Managed I.T.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient import client
|
|
||||||
|
|
||||||
|
|
||||||
class SyncController(client.Controller):
|
|
||||||
def sync_all(self):
|
|
||||||
"""
|
|
||||||
Sync Everything
|
|
||||||
"""
|
|
||||||
self.client.post('/domains/sync')
|
|
||||||
|
|
||||||
def sync_domain(self, domain_id):
|
|
||||||
"""
|
|
||||||
Sync Single Domain
|
|
||||||
"""
|
|
||||||
self.client.post('/domains/%s/sync' % domain_id)
|
|
||||||
|
|
||||||
def sync_record(self, domain_id, record_id):
|
|
||||||
"""
|
|
||||||
Sync Single Record
|
|
||||||
"""
|
|
||||||
self.client.post('/domains/%s/records/%s/sync' %
|
|
||||||
(domain_id, record_id))
|
|
@ -1,24 +0,0 @@
|
|||||||
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Kiall Mac Innes <kiall@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient import client
|
|
||||||
|
|
||||||
|
|
||||||
class TouchController(client.Controller):
|
|
||||||
def domain(self, domain_id):
|
|
||||||
"""
|
|
||||||
Touch a single Domain
|
|
||||||
"""
|
|
||||||
self.client.post('/domains/%s/touch' % domain_id)
|
|
@ -1,48 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
|
|
||||||
|
|
||||||
class BlacklistController(V2Controller):
|
|
||||||
def create(self, pattern, description=None):
|
|
||||||
data = {
|
|
||||||
'pattern': pattern,
|
|
||||||
}
|
|
||||||
|
|
||||||
if description is not None:
|
|
||||||
data['description'] = description
|
|
||||||
|
|
||||||
return self._post('/blacklists', data=data)
|
|
||||||
|
|
||||||
def list(self, criterion=None, marker=None, limit=None):
|
|
||||||
url = self.build_url('/blacklists', criterion, marker, limit)
|
|
||||||
|
|
||||||
return self._get(url, response_key="blacklists")
|
|
||||||
|
|
||||||
def get(self, blacklist_id):
|
|
||||||
url = '/blacklists/%s' % blacklist_id
|
|
||||||
|
|
||||||
return self._get(url)
|
|
||||||
|
|
||||||
def update(self, blacklist_id, values):
|
|
||||||
url = '/blacklists/%s' % blacklist_id
|
|
||||||
|
|
||||||
return self._patch(url, data=values)
|
|
||||||
|
|
||||||
def delete(self, blacklist_id):
|
|
||||||
url = '/blacklists/%s' % blacklist_id
|
|
||||||
|
|
||||||
return self._delete(url)
|
|
@ -1,155 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
from designateclient.v2.utils import get_all
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_blacklist(blacklist):
|
|
||||||
# Remove unneeded fields for display output formatting
|
|
||||||
blacklist.pop('links', None)
|
|
||||||
|
|
||||||
|
|
||||||
class ListBlacklistsCommand(command.Lister):
|
|
||||||
"""List blacklists"""
|
|
||||||
|
|
||||||
columns = ['id', 'pattern', 'description']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListBlacklistsCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
data = get_all(client.blacklists.list)
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowBlacklistCommand(command.ShowOne):
|
|
||||||
"""Show blacklist details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowBlacklistCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Blacklist ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.blacklists.get(parsed_args.id)
|
|
||||||
_format_blacklist(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class CreateBlacklistCommand(command.ShowOne):
|
|
||||||
"""Create new blacklist"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateBlacklistCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--pattern', help="Blacklist pattern",
|
|
||||||
required=True)
|
|
||||||
parser.add_argument('--description', help="Description")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.blacklists.create(
|
|
||||||
parsed_args.pattern, parsed_args.description)
|
|
||||||
|
|
||||||
_format_blacklist(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetBlacklistCommand(command.ShowOne):
|
|
||||||
"""Set blacklist properties"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetBlacklistCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Blacklist ID")
|
|
||||||
parser.add_argument('--pattern', help="Blacklist pattern")
|
|
||||||
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
if parsed_args.pattern:
|
|
||||||
data['pattern'] = parsed_args.pattern
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
data['description'] = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
data['description'] = parsed_args.description
|
|
||||||
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
updated = client.blacklists.update(parsed_args.id, data)
|
|
||||||
|
|
||||||
_format_blacklist(updated)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(updated)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteBlacklistCommand(command.Command):
|
|
||||||
"""Delete blacklist"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteBlacklistCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Blacklist ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
client.blacklists.delete(parsed_args.id)
|
|
||||||
|
|
||||||
LOG.info('Blacklist %s was deleted', parsed_args.id)
|
|
@ -1,133 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import itertools
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from cliff import command
|
|
||||||
from cliff import show
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
DNS_QUOTAS = {
|
|
||||||
"api_export_size": "api-export-size",
|
|
||||||
"recordset_records": "recordset-records",
|
|
||||||
"zone_records": "zone-records",
|
|
||||||
"zone_recordsets": "zone-recordsets",
|
|
||||||
"zones": "zones"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ListQuotasCommand(show.ShowOne):
|
|
||||||
"""List quotas"""
|
|
||||||
|
|
||||||
# columns = ['resource', 'hard_limit']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListQuotasCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
'--project-id',
|
|
||||||
help="Project ID Default: current project")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
proj_id = parsed_args.project_id or client.session.get_project_id()
|
|
||||||
|
|
||||||
if parsed_args.project_id != client.session.get_project_id():
|
|
||||||
common.set_all_projects(client, True)
|
|
||||||
|
|
||||||
data = client.quotas.list(proj_id)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetQuotasCommand(show.ShowOne):
|
|
||||||
"""Set blacklist properties"""
|
|
||||||
|
|
||||||
def _build_options_list(self):
|
|
||||||
return itertools.chain(DNS_QUOTAS.items())
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetQuotasCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
parser.add_argument('--project-id', help="Project ID")
|
|
||||||
for k, v in self._build_options_list():
|
|
||||||
parser.add_argument(
|
|
||||||
'--%s' % v,
|
|
||||||
metavar='<%s>' % v,
|
|
||||||
dest=k,
|
|
||||||
type=int,
|
|
||||||
help='New value for the %s quota' % v,
|
|
||||||
)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
quotas = {}
|
|
||||||
for k, v in DNS_QUOTAS.items():
|
|
||||||
value = getattr(parsed_args, k, None)
|
|
||||||
if value is not None:
|
|
||||||
quotas[k] = value
|
|
||||||
|
|
||||||
proj_id = parsed_args.project_id or client.session.get_project_id()
|
|
||||||
|
|
||||||
if parsed_args.project_id != client.session.get_project_id():
|
|
||||||
common.set_all_projects(client, True)
|
|
||||||
|
|
||||||
updated = client.quotas.update(proj_id, quotas)
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(updated)))
|
|
||||||
|
|
||||||
|
|
||||||
class ResetQuotasCommand(command.Command):
|
|
||||||
"""Delete blacklist"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ResetQuotasCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
parser.add_argument('--project-id', help="Project ID")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
proj_id = parsed_args.project_id or client.session.get_project_id()
|
|
||||||
|
|
||||||
if parsed_args.project_id != client.session.get_project_id():
|
|
||||||
common.set_all_projects(client, True)
|
|
||||||
|
|
||||||
client.quotas.reset(proj_id)
|
|
||||||
|
|
||||||
LOG.info('Quota for project %s was reset', parsed_args.project_id)
|
|
@ -1,142 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
from designateclient.v2.utils import get_all
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_floatingip(fip):
|
|
||||||
# Remove unneeded fields for display output formatting
|
|
||||||
fip.pop('links', None)
|
|
||||||
|
|
||||||
|
|
||||||
class ListFloatingIPCommand(command.Lister):
|
|
||||||
"""List floatingip ptr records"""
|
|
||||||
|
|
||||||
columns = ['id', 'ptrdname', 'description', 'ttl']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListFloatingIPCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
data = get_all(client.floatingips.list)
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowFloatingIPCommand(command.ShowOne):
|
|
||||||
"""Show floatingip ptr record details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowFloatingIPCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('floatingip_id', help="Floating IP ID in format "
|
|
||||||
"region:floatingip_id")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.floatingips.get(parsed_args.floatingip_id)
|
|
||||||
_format_floatingip(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetFloatingIPCommand(command.ShowOne):
|
|
||||||
"""Set floatingip ptr record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetFloatingIPCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('floatingip_id', help="Floating IP ID in format "
|
|
||||||
"region:floatingip_id")
|
|
||||||
parser.add_argument('ptrdname', help="PTRD Name")
|
|
||||||
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
ttl_group = parser.add_mutually_exclusive_group()
|
|
||||||
ttl_group.add_argument('--ttl', type=int, help="TTL")
|
|
||||||
ttl_group.add_argument('--no-ttl', action='store_true')
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
data['description'] = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
data['description'] = parsed_args.description
|
|
||||||
|
|
||||||
if parsed_args.no_ttl:
|
|
||||||
data['ttl'] = None
|
|
||||||
elif parsed_args.ttl:
|
|
||||||
data['ttl'] = parsed_args.ttl
|
|
||||||
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
fip = client.floatingips.set(
|
|
||||||
parsed_args.floatingip_id,
|
|
||||||
parsed_args.ptrdname,
|
|
||||||
parsed_args.description,
|
|
||||||
parsed_args.ttl)
|
|
||||||
|
|
||||||
_format_floatingip(fip)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(fip)))
|
|
||||||
|
|
||||||
|
|
||||||
class UnsetFloatingIPCommand(command.Command):
|
|
||||||
"""Unset floatingip ptr record"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(UnsetFloatingIPCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('floatingip_id', help="Floating IP ID in format "
|
|
||||||
"region:floatingip_id")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
client.floatingips.unset(parsed_args.floatingip_id)
|
|
||||||
LOG.info('FloatingIP PTR %s was unset', parsed_args.floatingip_id)
|
|
@ -1,94 +0,0 @@
|
|||||||
# Copyright 2016 Hewlett Packard Enterprise Development Company LP
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
from designateclient.v2 import utils as v2_utils
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_status(status):
|
|
||||||
status.pop("links", None)
|
|
||||||
# Remove unneeded fields for display output formatting
|
|
||||||
for k in ("capabilities", "stats"):
|
|
||||||
status[k] = "\n".join(status[k]) if status[k] else "-"
|
|
||||||
return status
|
|
||||||
|
|
||||||
|
|
||||||
class ListServiceStatusesCommand(command.Lister):
|
|
||||||
"""List service statuses"""
|
|
||||||
|
|
||||||
columns = ['id', 'hostname', 'service_name', 'status', 'stats',
|
|
||||||
'capabilities']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListServiceStatusesCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument("--hostname", help="Hostname", required=False)
|
|
||||||
parser.add_argument("--service_name", help="Service Name",
|
|
||||||
required=False)
|
|
||||||
parser.add_argument("--status", help="Status", required=False)
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
|
|
||||||
criterion = {}
|
|
||||||
for i in ["hostname", "service_name", "status"]:
|
|
||||||
v = getattr(parsed_args, i)
|
|
||||||
if v is not None:
|
|
||||||
criterion[i] = v
|
|
||||||
|
|
||||||
data = v2_utils.get_all(client.service_statuses.list,
|
|
||||||
criterion=criterion)
|
|
||||||
|
|
||||||
for i, s in enumerate(data):
|
|
||||||
data[i] = _format_status(s)
|
|
||||||
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowServiceStatusCommand(command.ShowOne):
|
|
||||||
"""Show service status details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowServiceStatusCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Service Status ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.service_statuses.get(parsed_args.id)
|
|
||||||
|
|
||||||
_format_status(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
@ -1,154 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
from designateclient.v2.utils import get_all
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_tld(tld):
|
|
||||||
# Remove unneeded fields for display output formatting
|
|
||||||
tld.pop('links', None)
|
|
||||||
|
|
||||||
|
|
||||||
class ListTLDsCommand(command.Lister):
|
|
||||||
"""List tlds"""
|
|
||||||
|
|
||||||
columns = ['id', 'name', 'description']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListTLDsCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="TLD NAME")
|
|
||||||
|
|
||||||
parser.add_argument('--description', help="TLD Description")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = get_all(client.tlds.list)
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowTLDCommand(command.ShowOne):
|
|
||||||
"""Show tld details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowTLDCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="TLD ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.tlds.get(parsed_args.id)
|
|
||||||
_format_tld(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class CreateTLDCommand(command.ShowOne):
|
|
||||||
"""Create new tld"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateTLDCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="TLD Name", required=True)
|
|
||||||
parser.add_argument('--description', help="Description")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.tlds.create(parsed_args.name, parsed_args.description)
|
|
||||||
_format_tld(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetTLDCommand(command.ShowOne):
|
|
||||||
"""Set tld properties"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetTLDCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="TLD ID")
|
|
||||||
parser.add_argument('--name', help="TLD Name")
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
if parsed_args.name:
|
|
||||||
data['name'] = parsed_args.name
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
data['description'] = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
data['description'] = parsed_args.description
|
|
||||||
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.tlds.update(parsed_args.id, data)
|
|
||||||
_format_tld(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteTLDCommand(command.Command):
|
|
||||||
"""Delete tld"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteTLDCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="TLD ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
client.tlds.delete(parsed_args.id)
|
|
||||||
|
|
||||||
LOG.info('TLD %s was deleted', parsed_args.id)
|
|
@ -1,170 +0,0 @@
|
|||||||
# Copyright 2017 SAP SE
|
|
||||||
#
|
|
||||||
# Author: Rudolf Vriend <rudolf.vriend@sap.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
from designateclient.v2.utils import get_all
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_tsigkey(tsigkey):
|
|
||||||
# Remove unneeded fields for display output formatting
|
|
||||||
tsigkey.pop('links', None)
|
|
||||||
|
|
||||||
|
|
||||||
class ListTSIGKeysCommand(command.Lister):
|
|
||||||
"""List tsigkeys"""
|
|
||||||
|
|
||||||
columns = ['id', 'name', 'algorithm', 'secret', 'scope', 'resource_id']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListTSIGKeysCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="TSIGKey NAME", required=False)
|
|
||||||
parser.add_argument('--algorithm', help="TSIGKey algorithm",
|
|
||||||
required=False)
|
|
||||||
parser.add_argument('--scope', help="TSIGKey scope", required=False)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
criterion = {}
|
|
||||||
if parsed_args.name is not None:
|
|
||||||
criterion["name"] = parsed_args.name
|
|
||||||
if parsed_args.algorithm is not None:
|
|
||||||
criterion["algorithm"] = parsed_args.algorithm
|
|
||||||
if parsed_args.scope is not None:
|
|
||||||
criterion["scope"] = parsed_args.scope
|
|
||||||
|
|
||||||
data = get_all(client.tsigkeys.list, criterion)
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowTSIGKeyCommand(command.ShowOne):
|
|
||||||
"""Show tsigkey details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowTSIGKeyCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="TSIGKey ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.tsigkeys.get(parsed_args.id)
|
|
||||||
_format_tsigkey(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class CreateTSIGKeyCommand(command.ShowOne):
|
|
||||||
"""Create new tsigkey"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateTSIGKeyCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="TSIGKey Name", required=True)
|
|
||||||
parser.add_argument('--algorithm', help="TSIGKey algorithm",
|
|
||||||
required=True)
|
|
||||||
parser.add_argument('--secret', help="TSIGKey secret", required=True)
|
|
||||||
parser.add_argument('--scope', help="TSIGKey scope", required=True)
|
|
||||||
parser.add_argument('--resource-id', help="TSIGKey resource_id",
|
|
||||||
required=True)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
data = client.tsigkeys.create(parsed_args.name, parsed_args.algorithm,
|
|
||||||
parsed_args.secret, parsed_args.scope,
|
|
||||||
parsed_args.resource_id)
|
|
||||||
_format_tsigkey(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetTSIGKeyCommand(command.ShowOne):
|
|
||||||
"""Set tsigkey properties"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetTSIGKeyCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="TSIGKey ID")
|
|
||||||
parser.add_argument('--name', help="TSIGKey Name")
|
|
||||||
parser.add_argument('--algorithm', help="TSIGKey algorithm")
|
|
||||||
parser.add_argument('--secret', help="TSIGKey secret")
|
|
||||||
parser.add_argument('--scope', help="TSIGKey scope")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
if parsed_args.name:
|
|
||||||
data['name'] = parsed_args.name
|
|
||||||
if parsed_args.algorithm:
|
|
||||||
data['algorithm'] = parsed_args.algorithm
|
|
||||||
if parsed_args.secret:
|
|
||||||
data['secret'] = parsed_args.secret
|
|
||||||
if parsed_args.scope:
|
|
||||||
data['scope'] = parsed_args.scope
|
|
||||||
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.tsigkeys.update(parsed_args.id, data)
|
|
||||||
_format_tsigkey(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteTSIGKeyCommand(command.Command):
|
|
||||||
"""Delete tsigkey"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteTSIGKeyCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="TSIGKey ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
client.tsigkeys.delete(parsed_args.id)
|
|
||||||
|
|
||||||
LOG.info('TSIGKey %s was deleted', parsed_args.id)
|
|
@ -1,716 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
|
||||||
from osc_lib import exceptions as osc_exc
|
|
||||||
import six
|
|
||||||
|
|
||||||
from designateclient import utils
|
|
||||||
from designateclient.v2.cli import common
|
|
||||||
from designateclient.v2.utils import get_all
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_zone(zone):
|
|
||||||
zone.pop('links', None)
|
|
||||||
zone['masters'] = ", ".join(zone['masters'])
|
|
||||||
attrib = ''
|
|
||||||
for attr in zone['attributes']:
|
|
||||||
attrib += "%s:%s\n" % (attr, zone['attributes'][attr])
|
|
||||||
zone['attributes'] = attrib
|
|
||||||
|
|
||||||
|
|
||||||
def _format_zone_export_record(zone_export_record):
|
|
||||||
zone_export_record.pop('links', None)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_zone_import_record(zone_import_record):
|
|
||||||
zone_import_record.pop('links', None)
|
|
||||||
|
|
||||||
|
|
||||||
class ListZonesCommand(command.Lister):
|
|
||||||
"""List zones"""
|
|
||||||
|
|
||||||
columns = ['id', 'name', 'type', 'serial', 'status', 'action']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListZonesCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--name', help="Zone Name", required=False)
|
|
||||||
parser.add_argument('--email', help="Zone Email", required=False)
|
|
||||||
parser.add_argument('--type', help="Zone Type", required=False)
|
|
||||||
parser.add_argument('--ttl', help="Time To Live (Seconds)",
|
|
||||||
required=False)
|
|
||||||
parser.add_argument('--description', help="Description",
|
|
||||||
required=False)
|
|
||||||
parser.add_argument('--status', help="Zone Status", required=False)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
criterion = {}
|
|
||||||
if parsed_args.type is not None:
|
|
||||||
criterion["type"] = parsed_args.type
|
|
||||||
|
|
||||||
if parsed_args.name is not None:
|
|
||||||
criterion["name"] = parsed_args.name
|
|
||||||
|
|
||||||
if parsed_args.ttl is not None:
|
|
||||||
criterion["ttl"] = parsed_args.ttl
|
|
||||||
|
|
||||||
if parsed_args.description is not None:
|
|
||||||
criterion["description"] = parsed_args.description
|
|
||||||
|
|
||||||
if parsed_args.email is not None:
|
|
||||||
criterion["email"] = parsed_args.email
|
|
||||||
|
|
||||||
if parsed_args.status is not None:
|
|
||||||
criterion["status"] = parsed_args.status
|
|
||||||
|
|
||||||
data = get_all(client.zones.list, criterion)
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
|
|
||||||
if client.session.all_projects:
|
|
||||||
cols.insert(1, 'project_id')
|
|
||||||
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowZoneCommand(command.ShowOne):
|
|
||||||
"""Show zone details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowZoneCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zones.get(parsed_args.id)
|
|
||||||
|
|
||||||
_format_zone(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class CreateZoneCommand(command.ShowOne):
|
|
||||||
"""Create new zone"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateZoneCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('name', help="Zone Name")
|
|
||||||
parser.add_argument('--email', help="Zone Email")
|
|
||||||
parser.add_argument('--type', help="Zone Type", default='PRIMARY')
|
|
||||||
parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)")
|
|
||||||
parser.add_argument('--description', help="Description")
|
|
||||||
parser.add_argument('--masters', help="Zone Masters", nargs='+')
|
|
||||||
parser.add_argument('--attributes', help="Zone Attributes", nargs='+')
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
|
|
||||||
if parsed_args.description:
|
|
||||||
payload["description"] = parsed_args.description
|
|
||||||
|
|
||||||
if parsed_args.attributes:
|
|
||||||
payload["attributes"] = {}
|
|
||||||
for attr in parsed_args.attributes:
|
|
||||||
try:
|
|
||||||
k, v = attr.split(':')
|
|
||||||
payload["attributes"][k] = v
|
|
||||||
except ValueError:
|
|
||||||
msg = "Attribute '%s' is in an incorrect format. "\
|
|
||||||
"Attributes are <key>:<value> formated"
|
|
||||||
raise osc_exc.CommandError(msg % attr)
|
|
||||||
|
|
||||||
if parsed_args.type == 'PRIMARY':
|
|
||||||
# email is just for PRIMARY.
|
|
||||||
if not parsed_args.email:
|
|
||||||
msg = "Zone type PRIMARY requires --email."
|
|
||||||
raise osc_exc.CommandError(msg)
|
|
||||||
|
|
||||||
payload["email"] = parsed_args.email
|
|
||||||
|
|
||||||
# TTL is just valid for PRIMARY
|
|
||||||
if parsed_args.ttl is not None:
|
|
||||||
payload["ttl"] = parsed_args.ttl
|
|
||||||
elif parsed_args.type == 'SECONDARY':
|
|
||||||
payload["masters"] = parsed_args.masters
|
|
||||||
else:
|
|
||||||
msg = "Type %s is not supported. Please choose between " \
|
|
||||||
"PRIMARY or SECONDARY"
|
|
||||||
raise osc_exc.CommandError(msg % parsed_args.type)
|
|
||||||
|
|
||||||
data = client.zones.create(
|
|
||||||
parsed_args.name, parsed_args.type, **payload)
|
|
||||||
|
|
||||||
_format_zone(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetZoneCommand(command.ShowOne):
|
|
||||||
"""Set zone properties"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetZoneCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone ID")
|
|
||||||
parser.add_argument('--email', help="Zone Email")
|
|
||||||
parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)")
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
parser.add_argument('--masters', help="Zone Masters", nargs='+')
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
# TODO(kiall): API needs updating.. this get is silly
|
|
||||||
if parsed_args.email:
|
|
||||||
data['email'] = parsed_args.email
|
|
||||||
|
|
||||||
if parsed_args.ttl:
|
|
||||||
data['ttl'] = parsed_args.ttl
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
data['description'] = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
data['description'] = parsed_args.description
|
|
||||||
|
|
||||||
if parsed_args.masters:
|
|
||||||
data['masters'] = parsed_args.masters
|
|
||||||
|
|
||||||
updated = client.zones.update(parsed_args.id, data)
|
|
||||||
_format_zone(updated)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(updated)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteZoneCommand(command.ShowOne):
|
|
||||||
"""Delete zone"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteZoneCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zones.delete(parsed_args.id)
|
|
||||||
LOG.info('Zone %s was deleted', parsed_args.id)
|
|
||||||
|
|
||||||
_format_zone(data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class AbandonZoneCommand(command.Command):
|
|
||||||
"""Abandon a zone"""
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(AbandonZoneCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
client.zones.abandon(parsed_args.id)
|
|
||||||
|
|
||||||
LOG.info("Z %(zone_id)s abandoned",
|
|
||||||
{"zone_id": parsed_args.id})
|
|
||||||
|
|
||||||
|
|
||||||
class AXFRZoneCommand(command.Command):
|
|
||||||
"""AXFR a zone"""
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(AXFRZoneCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
client.zones.axfr(parsed_args.id)
|
|
||||||
|
|
||||||
LOG.info("Scheduled AXFR for zone %(zone_id)s",
|
|
||||||
{"zone_id": parsed_args.id})
|
|
||||||
|
|
||||||
|
|
||||||
class CreateTransferRequestCommand(command.ShowOne):
|
|
||||||
"""Create new zone transfer request"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(CreateTransferRequestCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_id', help="Zone ID to transfer.",)
|
|
||||||
parser.add_argument(
|
|
||||||
'--target-project-id',
|
|
||||||
help="Target Project ID to transfer to.")
|
|
||||||
parser.add_argument('--description', help="Description")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_transfers.create_request(
|
|
||||||
parsed_args.zone_id, parsed_args.target_project_id,
|
|
||||||
parsed_args.description)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class ListTransferRequestsCommand(command.Lister):
|
|
||||||
"""List Zone Transfer Requests"""
|
|
||||||
|
|
||||||
columns = ['id', 'zone_id', 'zone_name', 'project_id',
|
|
||||||
'target_project_id', 'status', 'key']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListTransferRequestsCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_transfers.list_requests()
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowTransferRequestCommand(command.ShowOne):
|
|
||||||
"""Show Zone Transfer Request Details"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowTransferRequestCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone Tranfer Request ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_transfers.get_request(parsed_args.id)
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class SetTransferRequestCommand(command.ShowOne):
|
|
||||||
"""Set a Zone Transfer Request"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(SetTransferRequestCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone Transfer Request ID")
|
|
||||||
description_group = parser.add_mutually_exclusive_group()
|
|
||||||
description_group.add_argument('--description', help="Description")
|
|
||||||
description_group.add_argument('--no-description', action='store_true')
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
if parsed_args.no_description:
|
|
||||||
data['description'] = None
|
|
||||||
elif parsed_args.description:
|
|
||||||
data['description'] = parsed_args.description
|
|
||||||
|
|
||||||
updated = client.zone_transfers.update_request(parsed_args.id, data)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(updated)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteTransferRequestCommand(command.Command):
|
|
||||||
"""Delete a Zone Transfer Request"""
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteTransferRequestCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone Transfer Request ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
client.zone_transfers.delete_request(parsed_args.id)
|
|
||||||
|
|
||||||
LOG.info('Zone Transfer %s was deleted', parsed_args.id)
|
|
||||||
|
|
||||||
|
|
||||||
class AcceptTransferRequestCommand(command.ShowOne):
|
|
||||||
"""Accept a Zone Transfer Request"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(AcceptTransferRequestCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('--transfer-id', help="Transfer ID", type=str,
|
|
||||||
required=True)
|
|
||||||
parser.add_argument('--key', help="Transfer Key", type=str,
|
|
||||||
required=True)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_transfers.accept_request(
|
|
||||||
parsed_args.transfer_id, parsed_args.key)
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class ListTransferAcceptsCommand(command.Lister):
|
|
||||||
"""List Zone Transfer Accepts"""
|
|
||||||
|
|
||||||
columns = ['id', 'zone_id', 'project_id',
|
|
||||||
'zone_transfer_request_id', 'status', 'key']
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListTransferAcceptsCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_transfers.list_requests()
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowTransferAcceptCommand(command.ShowOne):
|
|
||||||
"""Show Zone Transfer Accept"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowTransferAcceptCommand, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('id', help="Zone Tranfer Accept ID")
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_transfers.get_accept(parsed_args.id)
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class ExportZoneCommand(command.ShowOne):
|
|
||||||
"""Export a Zone"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ExportZoneCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
parser.add_argument('zone_id', help="Zone ID", type=str)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_exports.create(parsed_args.zone_id)
|
|
||||||
_format_zone_export_record(data)
|
|
||||||
|
|
||||||
LOG.info('Zone Export %s was created', data['id'])
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class ListZoneExportsCommand(command.Lister):
|
|
||||||
"""List Zone Exports"""
|
|
||||||
|
|
||||||
columns = [
|
|
||||||
'id',
|
|
||||||
'zone_id',
|
|
||||||
'created_at',
|
|
||||||
'status',
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListZoneExportsCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_exports.list()
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
return cols, (utils.get_item_properties(s, cols)
|
|
||||||
for s in data['exports'])
|
|
||||||
|
|
||||||
|
|
||||||
class ShowZoneExportCommand(command.ShowOne):
|
|
||||||
"""Show a Zone Export"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowZoneExportCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_export_id', help="Zone Export ID", type=str)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_exports.get_export_record(
|
|
||||||
parsed_args.zone_export_id)
|
|
||||||
_format_zone_export_record(data)
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteZoneExportCommand(command.Command):
|
|
||||||
"""Delete a Zone Export"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteZoneExportCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_export_id', help="Zone Export ID", type=str)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
client.zone_exports.delete(parsed_args.zone_export_id)
|
|
||||||
|
|
||||||
LOG.info('Zone Export %s was deleted', parsed_args.zone_export_id)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowZoneExportFileCommand(command.ShowOne):
|
|
||||||
"""Show the zone file for the Zone Export"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowZoneExportFileCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_export_id', help="Zone Export ID", type=str)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_exports.get_export(parsed_args.zone_export_id)
|
|
||||||
|
|
||||||
return ['data'], [data]
|
|
||||||
|
|
||||||
|
|
||||||
class ImportZoneCommand(command.ShowOne):
|
|
||||||
"""Import a Zone from a file on the filesystem"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ImportZoneCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_file_path',
|
|
||||||
help="Path to a zone file", type=str)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
with open(parsed_args.zone_file_path, 'r') as f:
|
|
||||||
zone_file_contents = f.read()
|
|
||||||
|
|
||||||
data = client.zone_imports.create(zone_file_contents)
|
|
||||||
_format_zone_import_record(data)
|
|
||||||
|
|
||||||
LOG.info('Zone Import %s was created', data['id'])
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class ListZoneImportsCommand(command.Lister):
|
|
||||||
"""List Zone Imports"""
|
|
||||||
|
|
||||||
columns = [
|
|
||||||
'id',
|
|
||||||
'zone_id',
|
|
||||||
'created_at',
|
|
||||||
'status',
|
|
||||||
'message',
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ListZoneImportsCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_imports.list()
|
|
||||||
|
|
||||||
cols = self.columns
|
|
||||||
return cols, (utils.get_item_properties(s, cols)
|
|
||||||
for s in data['imports'])
|
|
||||||
|
|
||||||
|
|
||||||
class ShowZoneImportCommand(command.ShowOne):
|
|
||||||
"""Show a Zone Import"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(ShowZoneImportCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_import_id', help="Zone Import ID", type=str)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
data = client.zone_imports.get_import_record(
|
|
||||||
parsed_args.zone_import_id)
|
|
||||||
_format_zone_import_record(data)
|
|
||||||
|
|
||||||
return six.moves.zip(*sorted(six.iteritems(data)))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteZoneImportCommand(command.Command):
|
|
||||||
"""Delete a Zone Import"""
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(DeleteZoneImportCommand, self).get_parser(
|
|
||||||
prog_name)
|
|
||||||
|
|
||||||
parser.add_argument('zone_import_id', help="Zone Import ID", type=str)
|
|
||||||
|
|
||||||
common.add_all_common_options(parser)
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
client = self.app.client_manager.dns
|
|
||||||
common.set_all_common_headers(client, parsed_args)
|
|
||||||
|
|
||||||
client.zone_imports.delete(parsed_args.zone_import_id)
|
|
||||||
|
|
||||||
LOG.info('Zone Import %s was deleted', parsed_args.zone_import_id)
|
|
@ -1,21 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
|
|
||||||
|
|
||||||
class LimitController(V2Controller):
|
|
||||||
def get(self):
|
|
||||||
return self._get('/limits')
|
|
@ -1,26 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
from designateclient.v2 import utils as v2_utils
|
|
||||||
|
|
||||||
|
|
||||||
class NameServerController(V2Controller):
|
|
||||||
def list(self, zone):
|
|
||||||
zone = v2_utils.resolve_by_name(self.client.zones.list, zone)
|
|
||||||
|
|
||||||
url = '/zones/%s/nameservers' % zone
|
|
||||||
|
|
||||||
return self._get(url, response_key='nameservers')
|
|
@ -1,22 +0,0 @@
|
|||||||
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
# implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
|
|
||||||
|
|
||||||
class PoolController(V2Controller):
|
|
||||||
def list(self):
|
|
||||||
url = '/pools'
|
|
||||||
return self._get(url, response_key='pools')
|
|
@ -1,27 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
|
|
||||||
|
|
||||||
class QuotasController(V2Controller):
|
|
||||||
def list(self, project_id):
|
|
||||||
return self._get('/quotas/%s' % project_id)
|
|
||||||
|
|
||||||
def update(self, project_id, values):
|
|
||||||
return self._patch('/quotas/%s' % project_id, data=values)
|
|
||||||
|
|
||||||
def reset(self, project_id):
|
|
||||||
return self._delete('/quotas/%s' % project_id)
|
|
@ -1,49 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
|
|
||||||
|
|
||||||
class FloatingIPController(V2Controller):
|
|
||||||
def set(self, floatingip_id, ptrdname, description=None, ttl=None):
|
|
||||||
data = {
|
|
||||||
'ptrdname': ptrdname
|
|
||||||
}
|
|
||||||
|
|
||||||
if description is not None:
|
|
||||||
data["description"] = description
|
|
||||||
|
|
||||||
if ttl is not None:
|
|
||||||
data["ttl"] = ttl
|
|
||||||
|
|
||||||
url = '/reverse/floatingips/%s' % floatingip_id
|
|
||||||
return self._patch(url, data=data)
|
|
||||||
|
|
||||||
def list(self, criterion=None):
|
|
||||||
url = self.build_url('/reverse/floatingips', criterion)
|
|
||||||
|
|
||||||
return self._get(url, response_key='floatingips')
|
|
||||||
|
|
||||||
def get(self, floatingip_id):
|
|
||||||
url = '/reverse/floatingips/%s' % floatingip_id
|
|
||||||
|
|
||||||
return self._get(url)
|
|
||||||
|
|
||||||
def unset(self, floatingip_id):
|
|
||||||
data = {"ptrdname": None}
|
|
||||||
|
|
||||||
url = '/reverse/floatingips/%s' % floatingip_id
|
|
||||||
|
|
||||||
return self._patch(url, data=data)
|
|
@ -1,28 +0,0 @@
|
|||||||
# Copyright 2016 Hewlett Packard Enterprise Development Company LP
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2 import base
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceStatusesController(base.V2Controller):
|
|
||||||
def list(self, criterion=None, marker=None, limit=None):
|
|
||||||
url = self.build_url('/service_statuses', criterion, marker, limit)
|
|
||||||
|
|
||||||
return self._get(url, response_key="service_statuses")
|
|
||||||
|
|
||||||
def get(self, service_status_id):
|
|
||||||
url = '/service_statuses/%s' % service_status_id
|
|
||||||
|
|
||||||
return self._get(url)
|
|
@ -1,49 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
from designateclient.v2 import utils as v2_utils
|
|
||||||
|
|
||||||
|
|
||||||
class TLDController(V2Controller):
|
|
||||||
def create(self, name, description=None):
|
|
||||||
data = {
|
|
||||||
'name': name,
|
|
||||||
}
|
|
||||||
|
|
||||||
if description is not None:
|
|
||||||
data["description"] = description
|
|
||||||
|
|
||||||
return self._post('/tlds', data=data)
|
|
||||||
|
|
||||||
def list(self, criterion=None, marker=None, limit=None):
|
|
||||||
url = self.build_url('/tlds', criterion, marker, limit)
|
|
||||||
|
|
||||||
return self._get(url, response_key='tlds')
|
|
||||||
|
|
||||||
def get(self, tld):
|
|
||||||
tld = v2_utils.resolve_by_name(self.list, tld)
|
|
||||||
|
|
||||||
return self._get('/tlds/%s' % tld)
|
|
||||||
|
|
||||||
def update(self, tld, values):
|
|
||||||
tld = v2_utils.resolve_by_name(self.list, tld)
|
|
||||||
|
|
||||||
return self._patch('/tlds/%s' % tld, data=values)
|
|
||||||
|
|
||||||
def delete(self, tld):
|
|
||||||
tld = v2_utils.resolve_by_name(self.list, tld)
|
|
||||||
|
|
||||||
return self._delete('/tlds/%s' % tld)
|
|
@ -1,50 +0,0 @@
|
|||||||
# Copyright 2017 SAP SE
|
|
||||||
#
|
|
||||||
# Author: Rudolf Vriend <rudolf.vriend@sap.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
from designateclient.v2 import utils as v2_utils
|
|
||||||
|
|
||||||
|
|
||||||
class TSIGKeysController(V2Controller):
|
|
||||||
def create(self, name, algorithm, secret, scope, resource_id):
|
|
||||||
data = {
|
|
||||||
'name': name,
|
|
||||||
'algorithm': algorithm,
|
|
||||||
'secret': secret,
|
|
||||||
'scope': scope,
|
|
||||||
'resource_id': resource_id
|
|
||||||
}
|
|
||||||
|
|
||||||
return self._post('/tsigkeys', data=data)
|
|
||||||
|
|
||||||
def list(self, criterion=None, marker=None, limit=None):
|
|
||||||
url = self.build_url('/tsigkeys', criterion, marker, limit)
|
|
||||||
|
|
||||||
return self._get(url, response_key='tsigkeys')
|
|
||||||
|
|
||||||
def get(self, tsigkey):
|
|
||||||
tsigkey = v2_utils.resolve_by_name(self.list, tsigkey)
|
|
||||||
|
|
||||||
return self._get('/tsigkeys/%s' % tsigkey)
|
|
||||||
|
|
||||||
def update(self, tsigkey, values):
|
|
||||||
tsigkey = v2_utils.resolve_by_name(self.list, tsigkey)
|
|
||||||
|
|
||||||
return self._patch('/tsigkeys/%s' % tsigkey, data=values)
|
|
||||||
|
|
||||||
def delete(self, tsigkey):
|
|
||||||
tsigkey = v2_utils.resolve_by_name(self.list, tsigkey)
|
|
||||||
|
|
||||||
return self._delete('/tsigkeys/%s' % tsigkey)
|
|
@ -1,168 +0,0 @@
|
|||||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Author: Endre Karlson <endre.karlson@hp.com>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from designateclient.v2.base import V2Controller
|
|
||||||
from designateclient.v2 import utils as v2_utils
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneController(V2Controller):
|
|
||||||
def create(self, name, type_=None, email=None, description=None, ttl=None,
|
|
||||||
masters=None, attributes=None):
|
|
||||||
type_ = type_ or "PRIMARY"
|
|
||||||
|
|
||||||
data = {
|
|
||||||
"name": name,
|
|
||||||
"type": type_
|
|
||||||
}
|
|
||||||
|
|
||||||
if type_ == "PRIMARY":
|
|
||||||
if email:
|
|
||||||
data["email"] = email
|
|
||||||
|
|
||||||
if ttl is not None:
|
|
||||||
data["ttl"] = ttl
|
|
||||||
|
|
||||||
elif type_ == "SECONDARY" and masters:
|
|
||||||
data["masters"] = masters
|
|
||||||
|
|
||||||
if description is not None:
|
|
||||||
data["description"] = description
|
|
||||||
|
|
||||||
if attributes is not None:
|
|
||||||
data["attributes"] = attributes
|
|
||||||
|
|
||||||
return self._post('/zones', data=data)
|
|
||||||
|
|
||||||
def list(self, criterion=None, marker=None, limit=None):
|
|
||||||
url = self.build_url('/zones', criterion, marker, limit)
|
|
||||||
|
|
||||||
return self._get(url, response_key="zones")
|
|
||||||
|
|
||||||
def get(self, zone):
|
|
||||||
zone = v2_utils.resolve_by_name(self.list, zone)
|
|
||||||
|
|
||||||
return self._get('/zones/%s' % zone)
|
|
||||||
|
|
||||||
def update(self, zone, values):
|
|
||||||
zone = v2_utils.resolve_by_name(self.list, zone)
|
|
||||||
|
|
||||||
url = self.build_url('/zones/%s' % zone)
|
|
||||||
|
|
||||||
return self._patch(url, data=values)
|
|
||||||
|
|
||||||
def delete(self, zone):
|
|
||||||
zone = v2_utils.resolve_by_name(self.list, zone)
|
|
||||||
|
|
||||||
url = self.build_url('/zones/%s' % zone)
|
|
||||||
|
|
||||||
return self._delete(url)
|
|
||||||
|
|
||||||
def abandon(self, zone):
|
|
||||||
zone = v2_utils.resolve_by_name(self.list, zone)
|
|
||||||
|
|
||||||
url = '/zones/%s/tasks/abandon' % zone
|
|
||||||
|
|
||||||
self.client.session.post(url)
|
|
||||||
|
|
||||||
def axfr(self, zone):
|
|
||||||
zone = v2_utils.resolve_by_name(self.list, zone)
|
|
||||||
|
|
||||||
url = '/zones/%s/tasks/xfr' % zone
|
|
||||||
|
|
||||||
self.client.session.post(url)
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneTransfersController(V2Controller):
|
|
||||||
def create_request(self, zone, target_project_id, description=None):
|
|
||||||
zone = v2_utils.resolve_by_name(self.client.zones.list, zone)
|
|
||||||
|
|
||||||
data = {
|
|
||||||
"target_project_id": target_project_id
|
|
||||||
}
|
|
||||||
|
|
||||||
if description is not None:
|
|
||||||
data["description"] = description
|
|
||||||
|
|
||||||
url = '/zones/%s/tasks/transfer_requests' % zone
|
|
||||||
|
|
||||||
return self._post(url, data=data)
|
|
||||||
|
|
||||||
def get_request(self, transfer_id):
|
|
||||||
url = '/zones/tasks/transfer_requests/%s' % transfer_id
|
|
||||||
return self._get(url)
|
|
||||||
|
|
||||||
def list_requests(self):
|
|
||||||
url = '/zones/tasks/transfer_requests'
|
|
||||||
return self._get(url, response_key="transfer_requests")
|
|
||||||
|
|
||||||
def update_request(self, transfer_id, values):
|
|
||||||
url = '/zones/tasks/transfer_requests/%s' % transfer_id
|
|
||||||
return self._patch(url, data=values)
|
|
||||||
|
|
||||||
def delete_request(self, transfer_id):
|
|
||||||
url = '/zones/tasks/transfer_requests/%s' % transfer_id
|
|
||||||
self._delete(url)
|
|
||||||
|
|
||||||
def accept_request(self, transfer_id, key):
|
|
||||||
url = '/zones/tasks/transfer_accepts'
|
|
||||||
|
|
||||||
data = {
|
|
||||||
"key": key,
|
|
||||||
"zone_transfer_request_id": transfer_id
|
|
||||||
}
|
|
||||||
return self._post(url, data=data)
|
|
||||||
|
|
||||||
def get_accept(self, accept_id):
|
|
||||||
url = '/zones/tasks/transfer_accepts/%s' % accept_id
|
|
||||||
return self._get(url)
|
|
||||||
|
|
||||||
def list_accepts(self):
|
|
||||||
url = '/zones/tasks/transfer_accepts'
|
|
||||||
return self._get(url, response_key="transfer_accepts")
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneExportsController(V2Controller):
|
|
||||||
def create(self, zone):
|
|
||||||
zone_id = v2_utils.resolve_by_name(self.client.zones.list, zone)
|
|
||||||
|
|
||||||
return self._post('/zones/%s/tasks/export' % zone_id)
|
|
||||||
|
|
||||||
def get_export_record(self, zone_export_id):
|
|
||||||
return self._get('/zones/tasks/exports/%s' % zone_export_id)
|
|
||||||
|
|
||||||
def list(self):
|
|
||||||
return self._get('/zones/tasks/exports')
|
|
||||||
|
|
||||||
def delete(self, zone_export_id):
|
|
||||||
return self._delete('/zones/tasks/exports/%s' % zone_export_id)
|
|
||||||
|
|
||||||
def get_export(self, zone_export_id):
|
|
||||||
return self._get('/zones/tasks/exports/%s/export' % zone_export_id,
|
|
||||||
headers={'Accept': 'text/dns'})
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneImportsController(V2Controller):
|
|
||||||
def create(self, zone_file_contents):
|
|
||||||
return self._post('/zones/tasks/imports', data=zone_file_contents,
|
|
||||||
headers={'Content-Type': 'text/dns'})
|
|
||||||
|
|
||||||
def get_import_record(self, zone_import_id):
|
|
||||||
return self._get('/zones/tasks/imports/%s' % zone_import_id)
|
|
||||||
|
|
||||||
def list(self):
|
|
||||||
return self._get('/zones/tasks/imports')
|
|
||||||
|
|
||||||
def delete(self, zone_import_id):
|
|
||||||
return self._delete('/zones/tasks/imports/%s' % zone_import_id)
|
|
@ -1,9 +1,9 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from designateclient.v2 import client
|
from tatuclient.v2 import client
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
|
|
||||||
from keystoneauth1.identity import generic
|
from keystoneauth1.identity import generic
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from designateclient.v2 import client
|
from tatuclient.v2 import client
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
|
|
||||||
from keystoneauth1.identity import generic
|
from keystoneauth1.identity import generic
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
@ -2,9 +2,9 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
from designateclient.v2 import client
|
from tatuclient.v2 import client
|
||||||
|
|
||||||
from keystoneauth1.identity import generic
|
from keystoneauth1.identity import generic
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
@ -4,9 +4,9 @@ import uuid
|
|||||||
from keystoneauth1.identity import generic
|
from keystoneauth1.identity import generic
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
from designateclient.v2 import client
|
from tatuclient.v2 import client
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level='DEBUG')
|
logging.basicConfig(level='DEBUG')
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.v2 import client
|
from tatuclient.v2 import client
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
from designateclient import utils
|
from tatuclient import utils
|
||||||
|
|
||||||
from keystoneauth1.identity import generic
|
from keystoneauth1.identity import generic
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
@ -4,8 +4,8 @@ import logging
|
|||||||
from keystoneauth1.identity import generic
|
from keystoneauth1.identity import generic
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
from designateclient.v2 import client
|
from tatuclient.v2 import client
|
||||||
|
|
||||||
logging.basicConfig(level='DEBUG')
|
logging.basicConfig(level='DEBUG')
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# designateclient documentation build configuration file
|
# tatuclient documentation build configuration file
|
||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
# -- General configuration -----------------------------------------------------
|
||||||
|
|
||||||
@ -9,8 +9,8 @@
|
|||||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'openstackdocstheme']
|
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'openstackdocstheme']
|
||||||
|
|
||||||
# openstackdocstheme options
|
# openstackdocstheme options
|
||||||
repository_name = 'openstack/python-designateclient'
|
repository_name = 'openstack/python-tatuclient'
|
||||||
bug_project = 'python-designateclient'
|
bug_project = 'python-tatuclient'
|
||||||
bug_tag = ''
|
bug_tag = ''
|
||||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
||||||
html_theme = 'openstackdocs'
|
html_theme = 'openstackdocs'
|
||||||
@ -25,7 +25,7 @@ source_suffix = '.rst'
|
|||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'designateclient'
|
project = u'tatuclient'
|
||||||
copyright = u'2012, Managed I.T. 2013-2014, Hewlett-Packard Development Company, L.P.'
|
copyright = u'2012, Managed I.T. 2013-2014, Hewlett-Packard Development Company, L.P.'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
@ -33,7 +33,7 @@ copyright = u'2012, Managed I.T. 2013-2014, Hewlett-Packard Development Company,
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
from designateclient.version import version_info as designateclient_version
|
from tatuclient.version import version_info as designateclient_version
|
||||||
version = designateclient_version.canonical_version_string()
|
version = designateclient_version.canonical_version_string()
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = designateclient_version.version_string_with_vcs()
|
release = designateclient_version.version_string_with_vcs()
|
||||||
@ -46,7 +46,7 @@ exclude_patterns = []
|
|||||||
pygments_style = 'sphinx'
|
pygments_style = 'sphinx'
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
# A list of ignored prefixes for module index sorting.
|
||||||
modindex_common_prefix = ['designateclient']
|
modindex_common_prefix = ['tatuclient']
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ---------------------------------------------------
|
# -- Options for HTML output ---------------------------------------------------
|
||||||
|
@ -42,8 +42,8 @@ extensions = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# openstackdocstheme options
|
# openstackdocstheme options
|
||||||
repository_name = 'openstack/python-designateclient'
|
repository_name = 'openstack/python-tatuclient'
|
||||||
bug_project = 'python-designateclient'
|
bug_project = 'python-tatuclient'
|
||||||
bug_tag = ''
|
bug_tag = ''
|
||||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
||||||
html_theme = 'openstackdocs'
|
html_theme = 'openstackdocs'
|
||||||
|
163
setup.cfg
163
setup.cfg
@ -1,12 +1,12 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = python-designateclient
|
name = python-tatuclient
|
||||||
summary = OpenStack DNS-as-a-Service - Client
|
summary = OpenStack SSH-as-a-Service - Client
|
||||||
description-file =
|
description-file =
|
||||||
README.rst
|
README.rst
|
||||||
license = Apache License, Version 2.0
|
license = Apache License, Version 2.0
|
||||||
author = OpenStack
|
author = OpenStack
|
||||||
author-email = openstack-dev@lists.openstack.org
|
author-email = openstack-dev@lists.openstack.org
|
||||||
home-page = https://docs.openstack.org/python-designateclient/latest
|
home-page = https://docs.openstack.org/python-tatuclient/latest
|
||||||
classifier =
|
classifier =
|
||||||
Environment :: OpenStack
|
Environment :: OpenStack
|
||||||
Intended Audience :: Information Technology
|
Intended Audience :: Information Technology
|
||||||
@ -18,7 +18,7 @@ classifier =
|
|||||||
Programming Language :: Python :: 2.7
|
Programming Language :: Python :: 2.7
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Programming Language :: Python :: 3.5
|
Programming Language :: Python :: 3.5
|
||||||
Topic :: Internet :: Name Service (DNS)
|
Topic :: Internet :: Name Service (SSH)
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
setup-hooks =
|
setup-hooks =
|
||||||
@ -26,133 +26,34 @@ setup-hooks =
|
|||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
designateclient
|
tatuclient
|
||||||
scripts =
|
scripts =
|
||||||
bin/designate
|
bin/tatu
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
designateclient.v1.controllers =
|
tatuclient.versions =
|
||||||
reports = designateclient.v1.reports:ReportsController
|
2 = tatuclient.v2.client:Client
|
||||||
diagnostics = designateclient.v1.diagnostics:DiagnosticsController
|
|
||||||
domains = designateclient.v1.domains:DomainsController
|
|
||||||
records = designateclient.v1.records:RecordsController
|
|
||||||
servers = designateclient.v1.servers:ServersController
|
|
||||||
quotas = designateclient.v1.quotas:QuotasController
|
|
||||||
sync = designateclient.v1.sync:SyncController
|
|
||||||
touch = designateclient.v1.touch:TouchController
|
|
||||||
|
|
||||||
designateclient.cli =
|
|
||||||
domain-list = designateclient.cli.domains:ListDomainsCommand
|
|
||||||
domain-get = designateclient.cli.domains:GetDomainCommand
|
|
||||||
domain-create = designateclient.cli.domains:CreateDomainCommand
|
|
||||||
domain-update = designateclient.cli.domains:UpdateDomainCommand
|
|
||||||
domain-delete = designateclient.cli.domains:DeleteDomainCommand
|
|
||||||
domain-servers-list = designateclient.cli.domains:ListDomainServersCommand
|
|
||||||
|
|
||||||
record-list = designateclient.cli.records:ListRecordsCommand
|
|
||||||
record-get = designateclient.cli.records:GetRecordCommand
|
|
||||||
record-create = designateclient.cli.records:CreateRecordCommand
|
|
||||||
record-update = designateclient.cli.records:UpdateRecordCommand
|
|
||||||
record-delete = designateclient.cli.records:DeleteRecordCommand
|
|
||||||
|
|
||||||
server-list = designateclient.cli.servers:ListServersCommand
|
|
||||||
server-get = designateclient.cli.servers:GetServerCommand
|
|
||||||
server-create = designateclient.cli.servers:CreateServerCommand
|
|
||||||
server-update = designateclient.cli.servers:UpdateServerCommand
|
|
||||||
server-delete = designateclient.cli.servers:DeleteServerCommand
|
|
||||||
|
|
||||||
diagnostics-ping = designateclient.cli.diagnostics:PingCommand
|
|
||||||
|
|
||||||
sync-all = designateclient.cli.sync:SyncAllCommand
|
|
||||||
sync-domain = designateclient.cli.sync:SyncDomainCommand
|
|
||||||
sync-record = designateclient.cli.sync:SyncRecordCommand
|
|
||||||
|
|
||||||
touch-domain = designateclient.cli.touch:TouchDomainCommand
|
|
||||||
|
|
||||||
report-count-all = designateclient.cli.reports:CountsCommand
|
|
||||||
report-count-domains = designateclient.cli.reports:DomainCountCommand
|
|
||||||
report-count-records = designateclient.cli.reports:RecordCountCommand
|
|
||||||
report-count-tenants = designateclient.cli.reports:TenantCountCommand
|
|
||||||
report-tenants-all = designateclient.cli.reports:TenantsCommand
|
|
||||||
report-tenant-domains = designateclient.cli.reports:TenantCommand
|
|
||||||
|
|
||||||
quota-get = designateclient.cli.quotas:GetQuotaCommand
|
|
||||||
quota-update = designateclient.cli.quotas:UpdateQuotaCommand
|
|
||||||
quota-reset = designateclient.cli.quotas:ResetQuotaCommand
|
|
||||||
|
|
||||||
designateclient.versions =
|
|
||||||
1 = designateclient.v1:Client
|
|
||||||
2 = designateclient.v2.client:Client
|
|
||||||
|
|
||||||
openstack.cli.extension =
|
openstack.cli.extension =
|
||||||
dns = designateclient.osc.plugin
|
ssh = tatuclient.osc.plugin
|
||||||
|
|
||||||
openstack.dns.v2 =
|
openstack.ssh.v2 =
|
||||||
zone_blacklist_create = designateclient.v2.cli.blacklists:CreateBlacklistCommand
|
usercert_create = tatuclient.v2.cli.usercert:CreateUserCertCommand
|
||||||
zone_blacklist_list = designateclient.v2.cli.blacklists:ListBlacklistsCommand
|
usercert_list = tatuclient.v2.cli.usercert:ListUserCertsCommand
|
||||||
zone_blacklist_show = designateclient.v2.cli.blacklists:ShowBlacklistCommand
|
usercert_show = tatuclient.v2.cli.usercert:ShowUserCertCommand
|
||||||
zone_blacklist_set = designateclient.v2.cli.blacklists:SetBlacklistCommand
|
usercert_revoke = tatuclient.v2.cli.usercert:RevokeUserCertCommand
|
||||||
zone_blacklist_delete = designateclient.v2.cli.blacklists:DeleteBlacklistCommand
|
usercert_delete = tatuclient.v2.cli.usercert:DeleteUserCertCommand
|
||||||
|
|
||||||
tld_create = designateclient.v2.cli.tlds:CreateTLDCommand
|
hostcert_create = tatuclient.v2.cli.hostcert:CreateHostCertCommand
|
||||||
tld_list = designateclient.v2.cli.tlds:ListTLDsCommand
|
hostcert_list = tatuclient.v2.cli.hostcert:ListHostCertsCommand
|
||||||
tld_show = designateclient.v2.cli.tlds:ShowTLDCommand
|
hostcert_show = tatuclient.v2.cli.hostcert:ShowHostCertCommand
|
||||||
tld_set = designateclient.v2.cli.tlds:SetTLDCommand
|
hostcert_revoke = tatuclient.v2.cli.hostcert:RevokeHostCertCommand
|
||||||
tld_delete = designateclient.v2.cli.tlds:DeleteTLDCommand
|
hostcert_delete = tatuclient.v2.cli.hostcert:DeleteHostCertCommand
|
||||||
|
|
||||||
zone_create = designateclient.v2.cli.zones:CreateZoneCommand
|
|
||||||
zone_list = designateclient.v2.cli.zones:ListZonesCommand
|
|
||||||
zone_show = designateclient.v2.cli.zones:ShowZoneCommand
|
|
||||||
zone_set = designateclient.v2.cli.zones:SetZoneCommand
|
|
||||||
zone_delete = designateclient.v2.cli.zones:DeleteZoneCommand
|
|
||||||
|
|
||||||
zone_abandon = designateclient.v2.cli.zones:AbandonZoneCommand
|
|
||||||
zone_axfr = designateclient.v2.cli.zones:AXFRZoneCommand
|
|
||||||
|
|
||||||
zone_export_create = designateclient.v2.cli.zones:ExportZoneCommand
|
|
||||||
zone_export_list = designateclient.v2.cli.zones:ListZoneExportsCommand
|
|
||||||
zone_export_show = designateclient.v2.cli.zones:ShowZoneExportCommand
|
|
||||||
zone_export_delete = designateclient.v2.cli.zones:DeleteZoneExportCommand
|
|
||||||
zone_export_showfile = designateclient.v2.cli.zones:ShowZoneExportFileCommand
|
|
||||||
|
|
||||||
zone_import_create = designateclient.v2.cli.zones:ImportZoneCommand
|
|
||||||
zone_import_list = designateclient.v2.cli.zones:ListZoneImportsCommand
|
|
||||||
zone_import_show = designateclient.v2.cli.zones:ShowZoneImportCommand
|
|
||||||
zone_import_delete = designateclient.v2.cli.zones:DeleteZoneImportCommand
|
|
||||||
|
|
||||||
zone_transfer_request_create = designateclient.v2.cli.zones:CreateTransferRequestCommand
|
|
||||||
zone_transfer_request_list = designateclient.v2.cli.zones:ListTransferRequestsCommand
|
|
||||||
zone_transfer_request_show = designateclient.v2.cli.zones:ShowTransferRequestCommand
|
|
||||||
zone_transfer_request_set = designateclient.v2.cli.zones:SetTransferRequestCommand
|
|
||||||
zone_transfer_request_delete = designateclient.v2.cli.zones:DeleteTransferRequestCommand
|
|
||||||
zone_transfer_accept_request = designateclient.v2.cli.zones:AcceptTransferRequestCommand
|
|
||||||
zone_transfer_accept_list = designateclient.v2.cli.zones:ListTransferAcceptsCommand
|
|
||||||
zone_transfer_accept_show = designateclient.v2.cli.zones:ShowTransferAcceptCommand
|
|
||||||
|
|
||||||
recordset_create = designateclient.v2.cli.recordsets:CreateRecordSetCommand
|
|
||||||
recordset_list = designateclient.v2.cli.recordsets:ListRecordSetsCommand
|
|
||||||
recordset_show = designateclient.v2.cli.recordsets:ShowRecordSetCommand
|
|
||||||
recordset_set = designateclient.v2.cli.recordsets:SetRecordSetCommand
|
|
||||||
recordset_delete = designateclient.v2.cli.recordsets:DeleteRecordSetCommand
|
|
||||||
|
|
||||||
ptr_record_list = designateclient.v2.cli.reverse:ListFloatingIPCommand
|
|
||||||
ptr_record_show = designateclient.v2.cli.reverse:ShowFloatingIPCommand
|
|
||||||
ptr_record_set = designateclient.v2.cli.reverse:SetFloatingIPCommand
|
|
||||||
ptr_record_unset = designateclient.v2.cli.reverse:UnsetFloatingIPCommand
|
|
||||||
|
|
||||||
dns_service_list = designateclient.v2.cli.service_statuses:ListServiceStatusesCommand
|
|
||||||
dns_service_show = designateclient.v2.cli.service_statuses:ShowServiceStatusCommand
|
|
||||||
|
|
||||||
dns_quota_list = designateclient.v2.cli.quotas:ListQuotasCommand
|
|
||||||
dns_quota_set = designateclient.v2.cli.quotas:SetQuotasCommand
|
|
||||||
dns_quota_reset = designateclient.v2.cli.quotas:ResetQuotasCommand
|
|
||||||
|
|
||||||
tsigkey_create = designateclient.v2.cli.tsigkeys:CreateTSIGKeyCommand
|
|
||||||
tsigkey_list = designateclient.v2.cli.tsigkeys:ListTSIGKeysCommand
|
|
||||||
tsigkey_show = designateclient.v2.cli.tsigkeys:ShowTSIGKeyCommand
|
|
||||||
tsigkey_set = designateclient.v2.cli.tsigkeys:SetTSIGKeyCommand
|
|
||||||
tsigkey_delete = designateclient.v2.cli.tsigkeys:DeleteTSIGKeyCommand
|
|
||||||
|
|
||||||
|
sshca_create = tatuclient.v2.cli.ca:CreateCACommand
|
||||||
|
sshca_list = tatuclient.v2.cli.ca:ListCAsCommand
|
||||||
|
sshca_show = tatuclient.v2.cli.ca:ShowCACommand
|
||||||
|
sshca_delete = tatuclient.v2.cli.ca:DeleteCACommand
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
builders = html,man
|
builders = html,man
|
||||||
@ -167,18 +68,18 @@ tag_date = 0
|
|||||||
tag_svn_revision = 0
|
tag_svn_revision = 0
|
||||||
|
|
||||||
[compile_catalog]
|
[compile_catalog]
|
||||||
directory = designateclient/locale
|
directory = tatuclient/locale
|
||||||
domain = designateclient
|
domain = tatuclient
|
||||||
|
|
||||||
[update_catalog]
|
[update_catalog]
|
||||||
domain = designateclient
|
domain = tatuclient
|
||||||
output_dir = designateclient/locale
|
output_dir = tatuclient/locale
|
||||||
input_file = designateclient/locale/designateclient.pot
|
input_file = tatuclient/locale/tatuclient.pot
|
||||||
|
|
||||||
[extract_messages]
|
[extract_messages]
|
||||||
keywords = _ gettext ngettext l_ lazy_gettext
|
keywords = _ gettext ngettext l_ lazy_gettext
|
||||||
mapping_file = babel.cfg
|
mapping_file = babel.cfg
|
||||||
output_file = designateclient/locale/designateclient.pot
|
output_file = tatuclient/locale/tatuclient.pot
|
||||||
|
|
||||||
[wheel]
|
[wheel]
|
||||||
universal = 1
|
universal = 1
|
||||||
@ -187,5 +88,5 @@ universal = 1
|
|||||||
autodoc_index_modules = True
|
autodoc_index_modules = True
|
||||||
api_doc_dir = reference/api
|
api_doc_dir = reference/api
|
||||||
autodoc_exclude_modules =
|
autodoc_exclude_modules =
|
||||||
designateclient.tests.*
|
tatuclient.tests.*
|
||||||
designateclient.functionaltests.*
|
tatuclient.functionaltests.*
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from designateclient import version
|
from tatuclient import version
|
||||||
|
|
||||||
|
|
||||||
__version__ = version.version_info.version_string()
|
__version__ = version.version_info.version_string()
|
@ -20,7 +20,7 @@ import six
|
|||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
@ -122,7 +122,7 @@ class CrudController(Controller):
|
|||||||
|
|
||||||
|
|
||||||
def get_versions():
|
def get_versions():
|
||||||
mgr = extension.ExtensionManager('designateclient.versions')
|
mgr = extension.ExtensionManager('tatuclient.versions')
|
||||||
return dict([(ep.name, ep.plugin) for ep in mgr.extensions])
|
return dict([(ep.name, ep.plugin) for ep in mgr.extensions])
|
||||||
|
|
||||||
|
|
@ -16,8 +16,8 @@ limitations under the License.
|
|||||||
from tempest.lib.cli import base
|
from tempest.lib.cli import base
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests import client
|
from tatuclient.functionaltests import client
|
||||||
from designateclient.functionaltests import config
|
from tatuclient.functionaltests import config
|
||||||
|
|
||||||
|
|
||||||
class BaseDesignateTest(base.ClientTestBase):
|
class BaseDesignateTest(base.ClientTestBase):
|
@ -18,9 +18,9 @@ import os
|
|||||||
|
|
||||||
from tempest.lib.cli import base
|
from tempest.lib.cli import base
|
||||||
|
|
||||||
from designateclient.functionaltests.config import cfg
|
from tatuclient.functionaltests.config import cfg
|
||||||
from designateclient.functionaltests.models import FieldValueModel
|
from tatuclient.functionaltests.models import FieldValueModel
|
||||||
from designateclient.functionaltests.models import ListModel
|
from tatuclient.functionaltests.models import ListModel
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
@ -23,7 +23,7 @@ cfg.CONF.register_group(cfg.OptGroup(
|
|||||||
))
|
))
|
||||||
|
|
||||||
cfg.CONF.register_group(cfg.OptGroup(
|
cfg.CONF.register_group(cfg.OptGroup(
|
||||||
name='designateclient', title="Configuration for the Designate client"
|
name='tatuclient', title="Configuration for the Designate client"
|
||||||
))
|
))
|
||||||
|
|
||||||
cfg.CONF.register_opts([
|
cfg.CONF.register_opts([
|
||||||
@ -57,7 +57,7 @@ cfg.CONF.register_opts([
|
|||||||
cfg.CONF.register_opts([
|
cfg.CONF.register_opts([
|
||||||
cfg.StrOpt('directory',
|
cfg.StrOpt('directory',
|
||||||
help='the directory containing the client executable'),
|
help='the directory containing the client executable'),
|
||||||
], group='designateclient')
|
], group='tatuclient')
|
||||||
|
|
||||||
|
|
||||||
def find_config_file():
|
def find_config_file():
|
@ -23,7 +23,7 @@ import fixtures
|
|||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
from testtools.runtest import MultipleExceptions
|
from testtools.runtest import MultipleExceptions
|
||||||
|
|
||||||
from designateclient.functionaltests.client import DesignateCLI
|
from tatuclient.functionaltests.client import DesignateCLI
|
||||||
|
|
||||||
|
|
||||||
class BaseFixture(fixtures.Fixture):
|
class BaseFixture(fixtures.Fixture):
|
@ -15,9 +15,9 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_blacklist
|
from tatuclient.functionaltests.datagen import random_blacklist
|
||||||
from designateclient.functionaltests.v2.fixtures import BlacklistFixture
|
from tatuclient.functionaltests.v2.fixtures import BlacklistFixture
|
||||||
|
|
||||||
|
|
||||||
class TestBlacklist(BaseDesignateTest):
|
class TestBlacklist(BaseDesignateTest):
|
@ -15,11 +15,11 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_a_recordset_name
|
from tatuclient.functionaltests.datagen import random_a_recordset_name
|
||||||
from designateclient.functionaltests.datagen import random_zone_name
|
from tatuclient.functionaltests.datagen import random_zone_name
|
||||||
from designateclient.functionaltests.v2.fixtures import RecordsetFixture
|
from tatuclient.functionaltests.v2.fixtures import RecordsetFixture
|
||||||
from designateclient.functionaltests.v2.fixtures import ZoneFixture
|
from tatuclient.functionaltests.v2.fixtures import ZoneFixture
|
||||||
|
|
||||||
|
|
||||||
class TestRecordset(BaseDesignateTest):
|
class TestRecordset(BaseDesignateTest):
|
@ -15,9 +15,9 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_tld
|
from tatuclient.functionaltests.datagen import random_tld
|
||||||
from designateclient.functionaltests.v2.fixtures import TLDFixture
|
from tatuclient.functionaltests.v2.fixtures import TLDFixture
|
||||||
|
|
||||||
|
|
||||||
class TestTld(BaseDesignateTest):
|
class TestTld(BaseDesignateTest):
|
@ -15,12 +15,12 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_tsigkey_name
|
from tatuclient.functionaltests.datagen import random_tsigkey_name
|
||||||
from designateclient.functionaltests.datagen import random_tsigkey_secret
|
from tatuclient.functionaltests.datagen import random_tsigkey_secret
|
||||||
from designateclient.functionaltests.datagen import random_zone_name
|
from tatuclient.functionaltests.datagen import random_zone_name
|
||||||
from designateclient.functionaltests.v2.fixtures import TSIGKeyFixture
|
from tatuclient.functionaltests.v2.fixtures import TSIGKeyFixture
|
||||||
from designateclient.functionaltests.v2.fixtures import ZoneFixture
|
from tatuclient.functionaltests.v2.fixtures import ZoneFixture
|
||||||
|
|
||||||
|
|
||||||
class TestTSIGKey(BaseDesignateTest):
|
class TestTSIGKey(BaseDesignateTest):
|
@ -15,9 +15,9 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_zone_name
|
from tatuclient.functionaltests.datagen import random_zone_name
|
||||||
from designateclient.functionaltests.v2.fixtures import ZoneFixture
|
from tatuclient.functionaltests.v2.fixtures import ZoneFixture
|
||||||
|
|
||||||
|
|
||||||
class TestZone(BaseDesignateTest):
|
class TestZone(BaseDesignateTest):
|
@ -15,10 +15,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_zone_name
|
from tatuclient.functionaltests.datagen import random_zone_name
|
||||||
from designateclient.functionaltests.v2.fixtures import ExportFixture
|
from tatuclient.functionaltests.v2.fixtures import ExportFixture
|
||||||
from designateclient.functionaltests.v2.fixtures import ZoneFixture
|
from tatuclient.functionaltests.v2.fixtures import ZoneFixture
|
||||||
|
|
||||||
|
|
||||||
class TestZoneExport(BaseDesignateTest):
|
class TestZoneExport(BaseDesignateTest):
|
@ -15,9 +15,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.datagen import random_zone_file
|
from tatuclient.functionaltests.datagen import random_zone_file
|
||||||
from designateclient.functionaltests.v2.fixtures import ImportFixture
|
from tatuclient.functionaltests.v2.fixtures import ImportFixture
|
||||||
|
|
||||||
|
|
||||||
class TestZoneImport(BaseDesignateTest):
|
class TestZoneImport(BaseDesignateTest):
|
@ -17,11 +17,11 @@ import unittest
|
|||||||
|
|
||||||
from tempest.lib.exceptions import CommandFailed
|
from tempest.lib.exceptions import CommandFailed
|
||||||
|
|
||||||
from designateclient.functionaltests.base import BaseDesignateTest
|
from tatuclient.functionaltests.base import BaseDesignateTest
|
||||||
from designateclient.functionaltests.client import DesignateCLI
|
from tatuclient.functionaltests.client import DesignateCLI
|
||||||
from designateclient.functionaltests.datagen import random_zone_name
|
from tatuclient.functionaltests.datagen import random_zone_name
|
||||||
from designateclient.functionaltests.v2.fixtures import TransferRequestFixture
|
from tatuclient.functionaltests.v2.fixtures import TransferRequestFixture
|
||||||
from designateclient.functionaltests.v2.fixtures import ZoneFixture
|
from tatuclient.functionaltests.v2.fixtures import ZoneFixture
|
||||||
|
|
||||||
|
|
||||||
class TestZoneTransferRequest(BaseDesignateTest):
|
class TestZoneTransferRequest(BaseDesignateTest):
|
@ -14,19 +14,19 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""OpenStackClient plugin for DNS service."""
|
"""OpenStackClient plugin for SSH service."""
|
||||||
|
|
||||||
from osc_lib import utils as oscutils
|
from osc_lib import utils as oscutils
|
||||||
|
|
||||||
from designateclient import shell
|
from tatuclient import shell
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_API_VERSION = '2'
|
DEFAULT_API_VERSION = '2'
|
||||||
|
|
||||||
API_NAME = 'dns'
|
API_NAME = 'ssh'
|
||||||
API_VERSION_OPTION = 'os_dns_api_version'
|
API_VERSION_OPTION = 'os_ssh_api_version'
|
||||||
API_VERSIONS = {
|
API_VERSIONS = {
|
||||||
'2': 'designateclient.v2.client.Client',
|
'1': 'tatuclient.v2.client.Client',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -43,11 +43,11 @@ def make_client(instance):
|
|||||||
def build_option_parser(parser):
|
def build_option_parser(parser):
|
||||||
"""Hook to add global options."""
|
"""Hook to add global options."""
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-dns-api-version',
|
'--os-ssh-api-version',
|
||||||
metavar='<dns-api-version>',
|
metavar='<ssh-api-version>',
|
||||||
default=shell.env('OS_DNS_API_VERSION', default="2"),
|
default=shell.env('OS_SSH_API_VERSION', default="1"),
|
||||||
help='DNS API version, default=' +
|
help='SSH API version, default=' +
|
||||||
DEFAULT_API_VERSION +
|
DEFAULT_API_VERSION +
|
||||||
' (Env: OS_DNS_API_VERSION)')
|
' (Env: OS_SSH_API_VERSION)')
|
||||||
|
|
||||||
return parser
|
return parser
|
@ -21,8 +21,8 @@ import traceback
|
|||||||
from cliff.app import App
|
from cliff.app import App
|
||||||
from cliff.commandmanager import CommandManager
|
from cliff.commandmanager import CommandManager
|
||||||
|
|
||||||
from designateclient import utils
|
from tatuclient import utils
|
||||||
from designateclient.version import version_info as version
|
from tatuclient.version import version_info as version
|
||||||
|
|
||||||
|
|
||||||
def env(*vars, **kwargs):
|
def env(*vars, **kwargs):
|
||||||
@ -47,7 +47,7 @@ class DesignateShell(App):
|
|||||||
super(DesignateShell, self).__init__(
|
super(DesignateShell, self).__init__(
|
||||||
description='Designate Client',
|
description='Designate Client',
|
||||||
version=version.version_string(),
|
version=version.version_string(),
|
||||||
command_manager=CommandManager('designateclient.cli'),
|
command_manager=CommandManager('tatuclient.cli'),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log = logging.getLogger(__name__)
|
self.log = logging.getLogger(__name__)
|
@ -22,8 +22,8 @@ from requests_mock.contrib import fixture as req_fixture
|
|||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from designateclient import client
|
from tatuclient import client
|
||||||
from designateclient.utils import AdapterWithTimeout
|
from tatuclient.utils import AdapterWithTimeout
|
||||||
|
|
||||||
_TRUE_VALUES = ('True', 'true', '1', 'yes')
|
_TRUE_VALUES = ('True', 'true', '1', 'yes')
|
||||||
|
|
@ -14,14 +14,14 @@
|
|||||||
test_designateclient
|
test_designateclient
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
Tests for `designateclient` module.
|
Tests for `tatuclient` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import designateclient
|
import tatuclient
|
||||||
from designateclient.tests import base
|
from tatuclient.tests import base
|
||||||
|
|
||||||
|
|
||||||
class ClientTestCase(base.TestCase):
|
class ClientTestCase(base.TestCase):
|
||||||
|
|
||||||
def test_module_version(self):
|
def test_module_version(self):
|
||||||
self.assertTrue(hasattr(designateclient, '__version__'))
|
self.assertTrue(hasattr(tatuclient, '__version__'))
|
@ -14,8 +14,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient.tests import base
|
from tatuclient.tests import base
|
||||||
|
|
||||||
|
|
||||||
class RemoteErrorTestCase(base.TestCase):
|
class RemoteErrorTestCase(base.TestCase):
|
@ -16,9 +16,9 @@ import uuid
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient.tests import base
|
from tatuclient.tests import base
|
||||||
from designateclient import utils
|
from tatuclient import utils
|
||||||
|
|
||||||
|
|
||||||
LIST_MOCK_RESPONSE = [
|
LIST_MOCK_RESPONSE = [
|
@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.tests import base
|
from tatuclient.tests import base
|
||||||
|
|
||||||
|
|
||||||
class CrudMixin(object):
|
class CrudMixin(object):
|
@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
|
|
||||||
class TestBlacklists(v2.APIV2TestCase, v2.CrudMixin):
|
class TestBlacklists(v2.APIV2TestCase, v2.CrudMixin):
|
@ -17,8 +17,8 @@
|
|||||||
from keystoneauth1 import adapter
|
from keystoneauth1 import adapter
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
|
|
||||||
from designateclient.tests.base import TestCase
|
from tatuclient.tests.base import TestCase
|
||||||
from designateclient.v2.client import Client
|
from tatuclient.v2.client import Client
|
||||||
|
|
||||||
|
|
||||||
class TestClient(TestCase):
|
class TestClient(TestCase):
|
@ -13,7 +13,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
|
|
||||||
class TestLimits(v2.APIV2TestCase, v2.CrudMixin):
|
class TestLimits(v2.APIV2TestCase, v2.CrudMixin):
|
@ -15,8 +15,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
from designateclient.v2 import zones
|
from tatuclient.v2 import zones
|
||||||
|
|
||||||
|
|
||||||
class TestLimits(v2.APIV2TestCase, v2.CrudMixin):
|
class TestLimits(v2.APIV2TestCase, v2.CrudMixin):
|
@ -18,9 +18,9 @@ import uuid
|
|||||||
from mock import patch
|
from mock import patch
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
from designateclient.v2 import zones
|
from tatuclient.v2 import zones
|
||||||
|
|
||||||
ZONE = {
|
ZONE = {
|
||||||
"id": str(uuid.uuid4()),
|
"id": str(uuid.uuid4()),
|
@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
FIP_ID = '%s:%s' % (str(uuid.uuid4()), "RegionOne")
|
FIP_ID = '%s:%s' % (str(uuid.uuid4()), "RegionOne")
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
|
|
||||||
class TestServiceStatuses(v2.APIV2TestCase, v2.CrudMixin):
|
class TestServiceStatuses(v2.APIV2TestCase, v2.CrudMixin):
|
@ -18,8 +18,8 @@ from keystoneauth1.identity import generic
|
|||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
from designateclient.v2.client import Client
|
from tatuclient.v2.client import Client
|
||||||
|
|
||||||
|
|
||||||
def create_session(timeout=None):
|
def create_session(timeout=None):
|
@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
|
|
||||||
class TestTlds(v2.APIV2TestCase, v2.CrudMixin):
|
class TestTlds(v2.APIV2TestCase, v2.CrudMixin):
|
@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
|
|
||||||
class TestTSIGKeys(v2.APIV2TestCase, v2.CrudMixin):
|
class TestTSIGKeys(v2.APIV2TestCase, v2.CrudMixin):
|
@ -16,7 +16,7 @@
|
|||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from designateclient.tests import v2
|
from tatuclient.tests import v2
|
||||||
|
|
||||||
|
|
||||||
class TestZones(v2.APIV2TestCase, v2.CrudMixin):
|
class TestZones(v2.APIV2TestCase, v2.CrudMixin):
|
@ -26,7 +26,7 @@ from keystoneauth1 import token_endpoint
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from designateclient import exceptions
|
from tatuclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
def resource_string(*args, **kwargs):
|
def resource_string(*args, **kwargs):
|
||||||
@ -36,7 +36,7 @@ def resource_string(*args, **kwargs):
|
|||||||
package = kwargs.pop('package', None)
|
package = kwargs.pop('package', None)
|
||||||
|
|
||||||
if not package:
|
if not package:
|
||||||
package = 'designateclient'
|
package = 'tatuclient'
|
||||||
|
|
||||||
resource_path = os.path.join('resources', *args)
|
resource_path = os.path.join('resources', *args)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user