2 Copyright (c) 2017 SONATA-NFV and Paderborn University
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 Neither the name of the SONATA-NFV, Paderborn University
18 nor the names of its contributors may be used to endorse or promote
19 products derived from this software without specific prior written
22 This work has been performed in the framework of the SONATA project,
23 funded by the European Commission under Grant number 671517 through
24 the Horizon 2020 and 5G-PPP programmes. The authors would like to
25 acknowledge the contributions of their colleagues of the SONATA
26 partner consortium (www.sonata-nfv.eu).
29 def __init__(self
, name
, id=None, flavor
=None, image
=None, command
=None, nw_list
=None):
32 self
.template_name
= None
35 self
.command
= command
36 self
.port_names
= list()
37 self
.properties
= dict()
39 self
.son_emu_command
= None
40 self
.emulator_compute
= None
42 def compare_attributes(self
, other
):
44 Compares only class attributes like name and flavor but not the list of ports with the other server.
46 :param other: The second server to compare with.
47 :type other: :class:`heat.resources.server`
48 :return: * *True*: If all attributes are alike.
52 if self
.name
== other
.name
and self
.full_name
== other
.full_name
and \
53 self
.flavor
== other
.flavor
and \
54 self
.image
== other
.image
and \
55 self
.command
== other
.command
:
59 def __eq__(self
, other
):
60 if self
.name
== other
.name
and self
.full_name
== other
.full_name
and \
61 self
.flavor
== other
.flavor
and \
62 self
.image
== other
.image
and \
63 self
.command
== other
.command
and \
64 len(self
.port_names
) == len(other
.port_names
) and \
65 set(self
.port_names
) == set(other
.port_names
):
69 def create_server_dict(self
, compute
=None):
71 Creates the server description dictionary.
73 :param compute: The compute resource for further status information.
74 :type compute: :class:`heat.compute`
75 :return: Server description dictionary.
79 server_dict
['name'] = self
.name
80 server_dict
['full_name'] = self
.full_name
81 server_dict
['id'] = self
.id
82 server_dict
['template_name'] = self
.template_name
83 server_dict
['flavor'] = self
.flavor
84 server_dict
['image'] = self
.image
85 if self
.son_emu_command
is not None:
86 server_dict
['command'] = self
.son_emu_command
88 server_dict
['command'] = self
.command
90 if compute
is not None:
91 server_dict
['status'] = 'ACTIVE'
92 server_dict
['OS-EXT-STS:power_state'] = 1
93 server_dict
["OS-EXT-STS:task_state"] = None