Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VNF resource consumption functions #78

Merged
merged 11 commits into from
Aug 22, 2019
Prev Previous commit
Next Next commit
Update lists of available sf at a node
  • Loading branch information
ldklenner committed Aug 21, 2019
commit ed0c4a9ff6abe0f812d6b9412902251587b19ba4
6 changes: 4 additions & 2 deletions src/coordsim/reader/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_sf(sf_file, resource_functions_path):
# Configureable default mean and stdev defaults
default_processing_delay_mean = 1.0
default_processing_delay_stdev = 1.0
default_resource_function = lambda x: x
sf_list = defaultdict(None)
for sf_name, sf_details in sf_data['sf_list'].items():
sf_list[sf_name] = sf_details
Expand All @@ -79,11 +80,12 @@ def get_sf(sf_file, resource_functions_path):
resource_functions_path)
except Exception as ex:
sf_list[sf_name]["resource_function_id"] = 'default'
sf_list[sf_name]["resource_function"] = lambda x: x
sf_list[sf_name]["resource_function"] = default_resource_function
log.warning(f'{repr(ex)} Default resource function will be used instead.')
else:
sf_list[sf_name]["resource_function_id"] = 'default'
sf_list[sf_name]["resource_function"] = lambda x: x
sf_list[sf_name]["resource_function"] = default_resource_function
log.warning(f'No resource function specified. Default resource function will be used instead.')
return sf_list


Expand Down
6 changes: 6 additions & 0 deletions src/siminterface/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def apply(self, actions: SimulatorAction):
# Get the new placement from the action passed by the RL agent
# Modify and set the placement parameter of the instantiated simulator object.
self.simulator.params.sf_placement = actions.placement
# Update which sf is available at which node
for node_id, placed_sf_list in actions.placement.items():
available_sf = {}
for sf in placed_sf_list:
available_sf[sf] = self.simulator.params.network.nodes[node_id]['available_sf'].get(sf, {'load': 0.0})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each node stores a list of SFs that where placed and there current load as a node attribute. When changing the placement the list has to be updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the .get(sf, {'load': 0.0}) gets the current load of the SF at the node and defaults to 0 if the SF wasn't available?

self.simulator.params.network.nodes[node_id]['available_sf'] = available_sf

# Get the new schedule from the SimulatorAction
# Set it in the params of the instantiated simulator object.
Expand Down