This file is indexed.

/usr/lib/python3/dist-packages/os_win/exceptions.py is in python3-os-win 3.0.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# Copyright 2015 Cloudbase Solutions Srl
# 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.

"""
Utility class for VM related operations on Hyper-V.
"""

import sys

from os_win._i18n import _

# Define WMI specific exceptions, so WMI won't have to be imported in any
# module that expects those exceptions.
if sys.platform == 'win32':
    from six.moves.builtins import WindowsError
    import wmi

    x_wmi = wmi.x_wmi
    x_wmi_timed_out = wmi.x_wmi_timed_out
else:
    class WindowsError(Exception):
        def __init__(self, winerror=None):
            self.winerror = winerror

    class x_wmi(Exception):
        def __init__(self, info='', com_error=None):
            super(x_wmi, self).__init__(info)
            self.info = info
            self.com_error = com_error

    class x_wmi_timed_out(x_wmi):
        pass


class OSWinException(Exception):
    msg_fmt = 'An exception has been encountered.'

    def __init__(self, message=None, **kwargs):
        self.kwargs = kwargs
        self.error_code = kwargs.get('error_code')

        if not message:
            message = self.msg_fmt % kwargs

        self.message = message
        super(OSWinException, self).__init__(message)


class NotFound(OSWinException):
    msg_fmt = _("Resource could not be found: %(resource)s")


class PciDeviceNotFound(NotFound):
    msg_fmt = _("No assignable PCI device with vendor id: %(vendor_id)s and "
                "product id: %(product_id)s was found.")


class HyperVException(OSWinException):
    pass


# TODO(alexpilotti): Add a storage exception base class
class VHDResizeException(HyperVException):
    msg_fmt = _("Exception encountered while resizing the VHD %(vhd_path)s."
                "Reason: %(reason)s")


class HyperVAuthorizationException(HyperVException):
    msg_fmt = _("The Windows account running nova-compute on this Hyper-V "
                "host doesn't have the required permissions to perform "
                "Hyper-V related operations.")


class HyperVVMNotFoundException(NotFound, HyperVException):
    msg_fmt = _("VM not found: %(vm_name)s")


class HyperVPortNotFoundException(NotFound, HyperVException):
    msg_fmt = _("Switch port not found: %(port_name)s")


class HyperVvNicNotFound(NotFound, HyperVException):
    msg_fmt = _("vNic not found: %(vnic_name)s")


class HyperVvSwitchNotFound(NotFound, HyperVException):
    msg_fmt = _("vSwitch not found: %(vswitch_name)s.")


class Invalid(OSWinException):
    pass


class UnsupportedOperation(Invalid):
    msg_fmt = _("The operation failed due to the reason: %(reason)s")


class InvalidParameterValue(Invalid):
    msg_fmt = _("Invalid parameter value for: "
                "%(param_name)s=%(param_value)s")


class InvalidVMVersion(Invalid):
    msg_fmt = _("VM '%(vm_name)s' has an invalid version for this operation: "
                "%(version)s. Version is expected to be between: "
                "%(min_version)s and %(max_version)s.")


class SMBException(OSWinException):
    pass


class Win32Exception(OSWinException):
    msg_fmt = _("Executing Win32 API function %(func_name)s failed. "
                "Error code: %(error_code)s. "
                "Error message: %(error_message)s")


class VHDException(OSWinException):
    pass


class VHDWin32APIException(VHDException, Win32Exception):
    pass


class FCException(OSWinException):
    pass


class FCWin32Exception(FCException, Win32Exception):
    pass


class WMIException(OSWinException):
    def __init__(self, message=None, wmi_exc=None):
        if wmi_exc:
            try:
                wmi_exc_message = wmi_exc.com_error.excepinfo[2].strip()
                message = "%s WMI exception message: %s" % (message,
                                                            wmi_exc_message)
            except AttributeError:
                pass
            except IndexError:
                pass
        super(WMIException, self).__init__(message)


class WqlException(OSWinException):
    pass


class ISCSITargetException(OSWinException):
    pass


class ISCSITargetWMIException(ISCSITargetException, WMIException):
    pass


class ISCSIInitiatorAPIException(Win32Exception):
    pass


class ISCSILunNotAvailable(ISCSITargetException):
    msg_fmt = _("Could not find lun %(target_lun)s "
                "for iSCSI target %(target_iqn)s.")


class Win32IOException(Win32Exception):
    pass


class DiskNotFound(NotFound):
    pass


class HyperVRemoteFXException(HyperVException):
    pass


class HyperVClusterException(HyperVException):
    pass


class DNSException(OSWinException):
    pass


class Timeout(OSWinException):
    msg_fmt = _("Timed out waiting for the specified resource.")


class DNSZoneNotFound(NotFound, DNSException):
    msg_fmt = _("DNS Zone not found: %(zone_name)s")


class DNSZoneAlreadyExists(DNSException):
    msg_fmt = _("DNS Zone already exists: %(zone_name)s")


class WMIJobFailed(HyperVException):
    msg_fmt = _("WMI job failed with status %(job_state)s. "
                "Error summary description: %(error_summ_desc)s. "
                "Error description: %(error_desc)s "
                "Error code: %(error_code)s.")

    def __init__(self, message=None, **kwargs):
        self.error_code = kwargs.get('error_code', None)
        self.job_state = kwargs.get('job_state', None)

        super(WMIJobFailed, self).__init__(message, **kwargs)


class JobTerminateFailed(HyperVException):
    msg_fmt = _("Could not terminate the requested job(s).")


class ClusterException(OSWinException):
    pass


class ClusterWin32Exception(ClusterException, Win32Exception):
    pass


class ClusterGroupMigrationFailed(ClusterException):
    msg_fmt = _("Failed to migrate cluster group %(group_name)s. "
                "Expected state %(expected_state)s. "
                "Expected owner node: %(expected_node)s. "
                "Current group state: %(group_state)s. "
                "Current owner node: %(owner_node)s.")


class ClusterGroupMigrationTimeOut(ClusterGroupMigrationFailed):
    msg_fmt = _("Cluster group '%(group_name)s' migration "
                "timed out after %(time_elapsed)0.3fs. ")


class ClusterPropertyRetrieveFailed(ClusterException):
    msg_fmt = _("Failed to retrieve a cluster property.")


class ClusterPropertyListEntryNotFound(ClusterPropertyRetrieveFailed):
    msg_fmt = _("The specified cluster property list does not contain "
                "an entry named '%(property_name)s'")


class ClusterPropertyListParsingError(ClusterPropertyRetrieveFailed):
    msg_fmt = _("Parsing a cluster property list failed.")


class SCSIPageParsingError(Invalid):
    msg_fmt = _("Parsing SCSI Page %(page)s failed. "
                "Reason: %(reason)s.")


class SCSIIdDescriptorParsingError(Invalid):
    msg_fmt = _("Parsing SCSI identification descriptor failed. "
                "Reason: %(reason)s.")


class ResourceUpdateError(OSWinException):
    msg_fmt = _("Failed to update the specified resource.")


class DiskUpdateError(OSWinException):
    msg_fmt = _("Failed to update the specified disk.")