Package openflow :: Package plugin :: Package gapi :: Module rspec
[hide private]
[frames] | no frames]

Module rspec

source code

Created on May 2, 2010

Contains functions to transform to and from RSpecs


Author: jnaous

Classes [hide private]
  BadURNError
  UnknownObject
Functions [hide private]
 
_dpid_to_urn(dpid)
Change the dpid into a URN.
source code
 
_urn_to_dpid(urn)
Change from a switch URN to a dpid.
source code
 
_port_to_urn(dpid, port)
Specify an interface as URN.
source code
 
_urn_to_port(urn)
Get the dpid and port from a urn specifiying a port.
source code
 
_get_root_node(slice_urn, available)
Create the root node and add all aggregates
source code
 
_add_aggregate_node(parent_elem, aggregate, slice_urn, available)
Add an aggregate and the switches and links
source code
 
_add_switches_node(parent_elem, aggregate, slice_urn, available)
Add the switches tag and all switches
source code
 
_add_ports(switch_elem, switch, slice_urn)
Add the ports tags for the switch
source code
 
_add_links_node(parent_elem, aggregate, slice_urn, available)
Add the links tag and all the links
source code
 
get_resources(slice_urn, geni_available)
Gets a list of all the resources under all the aggregates as XML.
source code
 
parse_slice(resv_rspec)
Parses the reservation RSpec and returns a tuple: (project_name, project_desc, slice_name, slice_desc, controller_url, firstname, lastname, affiliation, email, password, slivers) where slivers is a dict mapping OpenFlowInterface instances to a flowspace dict for reservation on them.
source code
 
_resv_parse_user(root)
parse the user tag from the root Element
source code
 
_resv_parse_slice(root) source code
 
_resv_parse_project(root) source code
 
_resv_parse_slivers(root)
Return a list of slivers where slivers is a list of tuples of (flowspace dict, OpenFlowInterface queryset).
source code
str
create_resv_rspec(user, slice, aggregate=None)
Create a reservation rspec from the set of interface slivers.
source code
(dict mapping str to list of int, list of (str, int, str, int, dict))
parse_external_rspec(rspec)
Parse the given rspec and create dicts of the given switches.
source code
Variables [hide private]
  RSPEC_TAG = 'rspec'
  NETWORK_TAG = 'network'
  LINKS_TAG = 'links'
  LINK_TAG = 'link'
  SWITCHES_TAG = 'switches'
  SWITCH_TAG = 'switch'
  PORT_NUM_TAG = 'port_num'
  VERSION = 'version'
  CURRENT_ADV_VERSION = '2'
  URN = 'urn'
  SRC_URN = 'src_urn'
  DST_URN = 'dst_urn'
  LOCATION = 'location'
  NAME = 'name'
  FLOWVISOR_URL = 'flowvisor_url'
  OPENFLOW_GAPI_RSC_URN_PREFIX = 'urn:publicid:IDN+beirut:expedi...
  SWITCH_URN_REGEX = '^urn:publicid:IDN\\+beirut:expedient:openf...
  PORT_URN_REGEX = '^urn:publicid:IDN\\+beirut:expedient:openflo...
  switch_re = re.compile(r'^urn:publicid:IDN\+beirut:expedient:o...
  port_re = re.compile(r'^urn:publicid:IDN\+beirut:expedient:ope...
  EXTERNAL_SWITCH_URN_REGEX = '^(?P<prefix>.*)\\+switch:(?P<dpid...
  EXTERNAL_PORT_URN_REGEX = '^(?P<prefix>.*)\\+switch:(?P<dpid>[...
  external_switch_re = re.compile(r'^(?P<prefix>.*)\+switch:(?P<...
  external_port_re = re.compile(r'^(?P<prefix>.*)\+switch:(?P<dp...
  RESV_RSPEC_TAG = 'resv_rspec'
  USER_TAG = 'user'
  FIRSTNAME = 'firstname'
  LASTNAME = 'lastname'
  AFFILIATION = 'affiliation'
  EMAIL = 'email'
  PASSWORD = 'password'
  PROJECT_TAG = 'project'
  SLICE_TAG = 'slice'
  DESCRIPTION = 'description'
  CONTROLLER = 'controller_url'
  FLOWSPACE_TAG = 'flowspace'
  PORT_TAG = 'port'
  DL_SRC_TAG = 'dl_src'
  DL_DST_TAG = 'dl_dst'
  DL_TYPE_TAG = 'dl_type'
  VLAN_ID_TAG = 'vlan_id'
  NW_SRC_TAG = 'nw_src'
  NW_DST_TAG = 'nw_dst'
  NW_PROTO_TAG = 'nw_proto'
  TP_SRC_TAG = 'tp_src'
  TP_DST_TAG = 'tp_dst'
  WILDCARD = '*'
  EXPIRY = 'expiry'
  CURRENT_RESV_VERSION = '2'
  __package__ = 'openflow.plugin.gapi'
Function Details [hide private]

get_resources(slice_urn, geni_available)

source code 

Gets a list of all the resources under all the aggregates as XML.

The XML returned has a <rspec> root node with no attributes.

Under the rspec there is a list of <network> elements with the following attributes:

  • location: location
  • name: name of the aggregate/network
  • flowvisor_url: currently not implemented

Under each <network> there are exactly two nodes: <links> and <nodes>.

<links> has a list of <link> nodes with the following attributes:

  • src_urn: identifier for the src port
  • dst_urn: identifier for the dst port

Currently no other attributes are defined through there may be more later.

<switches> has a list of <switch> nodes with the following attributes:

  • urn: urn prefix for a switch:datapathid

Currently no other attributes are defined through there may be more later.

For example:

   <rspec type="openflow" version="2">
       <network name="Stanford" location="Stanford, CA, USA">
           <switches>
               <switch urn="urn:publicid:IDN+openflow:stanford+switch:0">
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:0+port:0 />
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:0+port:1 />
               </switch>
               <switch urn="urn:publicid:IDN+openflow:stanford+switch:1">
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:1+port:0 />
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:1+port:1 />
               </switch>
               <switch urn="urn:publicid:IDN+openflow:stanford+switch:2">
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:0 />
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:1 />
               </switch>
           </switches>
           <links>
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:0+port:0
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:1+port:0
               />
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:1+port:0
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:0+port:0
               />
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:0+port:1
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:2+port:0
               />
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:2+port:0
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:0+port:1
               />
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:1+port:1
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:2+port:1
               />
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:2+port:1
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:1+port:1
               />
           </links>
       </network>
       <network name="Princeton" location="USA">
           <switches>
               <switch urn="urn:publicid:IDN+openflow:stanford+switch:3">
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:3+port:0 />
               </switch>
               <switch urn="urn:publicid:IDN+openflow:stanford+switch:4">
                   <port urn="urn:publicid:IDN+openflow:stanford+switch:4+port:0 />
               </switch>
           </switches>
           <links>
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:3+port:0
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:4+port:0
               />
               <link
                src_urn="urn:publicid:IDN+openflow:stanford+switch:4+port:0
                dst_urn="urn:publicid:IDN+openflow:stanford+switch:3+port:0
               />
           </links>
       </network>
   </rspec>

specifies a triangular graph at the Stanford network and a single link at the Princeton network

parse_slice(resv_rspec)

source code 

Parses the reservation RSpec and returns a tuple: (project_name, project_desc, slice_name, slice_desc, controller_url, firstname, lastname, affiliation, email, password, slivers) where slivers is a dict mapping OpenFlowInterface instances to a flowspace dict for reservation on them.

In the flowspace definition, specifying a "switch" element adds all interfaces on that switch. Otherwise, specifying ports adds only that port on the switch.

The reservation rspec looks like the following:

   <resv_rspec type="openflow" version="2">
       <user
           firstname="John"
           lastname="Doe"
           affiliation="Stanford"
           email="john.doe@geni.net"
           password="slice_pass"
       />
       <project
           name="Stanford Networking Group"
           description="Internet performance research to ..."
       />
       <slice
           name="Crazy Load Balancer"
           description="Does this and that..."
           controller_url="tcp:controller.stanford.edu:6633"
           expiry="1298020775"
       />
       <flowspace>
           <switch urn="urn:publicid:IDN+openflow:stanford+switch:0" />
           <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:1 />
           <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:2 />
           <port urn="urn:publicid:IDN+openflow:stanford+switch:2+port:3 />
           <dl_src from="22:33:44:55:66:77" to="22:33:44:55:66:77" />
           <dl_type from="0x800" to="0x800" />
           <vlan_id from="15" to="20" />
           <nw_src from="192.168.3.0" to="192.168.3.255" />
           <nw_dst from="192.168.3.0" to="192.168.3.255" />
           <nw_proto from="17" to="17" />
           <tp_src from="100" to="100" />
           <tp_dst from="100" />
       </flowspace>
       <flowspace>
           <switch urn="urn:publicid:IDN+openflow:stanford+switch:1" />
           <tp_src from="100" to="100" />
           <tp_dst from="100" />
       </flowspace>
   </resv_rspec>

Any missing fields from the flowspace mean wildcard. All '*' means any value.

The available fields are:

   dl_src, dl_dst, dl_type, vlan_id, nw_src,
   nw_dst, nw_proto, tp_src, tp_dst

All integers can by specified as hex or decimal.

create_resv_rspec(user, slice, aggregate=None)

source code 

Create a reservation rspec from the set of interface slivers.

Parameters:
Returns: str
an OpenFlow reservation RSpec for the wanted slivers.

parse_external_rspec(rspec)

source code 

Parse the given rspec and create dicts of the given switches.

Parses the RSpec and creates a dict mapping switches to the ports they have. It also creates a list of (dpid, port, dpid, port) describing the links.

Parameters:
  • rspec (XML str) - The advertisement RSpec
Returns: (dict mapping str to list of int, list of (str, int, str, int, dict))
tuple of a dict mapping datapath ID strings to list of port numbers and a list of (src dpid, src port num, dst dpid, dst port num, attrs) describing the links.

Variables Details [hide private]

OPENFLOW_GAPI_RSC_URN_PREFIX

Value:
'urn:publicid:IDN+beirut:expedient:openflow'

SWITCH_URN_REGEX

Value:
'^urn:publicid:IDN\\+beirut:expedient:openflow\\+switch:(?P<dpid>[\\d:\
a-fA-F]+)$'

PORT_URN_REGEX

Value:
'^urn:publicid:IDN\\+beirut:expedient:openflow\\+switch:(?P<dpid>[\\d:\
a-fA-F]+)\\+port:(?P<port>\\d+)$'

switch_re

Value:
re.compile(r'^urn:publicid:IDN\+beirut:expedient:openflow\+switch:(?P<\
dpid>[\d:a-fA-F]+)$')

port_re

Value:
re.compile(r'^urn:publicid:IDN\+beirut:expedient:openflow\+switch:(?P<\
dpid>[\d:a-fA-F]+)\+port:(?P<port>\d+)$')

EXTERNAL_SWITCH_URN_REGEX

Value:
'^(?P<prefix>.*)\\+switch:(?P<dpid>[:a-fA-F\\d]+)$'

EXTERNAL_PORT_URN_REGEX

Value:
'^(?P<prefix>.*)\\+switch:(?P<dpid>[:a-fA-F\\d]+)\\+port:(?P<port>\\d+\
)$'

external_switch_re

Value:
re.compile(r'^(?P<prefix>.*)\+switch:(?P<dpid>[:a-fA-F\d]+)$')

external_port_re

Value:
re.compile(r'^(?P<prefix>.*)\+switch:(?P<dpid>[:a-fA-F\d]+)\+port:(?P<\
port>\d+)$')