Skip to content

Commit

Permalink
Merge pull request kytos#30 from ajoaoff/issue28
Browse files Browse the repository at this point in the history
Include flow priority
  • Loading branch information
Antonio Francisco authored Aug 2, 2021
2 parents 6da60d7 + 45cc910 commit 4aff4ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def update(self, circuit_id):
raise UnsupportedMediaType(result)

try:
enable, path = \
enable, redeploy = \
evc.update(**self._evc_dict_with_instances(data))
except ValueError as exception:
log.error(exception)
Expand All @@ -221,7 +221,7 @@ def update(self, circuit_id):
if enable is False: # disable if active
with evc.lock:
evc.remove()
elif path is not None: # redeploy if active
elif redeploy is not None: # redeploy if active
with evc.lock:
evc.remove()
evc.deploy()
Expand Down
14 changes: 8 additions & 6 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __init__(self, controller, **kwargs):
self.dynamic_backup_path = kwargs.get('dynamic_backup_path', False)
self.creation_time = get_time(kwargs.get('creation_time')) or now()
self.owner = kwargs.get('owner', None)
self.priority = kwargs.get('priority', 0)
self.priority = kwargs.get('priority', -1)
self.circuit_scheduler = kwargs.get('circuit_scheduler', [])

self.current_links_cache = set()
Expand Down Expand Up @@ -259,13 +259,13 @@ def update(self, **kwargs):
attributes: [name, uni_a and uni_z]
Returns:
the values for enable and a path attribute, if exists and None
the values for enable and a redeploy attribute, if exists and None
otherwise
Raises:
ValueError: message with error detail.
"""
enable, path = (None, None)
enable, redeploy = (None, None)
for attribute, value in kwargs.items():
if attribute in self.unique_attributes:
raise ValueError(f'{attribute} can\'t be be updated.')
Expand All @@ -283,12 +283,12 @@ def update(self, **kwargs):
self.deactivate()
else:
setattr(self, attribute, value)
if 'path' in attribute:
path = value
if 'path' in attribute or 'priority' in attribute:
redeploy = value
else:
raise ValueError(f'The attribute "{attribute}" is invalid.')
self.sync()
return enable, path
return enable, redeploy

def __repr__(self):
"""Repr method."""
Expand Down Expand Up @@ -772,6 +772,8 @@ def _prepare_flow_mod(self, in_interface, out_interface, queue_id=None):
flow_mod = {"match": {"in_port": in_interface.port_number},
"cookie": self.get_cookie(),
"actions": default_actions}
if self.priority > -1:
flow_mod['priority'] = self.priority

return flow_mod

Expand Down

0 comments on commit 4aff4ff

Please sign in to comment.