This file is indexed.

/usr/lib/python3/dist-packages/designateclient/cli/records.py is in python3-designateclient 2.9.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# 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)