def __init__(self, configfile, islconffile):
        self.shell = {}
        self.rftable = RFTable()
        self.isltable = RFISLTable()
        self.config = RFConfig(configfile, 0)
        self.islconf = RFISLConf(islconffile)
        self.configured_rfvs = []
        self.switch = {}
        self.link = {}
        self.linkname = {}
        self.ent = 0
        # Logging
        self.log = logging.getLogger("rfserver")
        self.log.setLevel(logging.INFO)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        ch.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
        self.log.addHandler(ch)

        self.ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS,
                                                   MONGO_DB_NAME, RFSERVER_ID,
                                                   threading.Thread,
                                                   time.sleep)

        self.ipc.listen(RFCLIENT_RFSERVER_CHANNEL, self, self, False)
        self.ipc.listen(RFSERVER_RFPROXY_CHANNEL, self, self, False)
        filename = "rftest/CONF_FILE"
        f = open(filename, 'w')
        f.write("vm_id,vm_port,ct_id,dp_id,dp_port")
        f.close()
Пример #2
0
    def __init__(self, configfile, islconffile):
        self.rftable = RFTable()
        self.isltable = RFISLTable()
        self.config = RFConfig(configfile)
        self.islconf = RFISLConf(islconffile)
        self.configured_rfvs = []
        # Logging
        self.log = logging.getLogger("rfserver")
        self.log.setLevel(logging.INFO)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        ch.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
        self.log.addHandler(ch)

        self.ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS,
                                                   MONGO_DB_NAME, RFSERVER_ID,
                                                   threading.Thread,
                                                   time.sleep)
        self.log.info(
            "11111111111111111111111111111111111111111111111111111111111")
        self.ipc.listen(RFCLIENT_RFSERVER_CHANNEL, self, self, False)
        self.log.info(
            "2222222222222222222222222222222222222222222222222222222222")
        self.ipc.listen(RFSERVER_RFPROXY_CHANNEL, self, self, True)
        self.log.info(
            "33333333333333333333333333333333333333333333333333333333333")
Пример #3
0
    def __init__(self, *args, **kwargs):
        super(RFProxy, self).__init__(*args, **kwargs)

        ID = 0
        self.ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS,
                                                   MONGO_DB_NAME, str(ID),
                                                   hub_thread_wrapper,
                                                   hub.sleep)
        self.ipc.listen(RFSERVER_RFPROXY_CHANNEL, RFProtocolFactory(),
                        RFProcessor(), False)
        log.info("RFProxy running.")
Пример #4
0
def prettify_message(envelope):
    result = {}

    result[MongoIPC.FROM_FIELD] = format_id(envelope[MongoIPC.FROM_FIELD])
    result[MongoIPC.TO_FIELD] = format_id(envelope[MongoIPC.TO_FIELD])
    result[MongoIPC.READ_FIELD] = envelope[MongoIPC.READ_FIELD]
    result[MongoIPC.TYPE_FIELD] = envelope[MongoIPC.TYPE_FIELD]

    msg = MongoIPC.take_from_envelope(envelope, factory)
    result[MongoIPC.CONTENT_FIELD] = str(msg)

    return result
Пример #5
0
def prettify_message(envelope):
    result = {}

    result[MongoIPC.FROM_FIELD] = format_id(envelope[MongoIPC.FROM_FIELD])    
    result[MongoIPC.TO_FIELD] = format_id(envelope[MongoIPC.TO_FIELD])
    result[MongoIPC.READ_FIELD] = envelope[MongoIPC.READ_FIELD]
    result[MongoIPC.TYPE_FIELD] = envelope[MongoIPC.TYPE_FIELD]
    
    msg = MongoIPC.take_from_envelope(envelope, factory)
    result[MongoIPC.CONTENT_FIELD] = str(msg)

    return result
Пример #6
0
    def __init__(self, configfile):
        self.rftable = RFTable()
        self.config = RFConfig(configfile)
        self.configured_rfvs = False
        # Logging
        self.log = logging.getLogger("rfserver")
        self.log.setLevel(logging.INFO)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        ch.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
        self.log.addHandler(ch)

        self.ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS,
                                                   MONGO_DB_NAME, RFSERVER_ID)
        self.ipc.listen(RFCLIENT_RFSERVER_CHANNEL, self, self, False)
        self.ipc.listen(RFSERVER_RFPROXY_CHANNEL, self, self, True)
Пример #7
0
 def __init__(self, *arg, **kwargs):
     self.controllers = dict()
     self.monitors = dict()
     self.eligible_masters = dict()
     self.controllerLock = threading.Lock()
     self.ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS,
                                                MONGO_DB_NAME, RFMONITOR_ID,
                                                threading.Thread,
                                                time.sleep)
     self.ipc.listen(RFMONITOR_RFPROXY_CHANNEL, self, self, False)
     self.log = logging.getLogger("rfmonitor")
     self.log.setLevel(logging.INFO)
     ch = logging.StreamHandler()
     ch.setLevel(logging.INFO)
     ch.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
     self.log.addHandler(ch)
     self.test_controllers()
Пример #8
0
import rflib.defs as defs
import rflib.ipc.MongoIPC as MongoIPC
from rflib.ipc.RFProtocolFactory import RFProtocolFactory

def usage():
    print('Usage: %s <channel>\n' % sys.argv[0])
    print('channel: "rfclient" or "rfproxy"')
    sys.exit(1)

def parse_args(args=sys.argv):
    if (len(sys.argv) < 2):
        return None
    if (args[1] == 'rfclient'):
        return defs.RFCLIENT_RFSERVER_CHANNEL
    if (args[1] == 'rfproxy'):
        return defs.RFSERVER_RFPROXY_CHANNEL
    return None

if __name__ == '__main__':
    connection = pymongo.Connection('localhost', 27017)
    db = connection[defs.MONGO_DB_NAME]
    channel = parse_args()

    if (channel == None):
        usage()

    factory = RFProtocolFactory()
    for entry in db[channel].find():
        msg = MongoIPC.take_from_envelope(entry, factory)
        print(msg)
Пример #9
0
        for key in self.vs_to_dp.keys():
            id_, port = self.vs_to_dp[key]
            if id_ == dp_id:
                del self.vs_to_dp[key]

    # We're not considering the case of this table becoming invalid when a
    # datapath goes down. When the datapath comes back, the server recreates
    # the association, forcing new map messages to be generated, overriding the
    # previous mapping.
    # If a packet comes and matches the invalid mapping, it can be redirected
    # to the wrong places. We have to fix this.


netmask_prefix = lambda a: sum(
    [bin(int(x)).count("1") for x in a.split(".", 4)])
ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS, MONGO_DB_NAME, RFPROXY_ID)
table = Table()

# Logging
log = core.getLogger("rfproxy")


# Base methods
def send_of_msg(dp_id, ofmsg):
    topology = core.components['topology']
    switch = topology.getEntityByID(dp_id)
    if switch is not None and switch.connected:
        try:
            switch.send(ofmsg)
        except:
            return FAILURE
Пример #10
0

def usage():
    print('Usage: %s <channel>\n' % sys.argv[0])
    print('channel: "rfclient" or "rfproxy"')
    sys.exit(1)


def parse_args(args=sys.argv):
    if (len(sys.argv) < 2):
        return None
    if (args[1] == 'rfclient'):
        return defs.RFCLIENT_RFSERVER_CHANNEL
    if (args[1] == 'rfproxy'):
        return defs.RFSERVER_RFPROXY_CHANNEL
    return None


if __name__ == '__main__':
    connection = pymongo.Connection('localhost', 27017)
    db = connection[defs.MONGO_DB_NAME]
    channel = parse_args()

    if (channel == None):
        usage()

    factory = RFProtocolFactory()
    for entry in db[channel].find():
        msg = MongoIPC.take_from_envelope(entry, factory)
        print(msg)
Пример #11
0
                del self.vs_to_dp[key]

    # We're not considering the case of this table becoming invalid when a
    # datapath goes down. When the datapath comes back, the server recreates
    # the association, forcing new map messages to be generated, overriding the
    # previous mapping.
    # If a packet comes and matches the invalid mapping, it can be redirected
    # to the wrong places. We have to fix this.


netmask_prefix = lambda a: sum(
    [bin(int(x)).count("1") for x in a.split(".", 4)])

# TODO: add proper support for ID
ID = 0
ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS, MONGO_DB_NAME, str(ID),
                                      threading.Thread, time.sleep)
table = Table()

# Logging
log = core.getLogger("rfproxy")


# Base methods
def send_of_msg(dp_id, ofmsg):
    topology = core.components['topology']
    switch = topology.getEntityByID(dp_id)
    if switch is not None and switch.connected:
        try:
            switch.send(ofmsg)
        except:
            return FAILURE
Пример #12
0
 def __define_ipc(self):
     self.ipc = MongoIPC.MongoIPCMessageService(MONGO_ADDRESS,
                                                MONGO_DB_NAME, RFSERVER_ID,
                                                threading.Thread,
                                                time.sleep)