7d2d13ff4d
climate lease-create was not available, albeit we need it for the physical reservation usecase. Adding it, e.g. climate lease-create --physical-reservation min=1,max=5,\ hypervisor_properties='["=", "$hypervisor_type", "QEMU"]',\ resource_properties="" test_phys Partially implements blueprint python-client Change-Id: Ia836846c3d25a3dd3ccd3308d40f165253df059d
79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
# Copyright (c) 2013 Mirantis Inc.
|
|
#
|
|
# 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 climateclient.openstack.common.gettextutils import _ # noqa
|
|
|
|
|
|
class ClimateClientException(Exception):
|
|
"""Base exception class."""
|
|
message = _("An unknown exception occurred %s.")
|
|
code = 500
|
|
|
|
def __init__(self, message=None, **kwargs):
|
|
self.kwargs = kwargs
|
|
|
|
if 'code' not in self.kwargs:
|
|
try:
|
|
self.kwargs['code'] = self.code
|
|
except AttributeError:
|
|
pass
|
|
|
|
if not message:
|
|
message = self.message % kwargs
|
|
|
|
super(ClimateClientException, self).__init__(message)
|
|
|
|
|
|
class CommandError(ClimateClientException):
|
|
"""Occurs if not all authentication vital options are set."""
|
|
message = _("You have to provide all options like user name or tenant "
|
|
"id to make authentication possible.")
|
|
code = 401
|
|
|
|
|
|
class NotAuthorized(ClimateClientException):
|
|
"""HTTP 401 - Not authorized.
|
|
|
|
User have no enough rights to perform action.
|
|
"""
|
|
code = 401
|
|
message = _("Not authorized request.")
|
|
|
|
|
|
class NoClimateEndpoint(ClimateClientException):
|
|
"""Occurs if no endpoint for Climate set in the Keystone."""
|
|
message = _("No publicURL endpoint for Climate found. Set endpoint "
|
|
"for Climate in the Keystone.")
|
|
code = 404
|
|
|
|
|
|
class NoUniqueMatch(ClimateClientException):
|
|
"""Occurs if there are more than one appropriate resources."""
|
|
message = _("There is no unique requested resource.")
|
|
code = 409
|
|
|
|
|
|
class UnsupportedVersion(ClimateClientException):
|
|
"""Occurs if unsupported client version was requested."""
|
|
message = _("Unsupported client version requested.")
|
|
code = 406
|
|
|
|
|
|
class IncorrectLease(ClimateClientException):
|
|
"""Occurs if lease parameters are incorrect."""
|
|
message = _("The lease parameters are incorrect.")
|
|
code = 409
|