Remove white space between print and ()
And in / doc/source/conf.py: print line, ---> print(line) Change-Id: I57d34ed1256f1573717292df64fdddd023d2bad2
This commit is contained in:
parent
573399ae64
commit
e07bf5cfda
68
devstack/tools/nsxv_cleanup.py
Executable file → Normal file
68
devstack/tools/nsxv_cleanup.py
Executable file → Normal file
@ -181,10 +181,10 @@ class VSMClient(object):
|
||||
paging_info = response.json()['dataPage']['pagingInfo']
|
||||
page_size = int(paging_info['pageSize'])
|
||||
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))
|
||||
pages = ceil(total_count, page_size)
|
||||
print ("Total pages: %s" % pages)
|
||||
print("Total pages: %s" % pages)
|
||||
for i in range(0, pages):
|
||||
start_index = page_size * i
|
||||
params = {'startindex': start_index}
|
||||
@ -195,16 +195,16 @@ class VSMClient(object):
|
||||
return lswitches
|
||||
|
||||
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()
|
||||
print ("There are total %s logical switches" % len(lswitches))
|
||||
print("There are total %s logical switches" % len(lswitches))
|
||||
for ls in lswitches:
|
||||
print ("\nDeleting logical switch %s (%s) ..." % (ls['name'],
|
||||
print("\nDeleting logical switch %s (%s) ..." % (ls['name'],
|
||||
ls['objectId']))
|
||||
endpoint = '/vdn/virtualwires/%s' % ls['objectId']
|
||||
response = self.delete(endpoint=endpoint)
|
||||
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):
|
||||
firewall_sections = []
|
||||
@ -218,23 +218,23 @@ class VSMClient(object):
|
||||
firewall_sections = [s for s in l3_sections if s['name'] !=
|
||||
"Default Section Layer3"]
|
||||
else:
|
||||
print ("ERROR: wrong response status code! Exiting...")
|
||||
print("ERROR: wrong response status code! Exiting...")
|
||||
sys.exit()
|
||||
|
||||
return firewall_sections
|
||||
|
||||
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()
|
||||
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:
|
||||
print ("\nDeleting firewall section %s (%s) ..." % (l3sec['name'],
|
||||
l3sec['id']))
|
||||
print("\nDeleting firewall section %s (%s) ..." % (l3sec['name'],
|
||||
l3sec['id']))
|
||||
endpoint = '/firewall/globalroot-0/config/layer3sections/%s' % \
|
||||
l3sec['id']
|
||||
response = self.delete(endpoint=endpoint)
|
||||
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):
|
||||
security_groups = []
|
||||
@ -245,7 +245,7 @@ class VSMClient(object):
|
||||
if response.status_code is 200:
|
||||
sg_all = response.json()
|
||||
else:
|
||||
print ("ERROR: wrong response status code! Exiting...")
|
||||
print("ERROR: wrong response status code! Exiting...")
|
||||
sys.exit()
|
||||
# Remove Activity Monitoring Data Collection, which is not
|
||||
# related to any security group created by OpenStack
|
||||
@ -254,17 +254,17 @@ class VSMClient(object):
|
||||
return security_groups
|
||||
|
||||
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()
|
||||
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:
|
||||
print ("\nDeleting security group %s (%s) ..." % (sg['name'],
|
||||
sg['objectId']))
|
||||
print("\nDeleting security group %s (%s) ..." % (sg['name'],
|
||||
sg['objectId']))
|
||||
endpoint = '/services/securitygroup/%s' % sg['objectId']
|
||||
params = {'force': self.force}
|
||||
response = self.delete(endpoint=endpoint, params=params)
|
||||
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):
|
||||
self.__set_api_version('4.0')
|
||||
@ -272,7 +272,7 @@ class VSMClient(object):
|
||||
# Query all spoofguard policies
|
||||
response = self.get()
|
||||
if response.status_code is not 200:
|
||||
print ("ERROR: Faield to get spoofguard policies")
|
||||
print("ERROR: Faield to get spoofguard policies")
|
||||
return
|
||||
sgp_all = response.json()
|
||||
policies = [sgp for sgp in sgp_all['policies'] if
|
||||
@ -280,15 +280,15 @@ class VSMClient(object):
|
||||
return policies
|
||||
|
||||
def cleanup_spoofguard_policies(self):
|
||||
print ("\n\nCleaning up spoofguard policies")
|
||||
print("\n\nCleaning up 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:
|
||||
print ("\nDeleting spoofguard policy %s (%s) ..." %
|
||||
(spg['name'], spg['policyId']))
|
||||
print("\nDeleting spoofguard policy %s (%s) ..." %
|
||||
(spg['name'], spg['policyId']))
|
||||
endpoint = '/services/spoofguard/policies/%s' % spg['policyId']
|
||||
response = self.delete(endpoint=endpoint)
|
||||
print ("Response code: %s" % response.status_code)
|
||||
print("Response code: %s" % response.status_code)
|
||||
|
||||
def query_all_edges(self):
|
||||
edges = []
|
||||
@ -299,10 +299,10 @@ class VSMClient(object):
|
||||
paging_info = response.json()['edgePage']['pagingInfo']
|
||||
page_size = int(paging_info['pageSize'])
|
||||
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))
|
||||
pages = ceil(total_count, page_size)
|
||||
print ("Total pages: %s" % pages)
|
||||
print("Total pages: %s" % pages)
|
||||
for i in range(0, pages):
|
||||
start_index = page_size * i
|
||||
params = {'startindex': start_index}
|
||||
@ -313,15 +313,15 @@ class VSMClient(object):
|
||||
return edges
|
||||
|
||||
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()
|
||||
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']
|
||||
response = self.delete(endpoint=endpoint)
|
||||
if response.status_code != 204:
|
||||
print ("ERROR: response status code %s" %
|
||||
response.status_code)
|
||||
print("ERROR: response status code %s" %
|
||||
response.status_code)
|
||||
|
||||
def cleanup_all(self):
|
||||
self.cleanup_firewall_section()
|
||||
@ -350,10 +350,10 @@ if __name__ == "__main__":
|
||||
parser.add_option("-f", "--force", dest="force", action="store_true",
|
||||
help="Force cleanup option")
|
||||
(options, args) = parser.parse_args()
|
||||
print ("vsm-ip: %s" % options.vsm_ip)
|
||||
print ("username: %s" % options.username)
|
||||
print ("password: %s" % options.password)
|
||||
print ("force: %s" % options.force)
|
||||
print("vsm-ip: %s" % options.vsm_ip)
|
||||
print("username: %s" % options.username)
|
||||
print("password: %s" % options.password)
|
||||
print("force: %s" % options.force)
|
||||
|
||||
# Get VSM REST client
|
||||
if options.force:
|
||||
|
@ -47,7 +47,7 @@ if os.path.isfile(PATH) and os.access(PATH, os.R_OK):
|
||||
if fnmatch.fnmatch(line, '*' + pattern[4:]):
|
||||
found = True
|
||||
if not found:
|
||||
print line,
|
||||
print(line)
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
@ -112,7 +112,7 @@ class ApiReplayClient(object):
|
||||
dest_sec_group['security_group_rules'])
|
||||
is False):
|
||||
try:
|
||||
print (
|
||||
print(
|
||||
self.dest_neutron.create_security_group_rule(
|
||||
{'security_group_rule': sg_rule}))
|
||||
except n_exc.Conflict:
|
||||
@ -129,16 +129,16 @@ class ApiReplayClient(object):
|
||||
try:
|
||||
new_sg = self.dest_neutron.create_security_group(
|
||||
{'security_group': sg})
|
||||
print ("Created security-group %s" % new_sg)
|
||||
print("Created security-group %s" % new_sg)
|
||||
except Exception as e:
|
||||
# TODO(arosen): improve exception handing here.
|
||||
print (e)
|
||||
print(e)
|
||||
|
||||
for sg_rule in sg_rules:
|
||||
try:
|
||||
rule = self.dest_neutron.create_security_group_rule(
|
||||
{'security_group_rule': sg_rule})
|
||||
print ("created security group rule %s " % rule['id'])
|
||||
print("created security group rule %s " % rule['id'])
|
||||
except Exception:
|
||||
# NOTE(arosen): when you create a default
|
||||
# security group it is automatically populated
|
||||
@ -162,7 +162,7 @@ class ApiReplayClient(object):
|
||||
body = self.drop_fields(router, drop_router_fields)
|
||||
new_router = (self.dest_neutron.create_router(
|
||||
{'router': body}))
|
||||
print ("created router %s" % new_router)
|
||||
print("created router %s" % new_router)
|
||||
|
||||
def migrate_networks_subnets_ports(self):
|
||||
"""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:
|
||||
created_net = self.dest_neutron.create_network(
|
||||
{'network': body})['network']
|
||||
print ("Created network: %s " % created_net)
|
||||
print("Created network: %s " % created_net)
|
||||
|
||||
for subnet_id in network['subnets']:
|
||||
subnet = self.find_subnet_by_id(subnet_id, source_subnets)
|
||||
@ -222,9 +222,9 @@ class ApiReplayClient(object):
|
||||
try:
|
||||
created_subnet = self.dest_neutron.create_subnet(
|
||||
{'subnet': body})['subnet']
|
||||
print ("Created subnet: " + created_subnet['id'])
|
||||
print("Created subnet: " + created_subnet['id'])
|
||||
except n_exc.BadRequest as e:
|
||||
print (e)
|
||||
print(e)
|
||||
# NOTE(arosen): this occurs here if you run the script
|
||||
# multiple times as we don't currently
|
||||
# perserve the subnet_id. Also, 409 would be a better
|
||||
@ -253,7 +253,7 @@ class ApiReplayClient(object):
|
||||
router_uplink = self.dest_neutron.update_router(
|
||||
port['device_id'], # router_id
|
||||
{'router': body})
|
||||
print ("Uplinked router %s" % router_uplink)
|
||||
print("Uplinked router %s" % router_uplink)
|
||||
continue
|
||||
|
||||
# Let the neutron dhcp-agent recreate this on it's own
|
||||
@ -270,18 +270,18 @@ class ApiReplayClient(object):
|
||||
self.dest_neutron.add_interface_router(
|
||||
port['device_id'],
|
||||
{'subnet_id': created_subnet['id']})
|
||||
print ("Uplinked router %s to subnet %s" %
|
||||
(port['device_id'], created_subnet['id']))
|
||||
print("Uplinked router %s to subnet %s" %
|
||||
(port['device_id'], created_subnet['id']))
|
||||
continue
|
||||
except n_exc.BadRequest as e:
|
||||
# NOTE(arosen): this occurs here if you run the
|
||||
# script multiple times as we don't track this.
|
||||
print (e)
|
||||
print(e)
|
||||
raise
|
||||
|
||||
created_port = self.dest_neutron.create_port(
|
||||
{'port': body})['port']
|
||||
print ("Created port: " + created_port['id'])
|
||||
print("Created port: " + created_port['id'])
|
||||
|
||||
def migrate_floatingips(self):
|
||||
"""Migrates floatingips from source to dest neutron."""
|
||||
@ -291,4 +291,4 @@ class ApiReplayClient(object):
|
||||
for source_fip in source_fips:
|
||||
body = self.drop_fields(source_fip, drop_fip_fields)
|
||||
fip = self.dest_neutron.create_floatingip({'floatingip': body})
|
||||
print ("Created floatingip %s" % fip)
|
||||
print("Created floatingip %s" % fip)
|
||||
|
Loading…
Reference in New Issue
Block a user