| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 1 | """ |
| 2 | Distributed Cloud Emulator (dcemulator) |
| 3 | (c) 2015 by Manuel Peuster <manuel.peuster@upb.de> |
| 4 | """ |
| 5 | import logging |
| 6 | |
| 7 | |
| 8 | DCDPID_BASE = 1000 # start of switch dpid's used for data center switches |
| 9 | |
| 10 | |
| 11 | class Datacenter(object): |
| 12 | """ |
| 13 | Represents a logical data center to which compute resources |
| 14 | (Docker containers) can be added at runtime. |
| 15 | """ |
| 16 | |
| 17 | def __init__(self, name): |
| 18 | self.net = None # DCNetwork to which we belong |
| 19 | self.name = name |
| 20 | self.switch = None # first prototype assumes one "bigswitch" per DC |
| 21 | |
| 22 | def _get_next_dc_dpid(self): |
| 23 | global DCDPID_BASE |
| 24 | DCDPID_BASE += 1 |
| 25 | return DCDPID_BASE |
| 26 | |
| 27 | def create(self): |
| 28 | """ |
| 29 | Each data center is represented by a single switch to which |
| 30 | compute resources can be connected at run time. |
| 31 | |
| peusterm | 9c252b6 | 2016-01-06 16:59:53 +0100 | [diff] [blame^] | 32 | TODO: This will be changed in the future to support multiple networks |
| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 33 | per data center |
| 34 | """ |
| 35 | self.switch = self.net.mnet.addSwitch( |
| 36 | "%s.s1" % self.name, dpid=hex(self._get_next_dc_dpid())[2:]) |
| 37 | logging.debug("created data center switch: %s" % str(self.switch)) |
| 38 | |
| 39 | def start(self): |
| 40 | pass |
| 41 | |
| 42 | def addCompute(self): |
| 43 | pass |
| 44 | |
| 45 | def removeCompute(self): |
| 46 | pass |