| Total Complexity | 18 |
| Total Lines | 92 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
| 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 |