A happy new year 2014

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
tests: add some tests for ryu.lib.of_config.classes

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
lib.of_config: import ryu.contrib

import ryu.contrib by ourself for the benefit of programs
which doesn't use other ryu.contrib stuffs like oslo.config.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_rest: support group-related messages

this patch makes ofctl_rest possible to:

  - support the GROUP action in the FlowMod message
  - support the GroupMod message
  - support the GroupStats message
  - support the GroupFeatures message
  - support the GroupDesc message

see following examples.

FlowMod with the group action:

  e.g.)

    curl -X POST -d '{"dpid": 1,
                      "match": {},
                      "actions": [{"type": "GROUP,
                                   "group_id": 1}]}' http://localhost:8080/stats/flowentry/add

GroupMod:

  usage)

    URI:    /stats/groupentry/{cmd}
    METHOD: POST

      NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.

    the message body is as follows:

      type      Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
      group_id  Group Identifier. (default: 0)
      buckets   a list of buckets.

    where each bucket has the following members:

      weight       Relative weight of bucket. (default: 0)
      watch_port   Port whose state affects whether this bucket is live. (default: OFPP_ANY)
      watch_group  Group whose state affects whether this bucket is live. (default: OFPG_ANY)
      actions      a list of actions. the format is the same as that of FlowMod.

  e.g.)

    curl -X POST -d '{"dpid": 1,
                      "type": "FF",
                      "group_id": 1,
                      "buckets": [{"watch_port": 2,
                                   "actions": [{"type": "OUTPUT",
                                                "port": 3}]}]}' http://localhost:8080/stats/groupentry/add

GroupStats:

  usage)

    URI:    /stats/group/{dpid}
    METHOD: GET

  e.g.)

    curl http://localhost:8080/stats/group/1
    {
      "1": [
        {
          "bucket_stats": [
            {
              "packet_count": 0,
              "byte_count": 0
            }
          ],
          "byte_count": 0,
          "ref_count": 0,
          "duration_nsec": 231000000,
          "packet_count": 0,
          "duration_sec": 11238,
          "group_id": 1
        }
      ]
    }

GroupFeatures:

  usage)

    URI:    /stats/groupfeatures/{dpid}
    METHOD: GET

  e.g.)

    curl http://localhost:8080/stats/groupfeatures/1
    {
      "1": [
        {
          "actions": [
            {"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
            {"SELECT": []},
            {"INDIRECT": []},
            {"FF": []}
          ],
          "max_groups": [
            {"ALL": 4294967040},
            {"SELECT": 4294967040},
            {"INDIRECT": 4294967040},
            {"FF": 4294967040}
          ],
          "capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
          "types": []
        }
      ]
    }

GroupDesc:

  usage)

    URI:    /stats/groupdesc/{dpid}
    METHOD: GET

  e.g.)

    curl http://localhost:8080/stats/groupdesc/1
    {
      "1": [
        {
          "buckets": [
            {
              "actions": ["OUTPUT:2"],
              "watch_group": 4294967295,
              "weight": 0,
              "watch_port": 3
            }
          ],
          "group_id": 1,
          "type": "FF"
        }
      ]
    }

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_rest: improve readability of the result of MeterFeatures

although 'band_types' of MeterFeatures were bitmaps of supported band types, it was expressed numerically.
this patch makes 'band_types' human-readable.

e.g.)

  curl http://localhost:8080/stats/meterfeatures/8796750050962
  {
    "8796750050962": [
      {
        "max_meter": 16777216,
        "max_color": 0,
        "max_band": 255,
        "band_types": ["DROP", "DSCP_REMARK"]
      }
    ]
  }

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bpdu: handling based on version and type

In bpdu.py only one version was permitted with one type, before.
This patch improves parser so that it may be based on multiple versions and types.

Signed-off-by: WATANABE Fumitaka <watanabe.fumitaka1@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
test_bpdu: add unit test

Signed-off-by: WATANABE Fumitaka <watanabe.fumitaka1@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>