Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix id_get num bug

  • Loading branch information...
commit ccc3d78ed853564a563a1613f420ccd43dd6b598 1 parent adc21fb
@hokerffb hokerffb authored
Showing with 10 additions and 11 deletions.
  1. +1 −1  bin/kanyun
  2. +9 −10 kanyun/server/data_server.py
View
2  bin/kanyun
@@ -63,7 +63,7 @@ def vminfo(app, instanceid):
def show_iptables_cmd(instance_id, instance_ip, public_interface):
cmd1 = """sudo iptables -t filter -N nova-compute-f-inst-%s"""
cmd2 = """sudo iptables -I FORWARD -s %s -j nova-compute-f-inst-%s"""
- cmd3 = """sudo iptables -A nova-compute-f-inst-%s -o %s -m comment --comment "%s %s accounting rule" """
+ cmd3 = """sudo iptables -A nova-compute-f-inst-%s -o %s -m comment --comment " %s %s accounting rule " """
print cmd1 % instance_id
print cmd2 % (instance_ip, instance_id)
print cmd3 % (instance_id, public_interface, instance_id, instance_ip)
View
19 kanyun/server/data_server.py
@@ -119,17 +119,20 @@ def list_workers():
def get_prefix(data, s='@'):
try:
- prefix = a.split(s)[0]
+ prefix = data.split(s)[0]
return prefix
- except:
- pass
+ except Exception, e:
+ print Exception, e
return None
def isnum_prefix(data):
ret = get_prefix(data, "@")
-
- return not ret is None
+ try:
+ _ = int(ret)
+ except:
+ return False
+ return True
def check_id(data):
# 1.test format
@@ -141,14 +144,10 @@ def check_id(data):
id = get_prefix(data, "@")
instance_uuid = tool.get_uuid_by_id(int(id))
else:
- instance_uuid = None
+ instance_uuid = data
# # 2-3 is '10.0.0.1' format
# instance_uuid = tool.get_uuid_by_ip(data_id)
-# if instance_uuid is None:
-# instance_uuid = data_id
-# print "Invalid instance_id format:", data_id
-
return instance_uuid
def plugin_heartbeat(app, db, data):
Please sign in to comment.
Something went wrong with that request. Please try again.