- def new_scenario2(self, scenario_dict):
- tries = 2
- while tries:
- created_time = time.time()
- try:
- with self.con:
- self.cur = self.con.cursor()
- tenant_id = scenario_dict.get('tenant_id')
- #scenario
- INSERT_={'tenant_id': tenant_id,
- 'name': scenario_dict['name'],
- 'description': scenario_dict['description'],
- 'public': scenario_dict.get('public', "false")}
-
- scenario_uuid = self._new_row_internal('scenarios', INSERT_, add_uuid=True, root_uuid=None, created_time=created_time)
- #sce_nets
- for net in scenario_dict['nets'].values():
- net_dict={'scenario_id': scenario_uuid}
- net_dict["name"] = net["name"]
- net_dict["type"] = net["type"]
- net_dict["description"] = net.get("description")
- net_dict["external"] = net.get("external", False)
- if "graph" in net:
- #net["graph"]=yaml.safe_dump(net["graph"],default_flow_style=True,width=256)
- #TODO, must be json because of the GUI, change to yaml
- net_dict["graph"]=json.dumps(net["graph"])
- created_time += 0.00001
- net_uuid = self._new_row_internal('sce_nets', net_dict, add_uuid=True, root_uuid=scenario_uuid, created_time=created_time)
- net['uuid']=net_uuid
-
- if "ip-profile" in net: