Remove white space between print and ()

And in / doc/source/conf.py:
print line, ---> print(line)

Change-Id: I57d34ed1256f1573717292df64fdddd023d2bad2
This commit is contained in:
yuyafei 2016-07-07 11:07:55 +08:00
parent 573399ae64
commit e07bf5cfda
3 changed files with 49 additions and 49 deletions

60
devstack/tools/nsxv_cleanup.py Executable file → Normal file
View File

@ -181,10 +181,10 @@ class VSMClient(object):
paging_info = response.json()['dataPage']['pagingInfo'] paging_info = response.json()['dataPage']['pagingInfo']
page_size = int(paging_info['pageSize']) page_size = int(paging_info['pageSize'])
total_count = int(paging_info['totalCount']) total_count = int(paging_info['totalCount'])
print ("There are total %s logical switches and page size is %s" % ( print("There are total %s logical switches and page size is %s" % (
total_count, page_size)) total_count, page_size))
pages = ceil(total_count, page_size) pages = ceil(total_count, page_size)
print ("Total pages: %s" % pages) print("Total pages: %s" % pages)
for i in range(0, pages): for i in range(0, pages):
start_index = page_size * i start_index = page_size * i
params = {'startindex': start_index} params = {'startindex': start_index}
@ -195,16 +195,16 @@ class VSMClient(object):
return lswitches return lswitches
def cleanup_logical_switch(self): def cleanup_logical_switch(self):
print ("Cleaning up logical switches on NSX manager") print("Cleaning up logical switches on NSX manager")
lswitches = self.query_all_logical_switches() lswitches = self.query_all_logical_switches()
print ("There are total %s logical switches" % len(lswitches)) print("There are total %s logical switches" % len(lswitches))
for ls in lswitches: for ls in lswitches:
print ("\nDeleting logical switch %s (%s) ..." % (ls['name'], print("\nDeleting logical switch %s (%s) ..." % (ls['name'],
ls['objectId'])) ls['objectId']))
endpoint = '/vdn/virtualwires/%s' % ls['objectId'] endpoint = '/vdn/virtualwires/%s' % ls['objectId']
response = self.delete(endpoint=endpoint) response = self.delete(endpoint=endpoint)
if response.status_code != 200: if response.status_code != 200:
print ("ERROR: response status code %s" % response.status_code) print("ERROR: response status code %s" % response.status_code)
def query_all_firewall_sections(self): def query_all_firewall_sections(self):
firewall_sections = [] firewall_sections = []
@ -218,23 +218,23 @@ class VSMClient(object):
firewall_sections = [s for s in l3_sections if s['name'] != firewall_sections = [s for s in l3_sections if s['name'] !=
"Default Section Layer3"] "Default Section Layer3"]
else: else:
print ("ERROR: wrong response status code! Exiting...") print("ERROR: wrong response status code! Exiting...")
sys.exit() sys.exit()
return firewall_sections return firewall_sections
def cleanup_firewall_section(self): def cleanup_firewall_section(self):
print ("\n\nCleaning up firewall sections on NSX manager") print("\n\nCleaning up firewall sections on NSX manager")
l3_sections = self.query_all_firewall_sections() l3_sections = self.query_all_firewall_sections()
print ("There are total %s firewall sections" % len(l3_sections)) print("There are total %s firewall sections" % len(l3_sections))
for l3sec in l3_sections: for l3sec in l3_sections:
print ("\nDeleting firewall section %s (%s) ..." % (l3sec['name'], print("\nDeleting firewall section %s (%s) ..." % (l3sec['name'],
l3sec['id'])) l3sec['id']))
endpoint = '/firewall/globalroot-0/config/layer3sections/%s' % \ endpoint = '/firewall/globalroot-0/config/layer3sections/%s' % \
l3sec['id'] l3sec['id']
response = self.delete(endpoint=endpoint) response = self.delete(endpoint=endpoint)
if response.status_code != 204: if response.status_code != 204:
print ("ERROR: response status code %s" % response.status_code) print("ERROR: response status code %s" % response.status_code)
def query_all_security_groups(self): def query_all_security_groups(self):
security_groups = [] security_groups = []
@ -245,7 +245,7 @@ class VSMClient(object):
if response.status_code is 200: if response.status_code is 200:
sg_all = response.json() sg_all = response.json()
else: else:
print ("ERROR: wrong response status code! Exiting...") print("ERROR: wrong response status code! Exiting...")
sys.exit() sys.exit()
# Remove Activity Monitoring Data Collection, which is not # Remove Activity Monitoring Data Collection, which is not
# related to any security group created by OpenStack # related to any security group created by OpenStack
@ -254,17 +254,17 @@ class VSMClient(object):
return security_groups return security_groups
def cleanup_security_group(self): def cleanup_security_group(self):
print ("\n\nCleaning up security groups on NSX manager") print("\n\nCleaning up security groups on NSX manager")
security_groups = self.query_all_security_groups() security_groups = self.query_all_security_groups()
print ("There are total %s security groups" % len(security_groups)) print("There are total %s security groups" % len(security_groups))
for sg in security_groups: for sg in security_groups:
print ("\nDeleting security group %s (%s) ..." % (sg['name'], print("\nDeleting security group %s (%s) ..." % (sg['name'],
sg['objectId'])) sg['objectId']))
endpoint = '/services/securitygroup/%s' % sg['objectId'] endpoint = '/services/securitygroup/%s' % sg['objectId']
params = {'force': self.force} params = {'force': self.force}
response = self.delete(endpoint=endpoint, params=params) response = self.delete(endpoint=endpoint, params=params)
if response.status_code != 200: if response.status_code != 200:
print ("ERROR: response status code %s" % response.status_code) print("ERROR: response status code %s" % response.status_code)
def query_all_spoofguard_policies(self): def query_all_spoofguard_policies(self):
self.__set_api_version('4.0') self.__set_api_version('4.0')
@ -272,7 +272,7 @@ class VSMClient(object):
# Query all spoofguard policies # Query all spoofguard policies
response = self.get() response = self.get()
if response.status_code is not 200: if response.status_code is not 200:
print ("ERROR: Faield to get spoofguard policies") print("ERROR: Faield to get spoofguard policies")
return return
sgp_all = response.json() sgp_all = response.json()
policies = [sgp for sgp in sgp_all['policies'] if policies = [sgp for sgp in sgp_all['policies'] if
@ -280,15 +280,15 @@ class VSMClient(object):
return policies return policies
def cleanup_spoofguard_policies(self): def cleanup_spoofguard_policies(self):
print ("\n\nCleaning up spoofguard policies") print("\n\nCleaning up spoofguard policies")
policies = self.query_all_spoofguard_policies() policies = self.query_all_spoofguard_policies()
print ("There are total %s policies" % len(policies)) print("There are total %s policies" % len(policies))
for spg in policies: for spg in policies:
print ("\nDeleting spoofguard policy %s (%s) ..." % print("\nDeleting spoofguard policy %s (%s) ..." %
(spg['name'], spg['policyId'])) (spg['name'], spg['policyId']))
endpoint = '/services/spoofguard/policies/%s' % spg['policyId'] endpoint = '/services/spoofguard/policies/%s' % spg['policyId']
response = self.delete(endpoint=endpoint) response = self.delete(endpoint=endpoint)
print ("Response code: %s" % response.status_code) print("Response code: %s" % response.status_code)
def query_all_edges(self): def query_all_edges(self):
edges = [] edges = []
@ -299,10 +299,10 @@ class VSMClient(object):
paging_info = response.json()['edgePage']['pagingInfo'] paging_info = response.json()['edgePage']['pagingInfo']
page_size = int(paging_info['pageSize']) page_size = int(paging_info['pageSize'])
total_count = int(paging_info['totalCount']) total_count = int(paging_info['totalCount'])
print ("There are total %s edges and page size is %s" % ( print("There are total %s edges and page size is %s" % (
total_count, page_size)) total_count, page_size))
pages = ceil(total_count, page_size) pages = ceil(total_count, page_size)
print ("Total pages: %s" % pages) print("Total pages: %s" % pages)
for i in range(0, pages): for i in range(0, pages):
start_index = page_size * i start_index = page_size * i
params = {'startindex': start_index} params = {'startindex': start_index}
@ -313,14 +313,14 @@ class VSMClient(object):
return edges return edges
def cleanup_edge(self): def cleanup_edge(self):
print ("\n\nCleaning up edges on NSX manager") print("\n\nCleaning up edges on NSX manager")
edges = self.query_all_edges() edges = self.query_all_edges()
for edge in edges: for edge in edges:
print ("\nDeleting edge %s (%s) ..." % (edge['name'], edge['id'])) print("\nDeleting edge %s (%s) ..." % (edge['name'], edge['id']))
endpoint = '/edges/%s' % edge['id'] endpoint = '/edges/%s' % edge['id']
response = self.delete(endpoint=endpoint) response = self.delete(endpoint=endpoint)
if response.status_code != 204: if response.status_code != 204:
print ("ERROR: response status code %s" % print("ERROR: response status code %s" %
response.status_code) response.status_code)
def cleanup_all(self): def cleanup_all(self):
@ -350,10 +350,10 @@ if __name__ == "__main__":
parser.add_option("-f", "--force", dest="force", action="store_true", parser.add_option("-f", "--force", dest="force", action="store_true",
help="Force cleanup option") help="Force cleanup option")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
print ("vsm-ip: %s" % options.vsm_ip) print("vsm-ip: %s" % options.vsm_ip)
print ("username: %s" % options.username) print("username: %s" % options.username)
print ("password: %s" % options.password) print("password: %s" % options.password)
print ("force: %s" % options.force) print("force: %s" % options.force)
# Get VSM REST client # Get VSM REST client
if options.force: if options.force:

View File

@ -47,7 +47,7 @@ if os.path.isfile(PATH) and os.access(PATH, os.R_OK):
if fnmatch.fnmatch(line, '*' + pattern[4:]): if fnmatch.fnmatch(line, '*' + pattern[4:]):
found = True found = True
if not found: if not found:
print line, print(line)
# The suffix of source filenames. # The suffix of source filenames.
source_suffix = '.rst' source_suffix = '.rst'

View File

@ -112,7 +112,7 @@ class ApiReplayClient(object):
dest_sec_group['security_group_rules']) dest_sec_group['security_group_rules'])
is False): is False):
try: try:
print ( print(
self.dest_neutron.create_security_group_rule( self.dest_neutron.create_security_group_rule(
{'security_group_rule': sg_rule})) {'security_group_rule': sg_rule}))
except n_exc.Conflict: except n_exc.Conflict:
@ -129,16 +129,16 @@ class ApiReplayClient(object):
try: try:
new_sg = self.dest_neutron.create_security_group( new_sg = self.dest_neutron.create_security_group(
{'security_group': sg}) {'security_group': sg})
print ("Created security-group %s" % new_sg) print("Created security-group %s" % new_sg)
except Exception as e: except Exception as e:
# TODO(arosen): improve exception handing here. # TODO(arosen): improve exception handing here.
print (e) print(e)
for sg_rule in sg_rules: for sg_rule in sg_rules:
try: try:
rule = self.dest_neutron.create_security_group_rule( rule = self.dest_neutron.create_security_group_rule(
{'security_group_rule': sg_rule}) {'security_group_rule': sg_rule})
print ("created security group rule %s " % rule['id']) print("created security group rule %s " % rule['id'])
except Exception: except Exception:
# NOTE(arosen): when you create a default # NOTE(arosen): when you create a default
# security group it is automatically populated # security group it is automatically populated
@ -162,7 +162,7 @@ class ApiReplayClient(object):
body = self.drop_fields(router, drop_router_fields) body = self.drop_fields(router, drop_router_fields)
new_router = (self.dest_neutron.create_router( new_router = (self.dest_neutron.create_router(
{'router': body})) {'router': body}))
print ("created router %s" % new_router) print("created router %s" % new_router)
def migrate_networks_subnets_ports(self): def migrate_networks_subnets_ports(self):
"""Migrates networks/ports/router-uplinks from src to dest neutron.""" """Migrates networks/ports/router-uplinks from src to dest neutron."""
@ -208,7 +208,7 @@ class ApiReplayClient(object):
if self.have_id(network['id'], dest_networks) is False: if self.have_id(network['id'], dest_networks) is False:
created_net = self.dest_neutron.create_network( created_net = self.dest_neutron.create_network(
{'network': body})['network'] {'network': body})['network']
print ("Created network: %s " % created_net) print("Created network: %s " % created_net)
for subnet_id in network['subnets']: for subnet_id in network['subnets']:
subnet = self.find_subnet_by_id(subnet_id, source_subnets) subnet = self.find_subnet_by_id(subnet_id, source_subnets)
@ -222,9 +222,9 @@ class ApiReplayClient(object):
try: try:
created_subnet = self.dest_neutron.create_subnet( created_subnet = self.dest_neutron.create_subnet(
{'subnet': body})['subnet'] {'subnet': body})['subnet']
print ("Created subnet: " + created_subnet['id']) print("Created subnet: " + created_subnet['id'])
except n_exc.BadRequest as e: except n_exc.BadRequest as e:
print (e) print(e)
# NOTE(arosen): this occurs here if you run the script # NOTE(arosen): this occurs here if you run the script
# multiple times as we don't currently # multiple times as we don't currently
# perserve the subnet_id. Also, 409 would be a better # perserve the subnet_id. Also, 409 would be a better
@ -253,7 +253,7 @@ class ApiReplayClient(object):
router_uplink = self.dest_neutron.update_router( router_uplink = self.dest_neutron.update_router(
port['device_id'], # router_id port['device_id'], # router_id
{'router': body}) {'router': body})
print ("Uplinked router %s" % router_uplink) print("Uplinked router %s" % router_uplink)
continue continue
# Let the neutron dhcp-agent recreate this on it's own # Let the neutron dhcp-agent recreate this on it's own
@ -270,18 +270,18 @@ class ApiReplayClient(object):
self.dest_neutron.add_interface_router( self.dest_neutron.add_interface_router(
port['device_id'], port['device_id'],
{'subnet_id': created_subnet['id']}) {'subnet_id': created_subnet['id']})
print ("Uplinked router %s to subnet %s" % print("Uplinked router %s to subnet %s" %
(port['device_id'], created_subnet['id'])) (port['device_id'], created_subnet['id']))
continue continue
except n_exc.BadRequest as e: except n_exc.BadRequest as e:
# NOTE(arosen): this occurs here if you run the # NOTE(arosen): this occurs here if you run the
# script multiple times as we don't track this. # script multiple times as we don't track this.
print (e) print(e)
raise raise
created_port = self.dest_neutron.create_port( created_port = self.dest_neutron.create_port(
{'port': body})['port'] {'port': body})['port']
print ("Created port: " + created_port['id']) print("Created port: " + created_port['id'])
def migrate_floatingips(self): def migrate_floatingips(self):
"""Migrates floatingips from source to dest neutron.""" """Migrates floatingips from source to dest neutron."""
@ -291,4 +291,4 @@ class ApiReplayClient(object):
for source_fip in source_fips: for source_fip in source_fips:
body = self.drop_fields(source_fip, drop_fip_fields) body = self.drop_fields(source_fip, drop_fip_fields)
fip = self.dest_neutron.create_floatingip({'floatingip': body}) fip = self.dest_neutron.create_floatingip({'floatingip': body})
print ("Created floatingip %s" % fip) print("Created floatingip %s" % fip)