2017-02-01 10:30:14 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016 GNS3 Technologies Inc.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-06-28 07:37:19 +00:00
|
|
|
import copy
|
2017-02-01 10:30:14 +00:00
|
|
|
import uuid
|
2018-11-17 11:12:46 +00:00
|
|
|
|
2017-04-12 12:35:49 +00:00
|
|
|
|
2017-02-01 10:30:14 +00:00
|
|
|
class Appliance:
|
|
|
|
|
2018-11-28 09:12:57 +00:00
|
|
|
def __init__(self, appliance_id, data, builtin=True):
|
2017-02-01 10:30:14 +00:00
|
|
|
if appliance_id is None:
|
|
|
|
self._id = str(uuid.uuid4())
|
2017-06-19 06:47:50 +00:00
|
|
|
elif isinstance(appliance_id, uuid.UUID):
|
|
|
|
self._id = str(appliance_id)
|
2017-02-01 10:30:14 +00:00
|
|
|
else:
|
|
|
|
self._id = appliance_id
|
2018-11-28 09:12:57 +00:00
|
|
|
self._data = data.copy()
|
2017-04-12 12:35:49 +00:00
|
|
|
self._builtin = builtin
|
2018-11-28 09:12:57 +00:00
|
|
|
if "appliance_id" in self._data:
|
|
|
|
del self._data["appliance_id"]
|
2018-11-17 11:12:46 +00:00
|
|
|
|
2017-02-01 10:30:14 +00:00
|
|
|
@property
|
|
|
|
def id(self):
|
|
|
|
return self._id
|
|
|
|
|
2017-04-12 12:35:49 +00:00
|
|
|
@property
|
2018-11-28 09:12:57 +00:00
|
|
|
def status(self):
|
|
|
|
return self._data["status"]
|
2018-11-17 11:12:46 +00:00
|
|
|
|
2019-03-11 09:55:16 +00:00
|
|
|
@property
|
|
|
|
def symbol(self):
|
|
|
|
return self._data.get("symbol")
|
|
|
|
|
2017-02-01 10:30:14 +00:00
|
|
|
def __json__(self):
|
|
|
|
"""
|
2018-11-28 09:12:57 +00:00
|
|
|
Appliance data (a hash)
|
2017-02-01 10:30:14 +00:00
|
|
|
"""
|
2018-11-28 09:12:57 +00:00
|
|
|
data = copy.deepcopy(self._data)
|
|
|
|
data["builtin"] = self._builtin
|
|
|
|
return data
|