Skip to content
Snippets Groups Projects
Commit c96ef06f authored by Rowan Powell's avatar Rowan Powell
Browse files

Servers now send configure statements only one vm & server each

parent 2cf9fa36
No related branches found
No related tags found
No related merge requests found
......@@ -137,6 +137,12 @@ class DemoServer(object):
self.influxURL = db_url # InfluxDB connection URL
self.currentTime = int(round(time.time() * 1000)) # The current time
def configure(self, server_id, server_location):
print("Configuring")
self.configure_VM()
time.sleep(1)
self.configure_server(server_id, server_location)
def generate_clients(self):
self.clients = []
for i in range(self.clientCount):
......@@ -146,21 +152,24 @@ class DemoServer(object):
def reportStatus(self):
print('Number of clients: ' + str(len(self.clients)))
def configure_servers(self):
def configure_server(self, server_id, server_location):
print("Configuring Servers")
server_conf_block = []
ids = ['A', 'B', 'C']
locations = ['locA', 'locB', 'locC']
for i, id in enumerate(ids):
server_conf_block.append(
lp._generateServerConfig(id, locations[i], 8, '100G', '1T', self._selectDelay(len(ids))))
server_conf_block.append(lp._generateServerConfig(server_id, server_location, 8, '100G', '1T',
self._selectDelay(0)))
#ids = ['A', 'B', 'C']
#locations = ['locA', 'locB', 'locC']
#for i, id in enumerate(ids):
# server_conf_block.append(
# lp._generateServerConfig(id, locations[i], 8, '100G', '1T', self._selectDelay(len(ids))))
self._sendInfluxDataBlock(server_conf_block)
def configure_VMs(self):
def configure_VM(self):
print("Configuring VM nodes")
VM_conf_block = []
self._generateVMS('starting', 10, VM_conf_block)
self._generateVMS('running', 10, VM_conf_block)
self._generateVMS('starting', 1, VM_conf_block)
self._generateVMS('running', 1, VM_conf_block)
self._sendInfluxDataBlock(VM_conf_block)
......@@ -178,17 +187,12 @@ class DemoServer(object):
self._sendInfluxDataBlock(VM_conf_block)
def _generateVMS(self, state, amount, datablock):
for i in range(0, amount):
datablock.append(lp._generateVMConfig(state, 1, '100G', '1T', self._selectDelay(amount)))
def iterateService(self):
# The simulation will run through 'X' iterations of the simulation
# each time this method is called. This allows request/response messages to be
# batched and sent to the InfluxDB in sensible sized blocks
return self._executeServiceIteration(dc.ITERATION_STRIDE)
# 'Private' methods ________________________________________________________
def _executeServiceIteration(self, count):
requestBlock = []
......@@ -254,6 +258,11 @@ class DemoServer(object):
return self.simIterations
# 'Private' methods ________________________________________________________
def _generateVMS(self, state, amount, datablock):
for i in range(0, amount):
datablock.append(lp._generateVMConfig(state, 1, '100G', '1T', self._selectDelay(amount)))
def _cpuUsage(self, clientCount):
cpuUsage = randint(0, 10)
......@@ -362,9 +371,7 @@ database_manager.database_up()
time.sleep(2)
# configure servers
demoServer = DemoServer(clients, iterations, 'http://localhost:8186', 'testDB')
demoServer.reportStatus()
demoServer.configure_servers()
demoServer.configure_VMs()
demoServer.configure("Server1", "Southampton")
# Start simulation
print("Starting simulation")
while True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment