summaryrefslogtreecommitdiffstats
path: root/src/ceph-volume/ceph_volume/exceptions.py
blob: 5c6429483f8a9f09d10adbc772620ab89316142b (plain)
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
import os


class ConfigurationError(Exception):

    def __init__(self, cluster_name='ceph', path='/etc/ceph', abspath=None):
        self.cluster_name = cluster_name
        self.path = path
        self.abspath = abspath or "%s.conf" % os.path.join(self.path, self.cluster_name)

    def __str__(self):
        return 'Unable to load expected Ceph config at: %s' % self.abspath


class ConfigurationSectionError(Exception):

    def __init__(self, section):
        self.section = section

    def __str__(self):
        return 'Unable to find expected configuration section: "%s"' % self.section


class ConfigurationKeyError(Exception):

    def __init__(self, section, key):
        self.section = section
        self.key = key

    def __str__(self):
        return 'Unable to find expected configuration key: "%s" from section "%s"' % (
            self.key,
            self.section
        )


class SuffixParsingError(Exception):

    def __init__(self, suffix, part=None):
        self.suffix = suffix
        self.part = part

    def __str__(self):
        return 'Unable to parse the %s from systemd suffix: %s' % (self.part, self.suffix)


class SuperUserError(Exception):

    def __str__(self):
        return 'This command needs to be executed with sudo or as root'


class SizeAllocationError(Exception):

    def __init__(self, requested, available):
        self.requested = requested
        self.available = available

    def __str__(self):
        msg = 'Unable to allocate size (%s), not enough free space (%s)' % (
            self.requested, self.available
        )
        return msg