#NEWLINE# def parse_slice( resv_rspec ) : #NEWLINE# #INDENT# '\n    Parses the reservation RSpec and returns a tuple:\n    C{(project_name, project_desc, slice_name, slice_desc, \n    controller_url, firstname, lastname, affiliation, email, password,\n    slivers)} where C{slivers}\n    is a dict mapping OpenFlowInterface instances to a flowspace\n    dict for reservation on them.\n    \n    In the flowspace definition, specifying a "switch" element adds all\n    interfaces on that switch. Otherwise, specifying ports adds only that\n    port on the switch.\n    \n    The reservation rspec looks like the following::\n    \n        <resv_rspec type="openflow" version="2">\n            <user\n                firstname="John"\n                lastname="Doe"\n                affiliation="Stanford"\n                email="john.doe@geni.net"\n                password="slice_pass"\n            />\n            <project\n                name="Stanford Networking Group"\n                description="Internet performance research to ..."\n            />\n            <slice\n                name="Crazy Load Balancer"\n                description="Does this and that..."\n                controller_url="tcp:controller.stanford.edu:6633"\n                expiry="1298020775"\n            />\n            <flowspace>\n                <switch urn="urn:publicid:IDN+openflow:stanford+switch:0" />\n                <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:1 />\n                <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:2 />\n                <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:3 />\n                <dl_src from="22:33:44:55:66:77" to="22:33:44:55:66:77" />\n                <dl_type from="0x800" to="0x800" />\n                <vlan_id from="15" to="20" />\n                <nw_src from="192.168.3.0" to="192.168.3.255" />\n                <nw_dst from="192.168.3.0" to="192.168.3.255" />\n                <nw_proto from="17" to="17" />\n                <tp_src from="100" to="100" />\n                <tp_dst from="100" />\n            </flowspace>\n            <flowspace>\n                <switch urn="urn:publicid:IDN+openflow:stanford+switch:1" />\n                <tp_src from="100" to="100" />\n                <tp_dst from="100" />\n            </flowspace>\n        </resv_rspec>\n    \n    Any missing fields from the flowspace mean wildcard. All \'*\' means any\n    value.\n    \n    The available fields are::\n        \n        dl_src, dl_dst, dl_type, vlan_id, nw_src,\n        nw_dst, nw_proto, tp_src, tp_dst\n    \n    All integers can by specified as hex or decimal.\n    ' #NEWLINE# root = et . fromstring ( resv_rspec ) #NEWLINE# version = root . get ( VERSION , 'unknown' ) #NEWLINE# if ( version != CURRENT_RESV_VERSION ) : #NEWLINE# #INDENT# raise Exception ( ( 'Can only parse reservation rspecs version 2. Given rspec version is %s' % version ) ) #NEWLINE# #UNINDENT# ( firstname , lastname , affiliation , email , password ) = _resv_parse_user ( root ) #NEWLINE# ( slice_name , slice_desc , slice_expiry , controller_url ) = _resv_parse_slice ( root ) #NEWLINE# ( project_name , project_desc ) = _resv_parse_project ( root ) #NEWLINE# slivers = _resv_parse_slivers ( root ) #NEWLINE# return ( project_name , project_desc , slice_name , slice_desc , slice_expiry , controller_url , firstname , slice_name , affiliation , email , password , slivers )