Remove non-functional contrib code
- Remove code that no longer works. - Minor tweaks to existing contrib content. Change-Id: I0c7b70bde214da71e1bf3935f1e5f33107410c96
This commit is contained in:
parent
4ed635f620
commit
360433b38b
|
@ -1,2 +1,2 @@
|
||||||
pbr>=0.6,<1.0
|
pbr
|
||||||
-e git+https://github.com/openstack/designate.git#egg=designate
|
-e git+https://github.com/openstack/designate.git#egg=designate
|
||||||
|
|
|
@ -11,10 +11,6 @@ classifier =
|
||||||
Intended Audience :: System Administrators
|
Intended Audience :: System Administrators
|
||||||
License :: OSI Approved :: Apache Software License
|
License :: OSI Approved :: Apache Software License
|
||||||
Operating System :: POSIX :: Linux
|
Operating System :: POSIX :: Linux
|
||||||
Programming Language :: Python
|
|
||||||
Programming Language :: Python :: 2
|
|
||||||
Programming Language :: Python :: 2.7
|
|
||||||
Programming Language :: Python :: 2.6
|
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
setup-hooks =
|
setup-hooks =
|
||||||
|
|
|
@ -1,127 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# Copyright (C) 2018 Verizon
|
|
||||||
#
|
|
||||||
# Author: Graham Hayes <gr@ham.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 argparse
|
|
||||||
import ipaddress
|
|
||||||
import logging
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import dns.exception
|
|
||||||
from dns.ipv4 import inet_aton
|
|
||||||
from keystoneauth1.identity import generic
|
|
||||||
from keystoneauth1 import session as keystone_session
|
|
||||||
|
|
||||||
from designateclient import shell
|
|
||||||
from designateclient.v2 import client
|
|
||||||
|
|
||||||
|
|
||||||
auth = generic.Password(
|
|
||||||
auth_url=shell.env('OS_AUTH_URL'),
|
|
||||||
username=shell.env('OS_USERNAME'),
|
|
||||||
password=shell.env('OS_PASSWORD'),
|
|
||||||
project_name=shell.env('OS_PROJECT_NAME'),
|
|
||||||
project_domain_id=shell.env('OS_PROJECT_DOMAIN_ID'),
|
|
||||||
user_domain_id=shell.env('OS_USER_DOMAIN_ID'))
|
|
||||||
|
|
||||||
session = keystone_session.Session(auth=auth)
|
|
||||||
|
|
||||||
client = client.Client(session=session)
|
|
||||||
|
|
||||||
logging.basicConfig()
|
|
||||||
LOG = logging.getLogger('fixleadingzeros')
|
|
||||||
|
|
||||||
|
|
||||||
def find_bad_recordsets():
|
|
||||||
bad_recordsets = {}
|
|
||||||
LOG.debug("Looking for all A recordsets")
|
|
||||||
recordsets = client.recordsets.list_all_zones(criterion={'type': 'A', })
|
|
||||||
LOG.debug("Found %d A recordsets", len(recordsets))
|
|
||||||
LOG.debug("Filtering recordsets")
|
|
||||||
for recordset in recordsets:
|
|
||||||
for record in recordset['records']:
|
|
||||||
try:
|
|
||||||
inet_aton(record)
|
|
||||||
except dns.exception.SyntaxError:
|
|
||||||
bad_recordsets[recordset['id']] = recordset
|
|
||||||
LOG.debug("Found %d A invaild recordsets", len(bad_recordsets))
|
|
||||||
return bad_recordsets
|
|
||||||
|
|
||||||
|
|
||||||
def show_recordsets(recordsets):
|
|
||||||
for rs in recordsets:
|
|
||||||
LOG.info(
|
|
||||||
("%(name)s - %(records)s - Zone ID: %(zone_id)s - "
|
|
||||||
"Project ID: %(project_id)s ") % recordsets[rs])
|
|
||||||
|
|
||||||
|
|
||||||
def fix_bad_recordsets(bad_recordsets):
|
|
||||||
LOG.debug("Removing leading zeros in IPv4 addresses")
|
|
||||||
for rs in bad_recordsets:
|
|
||||||
new_records = []
|
|
||||||
for ip in bad_recordsets[rs]['records']:
|
|
||||||
ip = '.'.join(f'{int(i)}' for i in ip.split('.'))
|
|
||||||
new_records.append(
|
|
||||||
str(ipaddress.IPv4Address(ip))
|
|
||||||
)
|
|
||||||
bad_recordsets[rs]['records'] = new_records
|
|
||||||
return bad_recordsets
|
|
||||||
|
|
||||||
|
|
||||||
def update_recordsets(recordsets):
|
|
||||||
LOG.info("Updating recordsets")
|
|
||||||
for rs in recordsets:
|
|
||||||
LOG.debug(("Updating %(name)s - %(records)s - Zone ID: %(zone_id)s - "
|
|
||||||
"Project ID: %(project_id)s ") % recordsets[rs])
|
|
||||||
client.recordsets.update(
|
|
||||||
recordsets[rs]['zone_id'],
|
|
||||||
recordsets[rs]['id'],
|
|
||||||
{'records': recordsets[rs]['records']}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description='Fix any recordsets that have leading zeros in A records')
|
|
||||||
parser.add_argument('-v', '--verbose', action='store_true',
|
|
||||||
help='verbose output')
|
|
||||||
parser.add_argument('-d', '--dry-run', action='store_true',
|
|
||||||
help='do not modify records, just log bad records')
|
|
||||||
parser.add_argument('-a', '--all-projects', action='store_true',
|
|
||||||
help="Run on all projects")
|
|
||||||
args = parser.parse_args()
|
|
||||||
if args.verbose:
|
|
||||||
LOG.setLevel(logging.DEBUG)
|
|
||||||
else:
|
|
||||||
LOG.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
if args.all_projects:
|
|
||||||
client.session.all_projects = True
|
|
||||||
|
|
||||||
bad_recordsets = find_bad_recordsets()
|
|
||||||
|
|
||||||
LOG.info("Bad recordsets")
|
|
||||||
show_recordsets(bad_recordsets)
|
|
||||||
|
|
||||||
fixed_recordsets = fix_bad_recordsets(bad_recordsets)
|
|
||||||
LOG.info("Fixed recordsets")
|
|
||||||
show_recordsets(fixed_recordsets)
|
|
||||||
|
|
||||||
if not args.dry_run:
|
|
||||||
update_recordsets(fixed_recordsets)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.exit(main())
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,57 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# 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.
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from designateclient import v1
|
|
||||||
from oslo_config import cfg
|
|
||||||
from oslo_log import log as logging
|
|
||||||
|
|
||||||
from designate.utils import generate_uuid
|
|
||||||
|
|
||||||
|
|
||||||
cfg.CONF.register_cli_opts([
|
|
||||||
cfg.StrOpt("domain_id", help="ID of domain to use."),
|
|
||||||
cfg.IntOpt("records", default=100,
|
|
||||||
help="Records to create (name will be <uuid>.<domain name>.")
|
|
||||||
])
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
logging.register_options(cfg.CONF)
|
|
||||||
cfg.CONF(sys.argv[1:], project="designate")
|
|
||||||
logging.setup(cfg.CONF, "designate")
|
|
||||||
|
|
||||||
project_name = os.environ.get(
|
|
||||||
'OS_PROJECT_NAME', os.environ.get('OS_TENANT_NAME'))
|
|
||||||
|
|
||||||
client = v1.Client(
|
|
||||||
auth_url=os.environ.get('OS_AUTH_URL'),
|
|
||||||
username=os.environ.get('OS_USERNAME'),
|
|
||||||
password=os.environ.get('OS_PASSWORD'),
|
|
||||||
project_name=project_name
|
|
||||||
)
|
|
||||||
|
|
||||||
domain = client.domains.get(cfg.CONF.domain_id)
|
|
||||||
|
|
||||||
msg = "Creating %s records", cfg.CONF.records
|
|
||||||
LOG.info(msg)
|
|
||||||
for i in range(0, cfg.CONF.records):
|
|
||||||
name = '%s.%s' % (generate_uuid(), domain.name)
|
|
||||||
record = {"name": name, "type": "A", "data": "10.0.0.1"}
|
|
||||||
client.records.create(domain, record)
|
|
Loading…
Reference in New Issue