Apply general code clean-up and fixes

* Removed unused generate_uuid method.
* Changed print statement from 2.x style to 3.x.
* Updated scrapy to scrapy-python3 in requirements.txt for py3
  compatibility.

Change-Id: I7255a57c85cde105bf83bf6de5e779b71a09f8ee
Closes-Bug: #1576396
This commit is contained in:
Tin Lam 2016-05-02 21:26:17 -05:00
parent 4eff227d1e
commit 352c65725d
5 changed files with 13 additions and 20 deletions

View File

@ -3,5 +3,5 @@ jsonrpclib
netaddr
cliff
oslo.config>=1.6.0
scapy>=2.3.1
scapy-python3
pypcap

6
steth/stethclient/clients/neutron.py Normal file → Executable file
View File

@ -24,7 +24,7 @@ try:
from neutronclient.v2_0 import client
from neutronclient.common import exceptions
except ImportError:
print "Import neutronclient error. Please check it out."
print("Import neutronclient error. Please check it out.")
sys.exit()
@ -42,10 +42,10 @@ def get_port_attr(port_id, attr):
try:
res = client.show_port(port_id)
except exceptions.NeutronClientException:
print 'Port %s Not Found.' % port_id
print('Port %s Not Found.' % port_id)
return
except KeyError:
print 'Port attr: %s Not Found.' % attr
print('Port attr: %s Not Found.' % attr)
return
return res['port'][attr]

View File

@ -93,12 +93,12 @@ def check_ip_and_fill(agent_type, net_prefix):
d[name_prefix + node] = net_prefix + node
agent_type.update(d)
else:
print "%s is not IP!" % name_prefix + node
print("%s is not IP!" % name_prefix + node)
def validate_and_parse_network_types():
if not cfg.CONF.network_types:
print 'You must fill network_types in config file!'
print("You must fill network_types in config file!")
sys.exit()
for network_type in cfg.CONF.network_types:
net_type, net_interface, net_prefix = network_type.split(':')
@ -118,5 +118,6 @@ def validate_and_parse_network_types():
global STORAGE_INTERFACE
STORAGE_INTERFACE = net_interface
else:
print "Unkown network_types: %s" % network_type
print("Unkown network_types: %s" % network_type)
validate_and_parse_network_types()

View File

@ -75,7 +75,7 @@ def main(argv=sys.argv[1:]):
return StethShell(STETH_API_VERSION).run(
map(utils.safe_decode, argv))
except KeyboardInterrupt:
print "... terminating neutron client"
print("... terminating neutron client")
return 1
except Exception as e:
print(e)

View File

@ -69,15 +69,15 @@ class Logger():
@staticmethod
def log_normal(info):
print Logger.OKBLUE + info + Logger.ENDC
print(Logger.OKBLUE + info + Logger.ENDC)
@staticmethod
def log_high(info):
print Logger.OKGREEN + info + Logger.ENDC
print(Logger.OKGREEN + info + Logger.ENDC)
@staticmethod
def log_fail(info):
print Logger.FAIL + info + Logger.ENDC
print(Logger.FAIL + info + Logger.ENDC)
LISTEN_PORT = 9698
@ -134,15 +134,7 @@ def get_ip_from_agent(node, net_type):
else:
return 1
except Exception as e:
print "Can't get ip! Because: %s" % e
def generate_uuid():
"""Creates a random uuid string.
:returns: string
"""
return str(uuid.uuid4())
print("Can't get ip! Because: %s" % e)
def _format_uuid_string(string):