Search in sources :

Example 1 with OFNiciraControllerRoleReply

use of org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleReply in project onos by opennetworkinglab.

the class RoleManager method extractNiciraRoleReply.

/**
 * Extract the role from an OFVendor message.
 *
 * Extract the role from an OFVendor message if the message is a
 * Nicira role reply. Otherwise return null.
 *
 * @param experimenterMsg message
 * @return The role in the message if the message is a Nicira role
 * reply, null otherwise.
 * @throws SwitchStateException If the message is a Nicira role reply
 * but the numeric role value is unknown.
 */
@Override
public RoleState extractNiciraRoleReply(OFExperimenter experimenterMsg) throws SwitchStateException {
    int vendor = (int) experimenterMsg.getExperimenter();
    if (vendor != 0x2320) {
        return null;
    }
    OFNiciraControllerRoleReply nrr = (OFNiciraControllerRoleReply) experimenterMsg;
    RoleState role = null;
    OFNiciraControllerRole ncr = nrr.getRole();
    switch(ncr) {
        case ROLE_MASTER:
            role = RoleState.MASTER;
            break;
        case ROLE_OTHER:
            role = RoleState.EQUAL;
            break;
        case ROLE_SLAVE:
            role = RoleState.SLAVE;
            break;
        // handled below
        default:
    }
    if (role == null) {
        String msg = String.format("Switch: [%s], " + "received NX_ROLE_REPLY with invalid role " + "value %s", sw.getStringId(), nrr.getRole());
        throw new SwitchStateException(msg);
    }
    return role;
}
Also used : OFNiciraControllerRoleReply(org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleReply) OFNiciraControllerRole(org.projectfloodlight.openflow.protocol.OFNiciraControllerRole) RoleState(org.onosproject.openflow.controller.RoleState) SwitchStateException(org.onosproject.openflow.controller.driver.SwitchStateException)

Aggregations

RoleState (org.onosproject.openflow.controller.RoleState)1 SwitchStateException (org.onosproject.openflow.controller.driver.SwitchStateException)1 OFNiciraControllerRole (org.projectfloodlight.openflow.protocol.OFNiciraControllerRole)1 OFNiciraControllerRoleReply (org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleReply)1