Signed-off-by: Isaku Yamahata <[email protected]>
---
ryu/{flags.py => lib/dpid.py} | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
copy ryu/{flags.py => lib/dpid.py} (59%)
diff --git a/ryu/flags.py b/ryu/lib/dpid.py
similarity index 59%
copy from ryu/flags.py
copy to ryu/lib/dpid.py
index e969620..f7405fd 100644
--- a/ryu/flags.py
+++ b/ryu/lib/dpid.py
@@ -1,5 +1,4 @@
-# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
-# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
+# Copyright (C) 2012 Isaku Yamahata <yamahata at private email ne jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -13,13 +12,18 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-"""
-global flags
-"""
-import gflags
+# Internal representation of datapath id is quad int
+# string representation is in hex without '0x'
-FLAGS = gflags.FLAGS
+_DPID_LEN = 16
+_DPID_FMT = '%0' + str(_DPID_LEN) + 'x'
-# GLOBAL flags
-gflags.DEFINE_boolean('monkey_patch', False, 'do monkey patch')
+
+def dpid_to_str(dpid):
+ return _DPID_FMT % dpid
+
+
+def str_to_dpid(dpid_str):
+ assert len(dpid_str) == _DPID_LEN
+ return int(dpid_str, 16)
--
1.7.1.1
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel