| peusterm | 72f0988 | 2018-05-15 17:10:27 +0200 | [diff] [blame^] | 1 | # Copyright (c) 2015 SONATA-NFV and Paderborn University |
| 2 | # ALL RIGHTS RESERVED. |
| 3 | # |
| 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 |
| 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 | # limitations under the License. |
| 15 | # |
| 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 |
| 19 | # permission. |
| 20 | # |
| 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). |
| peusterm | 0019978 | 2017-05-17 08:48:12 +0200 | [diff] [blame] | 26 | import uuid |
| 27 | |
| 28 | |
| 29 | class Stack: |
| 30 | def __init__(self, id=None): |
| 31 | self.servers = dict() |
| 32 | self.nets = dict() |
| 33 | self.ports = dict() |
| 34 | self.routers = dict() |
| 35 | self.stack_name = None |
| 36 | self.creation_time = None |
| 37 | self.update_time = None |
| 38 | self.status = None |
| peusterm | 8bac1be | 2017-06-19 10:27:44 +0200 | [diff] [blame] | 39 | self.template = None |
| peusterm | 0019978 | 2017-05-17 08:48:12 +0200 | [diff] [blame] | 40 | if id is None: |
| 41 | self.id = str(uuid.uuid4()) |
| 42 | else: |
| 43 | self.id = id |
| 44 | |
| 45 | def add_server(self, server): |
| 46 | """ |
| 47 | Adds one server to the server dictionary. |
| 48 | |
| 49 | :param server: The server to add. |
| 50 | :type server: :class:`heat.resources.server` |
| 51 | """ |
| 52 | self.servers[server.name] = server |
| 53 | |
| 54 | def add_net(self, net): |
| 55 | """ |
| 56 | Adds one network to the network dictionary. |
| 57 | |
| 58 | :param net: Network to add. |
| 59 | :type net: :class:`heat.resources.net` |
| 60 | """ |
| 61 | self.nets[net.name] = net |
| 62 | |
| 63 | def add_port(self, port): |
| 64 | """ |
| 65 | Adds one port to the port dictionary. |
| 66 | |
| 67 | :param port: Port to add. |
| 68 | :type port: :class:`heat.resources.port` |
| 69 | """ |
| 70 | self.ports[port.name] = port |
| 71 | |
| 72 | def add_router(self, router): |
| 73 | """ |
| 74 | Adds one router to the port dictionary. |
| 75 | |
| 76 | :param router: Router to add. |
| 77 | :type router: :class:`heat.resources.router` |
| 78 | """ |
| 79 | self.routers[router.name] = router |