1 # Copyright (c) 2015 SONATA-NFV and Paderborn University
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
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 # limitations under the License.
16 # Neither the name of the SONATA-NFV, Paderborn University
17 # nor the names of its contributors may be used to endorse or promote
18 # products derived from this software without specific prior written
21 # This work has been performed in the framework of the SONATA project,
22 # funded by the European Commission under Grant number 671517 through
23 # the Horizon 2020 and 5G-PPP programmes. The authors would like to
24 # acknowledge the contributions of their colleagues of the SONATA
25 # partner consortium (www.sonata-nfv.eu).
29 def __init__(self
, name
, id=None, flavor
=None,
30 image
=None, command
=None, nw_list
=None):
33 self
.template_name
= None
36 self
.command
= command
37 self
.port_names
= list()
38 self
.properties
= dict()
40 self
.son_emu_command
= None
41 self
.emulator_compute
= None
43 def compare_attributes(self
, other
):
45 Compares only class attributes like name and flavor but not the list of ports with the other server.
47 :param other: The second server to compare with.
48 :type other: :class:`heat.resources.server`
49 :return: * *True*: If all attributes are alike.
53 if self
.name
== other
.name
and self
.full_name
== other
.full_name
and \
54 self
.flavor
== other
.flavor
and \
55 self
.image
== other
.image
and \
56 self
.command
== other
.command
:
60 def __eq__(self
, other
):
61 if self
.name
== other
.name
and self
.full_name
== other
.full_name
and \
62 self
.flavor
== other
.flavor
and \
63 self
.image
== other
.image
and \
64 self
.command
== other
.command
and \
65 len(self
.port_names
) == len(other
.port_names
) and \
66 set(self
.port_names
) == set(other
.port_names
):
70 def create_server_dict(self
, compute
=None):
72 Creates the server description dictionary.
74 :param compute: The compute resource for further status information.
75 :type compute: :class:`heat.compute`
76 :return: Server description dictionary.
80 server_dict
['name'] = self
.name
81 server_dict
['full_name'] = self
.full_name
82 server_dict
['id'] = self
.id
83 server_dict
['template_name'] = self
.template_name
84 server_dict
['flavor'] = self
.flavor
85 server_dict
['image'] = self
.image
86 if self
.son_emu_command
is not None:
87 server_dict
['command'] = self
.son_emu_command
89 server_dict
['command'] = self
.command
91 if compute
is not None:
92 server_dict
['status'] = 'ACTIVE'
93 server_dict
['OS-EXT-STS:power_state'] = 1
94 server_dict
["OS-EXT-STS:task_state"] = None