diff options
author | Satoshi Kobayashi <satoshi-k@stratosphere.co.jp> | 2014-09-01 11:41:03 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-09-01 15:16:05 +0900 |
commit | 4cfc239b30603ec331955435e08b27ae10654d20 (patch) | |
tree | 3b180a5c3ad0456cbbed41e2843984970e3aa64e | |
parent | bbb7724423d79532e10450e1a250fb46e5215416 (diff) |
bgp: should not use dict comprehension
Dict Comprehension is available in Python 2.7+ but Ryu should work
with Python2.6. Currently, It will become syntax error when we try to
operate BGP of Ryu on the platform of Python2.6.
Signed-off-by: Satoshi Kobayashi <satoshi-k@stratosphere.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/bgp/operator/command.py | 5 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/operator/commands/show/neighbor.py | 6 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/operator/commands/show/vrf.py | 3 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/operator/views/base.py | 2 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/peer.py | 5 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/speaker.py | 8 |
6 files changed, 16 insertions, 13 deletions
diff --git a/ryu/services/protocols/bgp/operator/command.py b/ryu/services/protocols/bgp/operator/command.py index 64449eff..8cdb579c 100644 --- a/ryu/services/protocols/bgp/operator/command.py +++ b/ryu/services/protocols/bgp/operator/command.py @@ -257,8 +257,9 @@ class TextFilter(object): resp = [resp[key] for key, value in enumerate(resp) if key not in remove] else: - resp = {key: value for key, value in resp.iteritems() - if key not in remove} + resp = dict([(key, value) + for key, value in resp.iteritems() + if key not in remove]) return resp else: diff --git a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py index 9f3f5ed0..f4d0f114 100644 --- a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py +++ b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py @@ -61,10 +61,10 @@ class SentRoutes(Command): return WrongParamResp('wrong addr_family name') ret = self._retrieve_paths(addr_family, rf, ip_addr).encode() - ret = { - path['nlri']['formatted_nlri']: path + ret = dict([ + (path['nlri']['formatted_nlri'], path) for path in ret - } + ]) return CommandsResponse(STATUS_OK, ret) diff --git a/ryu/services/protocols/bgp/operator/commands/show/vrf.py b/ryu/services/protocols/bgp/operator/commands/show/vrf.py index d1f4b6fd..2938e9fd 100644 --- a/ryu/services/protocols/bgp/operator/commands/show/vrf.py +++ b/ryu/services/protocols/bgp/operator/commands/show/vrf.py @@ -137,7 +137,8 @@ class Summary(Command, CountRoutesMixin): vrf_rf ) - encoded = {str(k): v for k, v in encoded.iteritems()} + encoded = dict([(str(k), v) + for k, v in encoded.iteritems()]) return CommandsResponse( STATUS_OK, encoded diff --git a/ryu/services/protocols/bgp/operator/views/base.py b/ryu/services/protocols/bgp/operator/views/base.py index bf62732f..2916df61 100644 --- a/ryu/services/protocols/bgp/operator/views/base.py +++ b/ryu/services/protocols/bgp/operator/views/base.py @@ -49,7 +49,7 @@ class OperatorAbstractView(object): def _collect_fields(cls): names = [attr for attr in dir(cls) if isinstance(getattr(cls, attr), fields.Field)] - return {name: getattr(cls, name) for name in names} + return dict([(name, getattr(cls, name)) for name in names]) def combine_related(self, field_name): """Combines related views. In case of DetailView it just returns diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py index 16576c2b..49c7151e 100644 --- a/ryu/services/protocols/bgp/peer.py +++ b/ryu/services/protocols/bgp/peer.py @@ -167,8 +167,9 @@ class PeerState(object): ) def _remember_last_bgp_error(self, identifier, data): - self._last_bgp_error = {k: v for k, v in data.iteritems() - if k != 'peer'} + self._last_bgp_error = dict([(k, v) + for k, v in data.iteritems() + if k != 'peer']) @property def recv_prefix(self): diff --git a/ryu/services/protocols/bgp/speaker.py b/ryu/services/protocols/bgp/speaker.py index f66ea41d..c206e42f 100644 --- a/ryu/services/protocols/bgp/speaker.py +++ b/ryu/services/protocols/bgp/speaker.py @@ -233,14 +233,14 @@ class BgpProtocol(Protocol, Activity): # Check MP_BGP capabilities were advertised. if local_mbgp_cap and remote_mbgp_cap: - local_families = { + local_families = set([ (peer_cap.afi, peer_cap.safi) for peer_cap in local_mbgp_cap - } - remote_families = { + ]) + remote_families = set([ (peer_cap.afi, peer_cap.safi) for peer_cap in remote_mbgp_cap - } + ]) afi_safi = local_families.intersection(remote_families) else: afi_safi = set() |