예제 #1
0
파일: ovsgre.py 프로젝트: dana-i2cat/felix
    def teardown_tunnel(self, src_if, dst_if):
        sw = get_swManager(src_if)
        ofport = None
        
        try:
            # ofport = sw.get_port(src_if.ofdev)
            ofdev, ofport = src_if.get_of(self.ovs_id)
            ofport2 = sw.get_port(ofdev)
            if ofport != ofport2:
                logger.error("teardown_tunnel:ofdev=%s: mismatch ofport=%s, ofport2=%s" % (ofdev, ofport, ofport2))
                ofport = ofport2
        except Exception as e:
            logger.error("teardown_tunnel:gre port is None. ex=%s" % e)
            
        if ofport is not None:
            urlbase = src_if.ryu_url
            dpid = src_if.dpid

            logger.info("teardown gre link here. url=%s, dpid=%s, ovsdb=%s, dev=%s, type=%s, local=%s, remote=%s" %
                        (urlbase, dpid, src_if.ovsdb, ofdev, src_if.gtype, src_if.address, dst_if.address));

            params = {}
            params["ovsdb"] = src_if.ovsdb
            params["name"] = ofdev
            params["remote_ip"] = dst_if.address

            ovsif.del_tunnel(urlbase, dpid, params)

        # src_if.ofport = None
        src_if.set_of(self.ovs_id, ofdev, None)
        sw.set_free(ofdev)
예제 #2
0
    def reserve(self, resv):
        # logger.info("ovsgre:OvsManager:reserve: enter")
        # This just only reserve vlans for source/destination/tunnel interfaces
        if resv is None:
            raise ManagerException("OvsManager:reserve",
                                   "The reservation parameter is null.")

        self.check_stp(resv)

        resv_id = uuid.uuid4()
        logger.info("ovsManager:reserve: new resv_id=%s." % resv_id)

        if dict_resvParameter.has_key(resv_id):
            logger.error("Never here. Reservation id is duplicated(%s)." %
                         (resv_id))
            raise ManagerException("OvsManager:reserve",
                                   "The reservation id is already used.")

        resvp = resvParameter(self.ovs_id, resv)

        (s_vlan, d_vlan, t_vlan) = resvp.allocate()
        resv.trans_vlan = t_vlan

        dict_resvParameter[resv_id] = resvp
        self.dict_isSetRule[resv_id] = False
        logger.info("ovsManager:reserve: done. resv_id=%s" % (resv_id))
        return resv_id
예제 #3
0
    def teardown_tunnel(self, src_if, dst_if):
        sw = get_swManager(src_if)
        ofport = None
        
        try:
            # ofport = sw.get_port(src_if.ofdev)
            ofdev, ofport = src_if.get_of(self.ovs_id)
            ofport2 = sw.get_port(ofdev)
            if ofport != ofport2:
                logger.error("teardown_tunnel:ofdev=%s: mismatch ofport=%s, ofport2=%s" % (ofdev, ofport, ofport2))
                ofport = ofport2
        except Exception as e:
            logger.info("teardown_tunnel:gre port is None")
            
        if ofport is not None:
            urlbase = src_if.ryu_url
            dpid = src_if.dpid

            logger.info("teardown gre link here. url=%s, dpid=%s, ovsdb=%s, dev=%s, type=%s, local=%s, remote=%s" %
                        (urlbase, dpid, src_if.ovsdb, ofdev, src_if.gtype, src_if.address, dst_if.address));

            params = {}
            params["ovsdb"] = src_if.ovsdb
            params["name"] = ofdev
            params["remote_ip"] = dst_if.address

            ovsif.del_tunnel(urlbase, dpid, params)

        # src_if.ofport = None
        src_if.set_of(self.ovs_id, ofdev, None)
        sw.set_free(ofdev)
예제 #4
0
파일: db.py 프로젝트: ict-felix/stack
    def update(self, resv):
        fmt = "UPDATE %s SET %s=\"%s\",  %s=\"%s\",  %s=\"%s\",  %s=\"%s\",  %s=\"%s\" WHERE resv_urn=\"%s\""

        error = resv.error
        if error is not None:
            error = error.replace("\"", "")
            error = error.replace("\'", "")

        sql = fmt % (mySQLtbl, 
                     "geni_expires", resv.end_time,
                     "geni_operational_status", resv.ostatus,
                     "geni_allocation_status", resv.astatus,
                     "geni_error", error,
                     "geni_action", resv.action,
                     resv.urn)

        logger.info("tnrm_db:update: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:restart: ex=%s" % e)
            raise e
        finally:
            self.close()
예제 #5
0
파일: db.py 프로젝트: dana-i2cat/felix
    def update(self, resv):
        fmt = "UPDATE %s SET %s=\"%s\",  %s=\"%s\",  %s=\"%s\",  %s=\"%s\",  %s=\"%s\" WHERE resv_urn=\"%s\""

        error = resv.error
        if error is not None:
            error = error.replace("\"", "")
            error = error.replace("\'", "")

        sql = fmt % (mySQLtbl, 
                     "geni_expires", resv.end_time,
                     "geni_operational_status", resv.ostatus,
                     "geni_allocation_status", resv.astatus,
                     "geni_error", error,
                     "geni_action", resv.action,
                     resv.urn)

        logger.info("tnrm_db:update: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:restart: ex=%s" % e)
            raise e
        finally:
            self.close()
예제 #6
0
    def provision (self, resv):
        # provison:nsiv2, poa geni_start
        if resv is None or not dict_resvParameter.has_key(resv.resv_id):
            logger.info("ovsManager:provision: resv_id=%s" % (resv.resv_id))
            for key in dict_resvParameter:
                logger.info("ovsManager:provision: resvp=%s" % (key))
            raise ManagerException("OvsManager:provision", "The reservation is null.")
        
        resvp = dict_resvParameter[resv.resv_id]
        if resvp is None:
            raise ManagerException("OvsManager:privision", "The ResvParameter is null.")

        if self.isSetup:
            # already setup
            pass
        else:
            try:
                ### setup src->dst
                self.setup_tunnel(self.src_if, self.dst_if)
            except:
                raise

            try:
                ### setup dst->src
                self.setup_tunnel(self.dst_if, self.src_if)
            except:
                ### teardown tunnel by setup_tunnel(self.src_if, self.dst_if)
                self.teardown_tunnel(self.src_if, self.dst_if)
                raise
                
            self.isSetup = True

        self.dict_used[resv.resv_id] = resv.resv_id

        if self.dict_isSetRule[resv.resv_id]:
            # already set flow rule
            pass
        else:
            #### add code for set rule
            logger.info("set flow rule. %s?vlan=%s:%s?vlan=%s, gre?vlan=%s." % 
                        (resvp.s_stp, resvp.s_vlan, resvp.d_stp, resvp.d_vlan, resvp.t_vlan))
            try:
                ### add src
                self.add_rule(self.src_if, resvp.s_vlan, resvp.t_vlan)
            except Exception as ex:
                logger.error("provision: error in add rule: src_if=%s sevlan=%s, ofvlan=%s, ex=%s" % (self.src_if, resvp.s_vlan, resvp.t_vlan, ex))
                raise ex

            try:
                ### add dst
                self.add_rule(self.dst_if, resvp.d_vlan, resvp.t_vlan)
            except Exception as ex:
                logger.error("provision: error in add rule: dst_if=%s sevlan=%s, ofvlan=%s, ex=%s" % (self.dst_if, resvp.s_vlan, resvp.t_vlan, ex))
                self.del_rule(self.src_if, resvp.s_vlan, resvp.t_vlan)
                raise ex

            self.dict_isSetRule[resv.resv_id] = True

        return resv.resv_id
예제 #7
0
파일: db.py 프로젝트: ict-felix/stack
    def close(self):
        if self.con is None:
            loggererror("Rule violation: use database. So TNRM stop now.")
            raise Exception("Rule violation: use database. So TNRM stop now.")

        try:
            if self.con is not None:
                self.con.close()
        except Exception as e:
            logger.error("tnrm_db:init: use database:%s, ex=%s" % 
                         (mySQLdb, e))
        finally:
            self.con = None
            self.cur = None
예제 #8
0
    def close(self):
        if self.con is None:
            loggererror("Rule violation: use database. So TNRM stop now.")
            raise Exception("Rule violation: use database. So TNRM stop now.")

        try:
            if self.con is not None:
                self.con.close()
        except Exception as e:
            logger.error("tnrm_db:init: use database:%s, ex=%s" % 
                         (mySQLdb, e))
        finally:
            self.con = None
            self.cur = None
예제 #9
0
파일: db.py 프로젝트: ict-felix/stack
    def delete(self, resv):
        fmt = "DELETE FROM %s WHERE resv_urn=\"%s\""
        sql = fmt % (mySQLtbl, resv.urn)

        logger.info("tnrm_db:delete: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:delete: ex=%s" % e)
            raise e
        finally:
            self.close()
예제 #10
0
    def delete(self, resv):
        fmt = "DELETE FROM %s WHERE resv_urn=\"%s\""
        sql = fmt % (mySQLtbl, resv.urn)

        logger.info("tnrm_db:delete: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:delete: ex=%s" % e)
            raise e
        finally:
            self.close()
예제 #11
0
파일: db.py 프로젝트: ict-felix/stack
    def open(self):
        if self.con is not None:
            logger.error("Rule violation: use database. So TNRM stop now.")
            raise Exception("Rule violation: use database. So TNRM stop now.")

        try:
            self.con = MySQLdb.connect(host = mySQLhost, db = "",
                                       user = mySQLuser, passwd = mySQLpass, 
                                       charset = mySQLchar)
            self.cur = self.con.cursor()
            
            sql = "USE %s" % mySQLdb
            self.cur.execute(sql)
        except Exception as e:
            logger.error("tnrm_db:init: use database:%s, ex=%s" % 
                         (mySQLdb, e))
예제 #12
0
파일: db.py 프로젝트: ict-felix/stack
    def update_time(self, resv):
        fmt = "UPDATE %s SET %s=\"%s\" WHERE resv_urn=\"%s\""
        sql = fmt % (mySQLtbl, 
                     "geni_expires", resv.end_time, resv.urn)

        logger.info("tnrm_db:update: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:restart: ex=%s" % e)
            raise e
        finally:
            self.close()
예제 #13
0
    def open(self):
        if self.con is not None:
            logger.error("Rule violation: use database. So TNRM stop now.")
            raise Exception("Rule violation: use database. So TNRM stop now.")

        try:
            self.con = MySQLdb.connect(host = mySQLhost, db = "",
                                       user = mySQLuser, passwd = mySQLpass, 
                                       charset = mySQLchar)
            self.cur = self.con.cursor()
            
            sql = "USE %s" % mySQLdb
            self.cur.execute(sql)
        except Exception as e:
            logger.error("tnrm_db:init: use database:%s, ex=%s" % 
                         (mySQLdb, e))
예제 #14
0
    def update_time(self, resv):
        fmt = "UPDATE %s SET %s=\"%s\" WHERE resv_urn=\"%s\""
        sql = fmt % (mySQLtbl, 
                     "geni_expires", resv.end_time, resv.urn)

        logger.info("tnrm_db:update: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:restart: ex=%s" % e)
            raise e
        finally:
            self.close()
예제 #15
0
    def setup_tunnel(self, src_if, dst_if):
        logger.info("setup src_if=%s" % src_if)
        logger.info("setup dst_if=%s" % dst_if)

        sw = get_swManager(src_if)
        ofport = None

        try:
            # ofport = sw.get_port(src_if.ofdev)
            ofdev, ofport = src_if.get_of(self.ovs_id)
            ofport2 = sw.get_port(ofdev)
            if ofport != ofport2:
                logger.error(
                    "setup_tunnel:ofdev=%s: mismatch ofport=%s, ofport2=%s" %
                    (ofdev, ofport, ofport2))
                ofport = ofport2
        except Exception as ex:
            logger.info("setup_tunnel:gre port is None")

        if ofport is None:
            urlbase = src_if.ryu_url
            dpid = src_if.dpid

            logger.info(
                "setup gre link here. url=%s, dpid=%s, ovsdb=%s, dev=%s, type=%s, local=%s, remote=%s"
                % (urlbase, dpid, src_if.ovsdb, ofdev, src_if.gtype,
                   src_if.address, dst_if.address))

            params = {}
            params["ovsdb"] = src_if.ovsdb
            params["name"] = ofdev
            if (src_if.gtype == "ovsgre"):
                params["type"] = "gre"
            else:
                raise ManagerException(
                    "OvsManager:setup_tunnel",
                    "Type (%s) is unknown, must be \"ovsgre\"." %
                    (src_if.gtype))
            params["local_ip"] = src_if.address
            params["remote_ip"] = dst_if.address

            ofport = ovsif.add_tunnel(urlbase, dpid, params)

        # src_if.ofport = ofport
        src_if.set_of(self.ovs_id, ofdev, ofport)
        sw.set_used(ofdev, ofport)
예제 #16
0
    def restart (self):
        fmt = "SELECT * from %s"
        sql = fmt % mySQLtbl
        logger.info("tnrm_db:select: sql=%s" % sql)

        try:
            self.open()
            self.cur.execute(sql)
            rows = self.cur.fetchall()
        except Exception as e:
            logger.error("tnrm_db:restart: ex=%s" % e)
            raise e
        finally:
            self.close()

        drows = []
        for row in rows:
            d = self.row2dict(row)
            drows.append(d)
            logger.info("tnrm_db:select: row=%s" % self.row2str(d))

            if False:
                pass
                # ep = Endpoint(ep_name, ep_vlantag, node, stp)
                # resv = Reservation(None, d["slice_urn"], d["resv_urn"], None, path, d["geni_expires"], d["start_time"]);

            manifest = reservation.manifest_rspec + d["manifest_node"] + d["manifest_link"] + reservation.close_rspec;

            current_time = datetime.datetime.utcnow()
            ic_time = unix_time_sec(current_time)
            is_datetime = datetime.datetime.strptime(d["start_time"], '%Y-%m-%d %H:%M:%S.%f')
            is_time = unix_time_sec(is_datetime)
            ie_datetime = datetime.datetime.strptime(d["geni_expires"], '%Y-%m-%d %H:%M:%S.%f')
            ie_time = unix_time_sec(ie_datetime)

            # logger.info("start_time:   %s, %d" % (d["start_time"], is_time))
            # logger.info("end_time:     %s, %d" % (d["geni_expires"], ie_time))
            # logger.info("current_time: %s, %d" % (current_time, ic_time))

            # try:
            self.tnrm.re_allocate(
                d["slice_urn"], d["resv_urn"], manifest, is_datetime, 
                ie_datetime, d["nsi_id"], d["transvlan"], 
                d["geni_operational_status"], d["geni_allocation_status"], 
                d["geni_error"], d["geni_action"])
예제 #17
0
파일: ovsgre.py 프로젝트: dana-i2cat/felix
    def setup_tunnel(self, src_if, dst_if):
        logger.info("setup src_if=%s" % src_if)
        logger.info("setup dst_if=%s" % dst_if)

        sw = get_swManager(src_if)
        ofport = None

        try:
            # ofport = sw.get_port(src_if.ofdev)
            ofdev, ofport = src_if.get_of(self.ovs_id)
            ofport2 = sw.get_port(ofdev)
            if ofport != ofport2:
                logger.error("setup_tunnel:ofdev=%s: mismatch ofport=%s, ofport2=%s" % (ofdev, ofport, ofport2))
                ofport = ofport2
        except Exception as ex:
            logger.info("setup_tunnel:gre port is None")
            
        if ofport is None:
            urlbase = src_if.ryu_url
            dpid = src_if.dpid

            logger.info("setup gre link here. url=%s, dpid=%s, ovsdb=%s, dev=%s, type=%s, local=%s, remote=%s" %
                        (urlbase, dpid, src_if.ovsdb, ofdev, src_if.gtype, src_if.address, dst_if.address));

            params = {}
            params["ovsdb"] = src_if.ovsdb
            params["name"] = ofdev
            if (src_if.gtype == "ovsgre"):
                params["type"] = "gre"
            else:
                raise ManagerException("OvsManager:setup_tunnel", 
                                       "Type (%s) is unknown, must be \"ovsgre\"." % (src_if.gtype))
            params["local_ip"] = src_if.address
            params["remote_ip"] = dst_if.address

            ofport = ovsif.add_tunnel(urlbase, dpid, params)

        # src_if.ofport = ofport
        src_if.set_of(self.ovs_id, ofdev, ofport)
        sw.set_used(ofdev, ofport)
예제 #18
0
파일: ovsgre.py 프로젝트: dana-i2cat/felix
    def reserve (self, resv):
        # logger.info("ovsgre:OvsManager:reserve: enter")
        # This just only reserve vlans for source/destination/tunnel interfaces
        if resv is None:
            raise ManagerException("OvsManager:reserve", "The reservation parameter is null.")
        
        self.check_stp(resv)

        resv_id = uuid.uuid4()
        logger.info("ovsManager:reserve: new resv_id=%s." % resv_id)
        
        if dict_resvParameter.has_key(resv_id):
            logger.error("Never here. Reservation id is duplicated(%s)." % (resv_id))
            raise ManagerException("OvsManager:reserve", "The reservation id is already used.")

        resvp = resvParameter(self.ovs_id, resv)

        (s_vlan, d_vlan, t_vlan) = resvp.allocate()
        resv.trans_vlan = t_vlan

        dict_resvParameter[resv_id] = resvp
        self.dict_isSetRule[resv_id] = False
        logger.info("ovsManager:reserve: done. resv_id=%s" % (resv_id))
        return resv_id
예제 #19
0
파일: db.py 프로젝트: ict-felix/stack
    def __init__(self):
        try:
            self.tnrm = None
            self.con = MySQLdb.connect(host = mySQLhost, db = "",
                                       user = mySQLuser, passwd = mySQLpass, 
                                       charset = mySQLchar)

            self.cur = self.con.cursor()
            sql = "CREATE DATABASE IF NOT EXISTS %s" % mySQLdb
            # sql = "CREATE DATABASE %s" % mySQLdb
            try:
                self.cur.execute(sql)
            except Exception as e:
                logger.error("tnrm_db:init: create database:%s, ex=%s" % 
                             (mySQLdb, e))

            sql = "USE %s" % mySQLdb
            try:
                self.cur.execute(sql)
            except Exception as e:
                logger.error("tnrm_db:init: use database:%s, ex=%s" % 
                             (mySQLdb, e))

            # sql = "CREATE TABLE %s (%s)" % (mySQLtbl, mySQLtable)
            sql = "CREATE TABLE IF NOT EXISTS %s (%s)" % (mySQLtbl, mySQLtable)
            try:
                self.cur.execute(sql)
                self.cur.execute("COMMIT")
            except Exception as e:
                logger.error("tnrm_db:init: create table:%s, ex=%s" % 
                             (mySQLtable, e))

            # sql = ("ALTER TABLE %s ADD INDEX (%s)" % 
            #        (mySQLtbl, "slice_urn, request_urn, nsi_id"))
            # self.cur.execute(sql)
            # logger.info("tnrm_db:init: create index:%s" % mySQLtable)

            self.con.close()
            self.con = None
            self.cur = None
        except Exception as e:
            logger.error("tnrm_db:init: ex=%s" % e)
예제 #20
0
    def __init__(self):
        try:
            self.tnrm = None
            self.con = MySQLdb.connect(host = mySQLhost, db = "",
                                       user = mySQLuser, passwd = mySQLpass, 
                                       charset = mySQLchar)

            self.cur = self.con.cursor()
            sql = "CREATE DATABASE IF NOT EXISTS %s" % mySQLdb
            # sql = "CREATE DATABASE %s" % mySQLdb
            try:
                self.cur.execute(sql)
            except Exception as e:
                logger.error("tnrm_db:init: create database:%s, ex=%s" % 
                             (mySQLdb, e))

            sql = "USE %s" % mySQLdb
            try:
                self.cur.execute(sql)
            except Exception as e:
                logger.error("tnrm_db:init: use database:%s, ex=%s" % 
                             (mySQLdb, e))

            # sql = "CREATE TABLE %s (%s)" % (mySQLtbl, mySQLtable)
            sql = "CREATE TABLE IF NOT EXISTS %s (%s)" % (mySQLtbl, mySQLtable)
            try:
                self.cur.execute(sql)
                self.cur.execute("COMMIT")
            except Exception as e:
                logger.error("tnrm_db:init: create table:%s, ex=%s" % 
                             (mySQLtable, e))

            # sql = ("ALTER TABLE %s ADD INDEX (%s)" % 
            #        (mySQLtbl, "slice_urn, request_urn, nsi_id"))
            # self.cur.execute(sql)
            # logger.info("tnrm_db:init: create index:%s" % mySQLtable)

            self.con.close()
            self.con = None
            self.cur = None
        except Exception as e:
            logger.error("tnrm_db:init: ex=%s" % e)
예제 #21
0
파일: db.py 프로젝트: ict-felix/stack
    def insert (self, resv):
        fmt = "INSERT INTO %s VALUES ("

        for i in range(0, mySQLtables_items):
            if i == (mySQLtables_items - 1):
                fmt += "\'%s\')"
            else:
                fmt += "\'%s\', "

        logger.info("tnrm_db:insert: fmt=%s" % fmt)

        trans_vlan = "0"
        if resv.trans_vlan is not None:
            trans_vlan = resv.trans_vlan

        error = resv.error
        if error is not None:
            error = error.replace("\"", "")
            error = error.replace("\'", "")

        sql = (fmt % (
                mySQLtbl,
                #1: slice_urn
                resv.slice_urn,
                #2: resv_urn
                resv.urn,
                #3: nsi_id
                resv.resv_id,
                #4: srcstp
                resv.src_if.felix_stp_id,
                #5: dststp
                resv.dst_if.felix_stp_id,
                #6: srcvlan
                int(resv.src_vlan),
                #7: dstvlan
                int(resv.dst_vlan),
                #8: transvlan
                int (trans_vlan),
                #9: geni_operational_status
                resv.ostatus,
                #10: geni_expires
                resv.end_time,
                #11: geni_allocation_status
                resv.astatus,
                #12: geni_sliver_urn
                resv.gid,
                #13: geni_urn
                resv.slice_urn,
                #14: geni_error
                error,
                #15: geni_action
                resv.action,
                #16: start_time
                resv.start_time,
                #16: manifest_node
                resv.manifest_node,
                #17: manifest_link
                resv.manifest_link 
                ))

        logger.info("tnrm_db:insert: sql=%s" % sql)
        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:insert: ex=%s" % e)
        finally:
            self.close()
예제 #22
0
    def insert (self, resv):
        fmt = "INSERT INTO %s VALUES ("

        for i in range(0, mySQLtables_items):
            if i == (mySQLtables_items - 1):
                fmt += "\'%s\')"
            else:
                fmt += "\'%s\', "

        logger.info("tnrm_db:insert: fmt=%s" % fmt)

        trans_vlan = "0"
        if resv.trans_vlan is not None:
            trans_vlan = resv.trans_vlan

        sql = (fmt % (
                mySQLtbl,
                #1: slice_urn
                resv.slice_urn,
                #2: resv_urn
                resv.urn,
                #3: nsi_id
                resv.resv_id,
                #4: srcstp
                resv.src_if.felix_stp_id,
                #5: dststp
                resv.dst_if.felix_stp_id,
                #6: srcvlan
                int(resv.src_vlan),
                #7: dstvlan
                int(resv.dst_vlan),
                #8: transvlan
                int (trans_vlan),
                #9: geni_operational_status
                resv.ostatus,
                #10: geni_expires
                resv.end_time,
                #11: geni_allocation_status
                resv.astatus,
                #12: geni_sliver_urn
                resv.gid,
                #13: geni_urn
                resv.slice_urn,
                #14: geni_error
                resv.error,
                #15: geni_action
                resv.action,
                #16: start_time
                resv.start_time,
                #16: manifest_node
                resv.manifest_node,
                #17: manifest_link
                resv.manifest_link 
                ))

        logger.info("tnrm_db:insert: sql=%s" % sql)
        try:
            self.open()
            self.cur.execute(sql)
            self.cur.execute("COMMIT")
        except Exception as e:
            logger.error("tnrm_db:insert: ex=%s" % e)
        finally:
            self.close()
예제 #23
0
파일: ovsgre.py 프로젝트: dana-i2cat/felix
    def release (self, resv):
        e = None
        ### release:nsiv2, poa geni_stop
        if resv is None or not dict_resvParameter.has_key(resv.resv_id):
            raise ManagerException("OvsManager:release", "The reservation is null.")
        
        resvp = dict_resvParameter[resv.resv_id]
        if resvp is None:
            raise ManagerException("OvsManager:release", "The ResvParameter is null.")

        if self.dict_isSetRule.has_key(resv.resv_id):
            if self.dict_isSetRule[resv.resv_id]:
                logger.info("delete flow rule here. %s?vlan=%s:%s?vlan=%s, gre?vlan=%s." % 
                            (resvp.s_stp, resvp.s_vlan, resvp.d_stp, resvp.d_vlan, resvp.t_vlan))

                try:
                    ### delete src
                    self.del_rule(self.src_if, resvp.s_vlan, resvp.t_vlan)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in delete rule: src_if=%s sevlan=%s, ofvlan=%s, ex=%s" % (self.src_if, resvp.s_vlan, resvp.t_vlan, ex))

                try:
                    ### delete dst
                    self.del_rule(self.dst_if, resvp.d_vlan, resvp.t_vlan)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in delete rule: dst_if=%s sevlan=%s, ofvlan=%s, ex=%s" % (self.dst_if, resvp.d_vlan, resvp.t_vlan, ex))

                self.dict_isSetRule[resv.resv_id] = False
                
            else:
                # already delete flow rule
                pass

        else:
            logger.info("OvsManager:release: This reservation (%s) does not have isSetRule." %
                        (resv.resv_id))

        if self.dict_used.has_key(resv.resv_id):
            del self.dict_used[resv.resv_id]
        else:
            logger.info("OvsManager:release: This reservation (%s) does not used this gre link." %
                        (resv.resv_id))

        if self.isSetup:
            if len(self.dict_used) > 0:
                logger.info("This gre link is shared other reservtion. Do not teardown now.")
            else:
                e = None
                ### teardown src->dst
                try:
                    self.teardown_tunnel(self.src_if, self.dst_if)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in teardown #1: src_if=%s, dst_if=%s ex=%s" % (self.src_if, self.dst_if, ex))

                ### teardown dst->src
                try:
                    self.teardown_tunnel(self.dst_if, self.src_if)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in teardown #2: src_if=%s, dst_if=%s ex=%s" % (self.dst_if, self.src_if, ex))

                self.isSetup = False
                self.isSetup = False

        else:
            logger.info("This link is already teardown.");
            
        if e is not None:
            raise e

        return resv.resv_id
예제 #24
0
    def release (self, resv):
        e = None
        ### release:nsiv2, poa geni_stop
        if resv is None or not dict_resvParameter.has_key(resv.resv_id):
            raise ManagerException("OvsManager:release", "The reservation is null.")
        
        resvp = dict_resvParameter[resv.resv_id]
        if resvp is None:
            raise ManagerException("OvsManager:release", "The ResvParameter is null.")

        if self.dict_isSetRule.has_key(resv.resv_id):
            if self.dict_isSetRule[resv.resv_id]:
                logger.info("delete flow rule here. %s?vlan=%s:%s?vlan=%s, gre?vlan=%s." % 
                            (resvp.s_stp, resvp.s_vlan, resvp.d_stp, resvp.d_vlan, resvp.t_vlan))

                try:
                    ### delete src
                    self.del_rule(self.src_if, resvp.s_vlan, resvp.t_vlan)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in delete rule: src_if=%s sevlan=%s, ofvlan=%s, ex=%s" % (self.src_if, resvp.s_vlan, resvp.t_vlan, ex))

                try:
                    ### delete dst
                    self.del_rule(self.dst_if, resvp.d_vlan, resvp.t_vlan)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in delete rule: dst_if=%s sevlan=%s, ofvlan=%s, ex=%s" % (self.dst_if, resvp.d_vlan, resvp.t_vlan, ex))

                self.dict_isSetRule[resv.resv_id] = False
                
            else:
                # already delete flow rule
                pass

        else:
            logger.info("OvsManager:release: This reservation (%s) does not have isSetRule." %
                        (resv.resv_id))

        if self.dict_used.has_key(resv.resv_id):
            del self.dict_used[resv.resv_id]
        else:
            logger.info("OvsManager:release: This reservation (%s) does not used this gre link." %
                        (resv.resv_id))

        if self.isSetup:
            if len(self.dict_used) > 0:
                logger.info("This gre link is shared other reservtion. Do not teardown now.")
            else:
                e = None
                ### teardown src->dst
                try:
                    self.teardown_tunnel(self.src_if, self.dst_if)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in teardown: src_if=%s, dst_if=%s ex=%s" % (self.src_if, self.dst_if, ex))

                ### teardown dst->src
                try:
                    self.teardown_tunnel(self.dst_if, self.src_if)
                except Exception as ex:
                    e = ex
                    logger.error("release: error in teardown: src_if=%s, dst_if=%s ex=%s" % (self.dst_if, self.src_if, ex))

                self.isSetup = False
                self.isSetup = False

        else:
            logger.info("This link is already teardown.");
            
        if e is not None:
            raise e

        return resv.resv_id