Completed
Pull Request — master (#487)
by
unknown
02:56
created

OrionNode.npm()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
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