Completed
Push — master ( f1a13c...e53aa3 )
by Tomaz
20s
created

OrionNode.ip_address()   A

Complexity

Conditions 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
c 3
b 0
f 0
dl 0
loc 3
rs 10
1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
15
from utils import is_ip
0 ignored issues
show
Bug introduced by
The name is_ip does not seem to exist in module utils.
Loading history...
16
17
18
class OrionNode(object):
19
    """
20
    Class for holding Orion Node details.
21
    """
22
    def __init__(self):
23
        """
24
        Setup the class
25
        """
26
        self._caption = None
27
        self._ip_address = None
28
        self._npm = False
29
        self._ncm = False
30
        self._npm_id = None
31
        self._ncm_id = None
32
        self._uri = None
33
34
    def __str__(self):
35
        return "{} (NodeId: {}; ip: {})".format(
36
            self._caption,
37
            self._npm_id,
38
            self._ip_address)
39
40
    def __repr__(self):
41
        return self.__str__
42
43
    @property
44
    def ip_address(self):
45
        return self._ip_address
46
47
    @ip_address.setter
48
    def ip_address(self, ip_address):
49
        if is_ip(ip_address):
50
            self._ip_address = ip_address
51
        else:
52
            raise ValueError("Not an IP address")
53
54
    @property
55
    def caption(self):
56
        return self._caption
57
58
    @caption.setter
59
    def caption(self, caption):
60
        self._caption = caption
61
62
    @property
63
    def npm_id(self):
64
        return self._npm_id
65
66
    @npm_id.setter
67
    def npm_id(self, npm_id):
68
        """
69
        Set self._npm_id and update self._npm to True.
70
        """
71
72
        if npm_id is not None:
73
            self._npm_id = npm_id
74
            self._npm = True
75
        else:
76
            self._npm_id = None
77
            self._npm = False
78
79
    @property
80
    def ncm_id(self):
81
        return self._ncm_id
82
83
    @ncm_id.setter
84
    def ncm_id(self, ncm_id):
85
        """
86
        Set self._ncm_id and update self._ncm to True.
87
        """
88
        if ncm_id is not None:
89
            self._ncm_id = ncm_id
90
            self._ncm = True
91
        else:
92
            self._ncm_id = None
93
            self._ncm = False
94
95
    @property
96
    def npm(self):
97
        return self._npm
98
99
    @property
100
    def ncm(self):
101
        return self._ncm
102
103
    @property
104
    def uri(self):
105
        return self._uri
106
107
    @uri.setter
108
    def uri(self, uri):
109
        self._uri = uri
110