本文整理汇总了Python中tn_rm_delegate.logger.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_dev
def find_dev(self, src_if, dst_if):
urlbase = src_if.ryu_url
dpid = src_if.dpid
params = {}
params["ovsdb"] = src_if.ovsdb
if (src_if.gtype == "ovsgre"):
params["type"] = "gre"
else:
raise ManagerException("OvsManager:find_dev",
"Type (%s) is unknown, must be \"ovsgre\"." % (src_if.gtype))
params["local_ip"] = src_if.address
params["remote_ip"] = dst_if.address
logger.info("search gre link. url=%s, dpid=%s, ovsdb=%s, type=%s, local=%s, remote=%s" % (urlbase, dpid, params["ovsdb"], params["type"], params["local_ip"], params["remote_ip"]));
finds = ovsif.get_tunnel_info(urlbase, dpid, params)
if len(finds) == 0:
return (None, None)
elif len(finds) == 1:
for p in finds.keys():
logger.info("find gre link. dev=%s, ofport=%s" % (p, finds[p]))
return (p, finds[p])
else:
raise ManagerException("OvsManager:init", "Duplicate path is exist. %s" % finds)
示例2: add_rule
def add_rule(self, interface, sevlan, ofvlan):
urlbase = interface.ryu_url
dpid = interface.dpid
ofdev, ofport = interface.get_of(self.ovs_id)
params = {}
params["dpid"] = int(dpid, 16)
params["priority"] = OF_PRIORITY
params["idel_timeout"] = OF_TIMEOUT
params["hard_timeout"] = OF_TIMEOUT
params["cookie"] = OF_COOKIE
params["cookie_mask"] = OF_COOKIE_MASK
params["table_id"] = OF_TABLE_ID
params["flags"] = OF_FLAGS
matchs = {"in_port": interface.seport, "dl_vlan": sevlan}
params["match"] = matchs
# actions = [{"type":"SET_VLAN_VID", "vlan_vid": ofvlan}, {"type":"OUTPUT", "port": interface.ofport}]
actions = [{"type":"SET_VLAN_VID", "vlan_vid": ofvlan}, {"type":"OUTPUT", "port": ofport}]
params["actions"] = actions
rc = ovsif.add_flow(urlbase, params)
logger.info("add_rule: ret=%s" % rc)
# matchs = {"in_port": interface.ofport, "dl_vlan": ofvlan}
matchs = {"in_port": ofport, "dl_vlan": ofvlan}
params["match"] = matchs
actions = [{"type":"SET_VLAN_VID", "vlan_vid": sevlan}, {"type":"OUTPUT", "port": interface.seport}]
params["actions"] = actions
rc = ovsif.add_flow(urlbase, params)
logger.info("add_rule: ret=%s" % rc)
示例3: teardown_tunnel
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)
示例4: restart
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)
try:
is_datetime = datetime.datetime.strptime(d["start_time"], '%Y-%m-%d %H:%M:%S.%f')
except Exception as e:
try:
is_datetime = datetime.datetime.strptime(d["start_time"], '%Y-%m-%d %H:%M:%S')
except Exception as ee:
logger.error("restart db: bad start time format: %s" % d["start_time"])
continue
is_time = unix_time_sec(is_datetime)
try:
ie_datetime = datetime.datetime.strptime(d["geni_expires"], '%Y-%m-%d %H:%M:%S.%f')
except Exception as e:
try:
ie_datetime = datetime.datetime.strptime(d["geni_expires"], '%Y-%m-%d %H:%M:%S')
except Exception as ee:
logger.error("restart db: bad start time format: %s" % d["geni_expires"])
continue
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"])
示例5: update
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: get_port
def get_port(self, dev):
if self.dict_dev.has_key(dev):
port = self.dict_dev[dev]
logger.info("swManager: get_port: dev=%s, ofport=%s" % (dev, port))
return self.dict_dev[dev]
raise ManagerException("ovsgre:swManager:get_port", "This dev(%s) does not exist." % dev)
示例7: status
def status (self, resv):
if resv is None or not dict_resvParameter.has_key(resv.resv_id):
logger.info("ovsManager:status: resv_id=%s" % (resv.resv_id))
for key in dict_resvParameter:
logger.info("ovsManager:status: resvp=%s" % (key))
raise ManagerException("OvsManager:status", "The reservation is null.")
resvp = dict_resvParameter[resv.resv_id]
if resvp is None:
raise ManagerException("OvsManager:status", "The ResvParameter is null.")
rc = self.check_rule(self.src_if, resvp.s_vlan, resvp.t_vlan)
if not rc:
### This operation is caused we can not remove flow rules
### and teardown gre tunnel in a normal island.
# self.dict_isSetRule[resv.resv_id] = False
return False
rc = self.check_rule(self.dst_if, resvp.d_vlan, resvp.t_vlan)
if not rc:
### This operation is caused we can not remove flow rules
### and teardown gre tunnel in a normal island.
# self.dict_isSetRule[resv.resv_id] = False
return False
return True
示例8: get_swManager
def get_swManager (interface):
stp = interface.nsi_stp_id
key = interface.ryu_url + "/" + interface.dpid
logger.info("get_swManager: key=%s" % key)
if dict_swManager.has_key(key):
return dict_swManager[key]
logger.info("get_swManager: new swManager")
sw = swManager(interface)
dict_swManager[key] = sw
return sw
示例9: free
def free (self):
keep = None
try:
self.s_vman.free(self.s_vlan)
except Exception as ex:
logger.info("free: source vlan tun:%s" % (self.s_vlan))
keep = ex
try:
self.d_vman.free(self.d_vlan)
except Exception as ex:
logger.info("destination vlan tun:%s" % (self.d_vlan))
keep = ex
try:
self.t_vman.free(self.t_vlan)
except Exception as ex:
logger.info("tunnel vlan tun:%s" % (self.t_vlan))
keep = ex
if keep is not None:
raise keep
logger.info("freed vlan src:%s, dst:%s, tun:%s" % (self.s_vlan, self.d_vlan, self.t_vlan))
return (self.s_vlan, self.d_vlan, self.t_vlan)
示例10: delete
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: update_time
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()
示例12: del_rule
def del_rule(self, interface, sevlan, ofvlan):
urlbase = interface.ryu_url
dpid = interface.dpid
ofdev, ofport = interface.get_of(self.ovs_id)
params = {}
params["dpid"] = int(dpid, 16)
matchs = {"in_port": interface.seport, "dl_vlan": sevlan}
params["match"] = matchs
rc = ovsif.del_flow(urlbase, params)
logger.info("del_rule: ret=%s" % rc)
# matchs = {"in_port": interface.ofport, "dl_vlan": ofvlan}
matchs = {"in_port": ofport, "dl_vlan": ofvlan}
params["match"] = matchs
rc = ovsif.del_flow(urlbase, params)
logger.info("del_rule: ret=%s" % rc)
示例13: allocate
def allocate (self):
try:
self.s_vman.allocate(self.s_vlan)
except Exception as ex:
raise ex
try:
self.d_vman.allocate(self.d_vlan)
except Exception as ex:
self.s_vman.free(self.s_vlan)
raise ex
try:
self.t_vlan = self.t_vman.allocate(self.t_vlan)
except Exception as ex:
self.s_vman.free(self.s_vlan)
self.d_vman.free(self.d_vlan)
raise ex
logger.info("allocated vlan src:%s, dst:%s, tun:%s" % (self.s_vlan, self.d_vlan, self.t_vlan))
return (self.s_vlan, self.d_vlan, self.t_vlan)
示例14: search
def search (self):
for v in xrange(self.vlan_pos, self.vlan_max):
logger.info("ovsgre:vlanManager:search: vlan=%d" % (v))
if self.dict_vlans.has_key(str(v)):
continue
else:
self.vlan_pos = v + 1
if self.vlan_pos == self.vlan_max:
self.vlan_pos = self.vlan_min
return str(v)
for v in xrange(self.vlan_min, self.vlan_pos):
logger.info("ovsgre:vlanManager:search: vlan=%d" % (v))
if self.dict_vlans.has_key(str(v)):
continue
else:
self.vlan_pos = v + 1
if self.vlan_pos == self.vlan_max:
self.vlan_pos = self.vlan_min
return str(v)
raise ManagerException("proxy:allocate_vlan", "New vlan is not allocated.")
示例15: provision
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