Merge "use the fact that empty sequences are false"
This commit is contained in:
@@ -72,7 +72,7 @@ class HyperVUtils(object):
|
||||
def _get_vnic_settings(self, vnic_name):
|
||||
vnic_settings = self._conn.Msvm_SyntheticEthernetPortSettingData(
|
||||
ElementName=vnic_name)
|
||||
if not len(vnic_settings):
|
||||
if not vnic_settings:
|
||||
raise HyperVException(msg=_('Vnic not found: %s') % vnic_name)
|
||||
return vnic_settings[0]
|
||||
|
||||
@@ -185,7 +185,7 @@ class HyperVUtils(object):
|
||||
|
||||
def _get_vswitch(self, vswitch_name):
|
||||
vswitch = self._conn.Msvm_VirtualSwitch(ElementName=vswitch_name)
|
||||
if not len(vswitch):
|
||||
if not vswitch:
|
||||
raise HyperVException(msg=_('VSwitch not found: %s') %
|
||||
vswitch_name)
|
||||
return vswitch[0]
|
||||
@@ -196,7 +196,7 @@ class HyperVUtils(object):
|
||||
for vswitch_port in vswitch_ports:
|
||||
lan_endpoints = vswitch_port.associators(
|
||||
wmi_result_class='Msvm_SwitchLanEndpoint')
|
||||
if len(lan_endpoints):
|
||||
if lan_endpoints:
|
||||
ext_port = lan_endpoints[0].associators(
|
||||
wmi_result_class='Msvm_ExternalEthernetPort')
|
||||
if ext_port:
|
||||
|
||||
@@ -354,7 +354,7 @@ class NECPluginV2(nec_plugin_base.NECPluginV2Base,
|
||||
# delete unnessary ofc_tenant
|
||||
filters = dict(tenant_id=[tenant_id])
|
||||
nets = super(NECPluginV2, self).get_networks(context, filters=filters)
|
||||
if len(nets) == 0:
|
||||
if not nets:
|
||||
try:
|
||||
self.ofc.delete_ofc_tenant(context, tenant_id)
|
||||
except (nexc.OFCException, nexc.OFCConsistencyBroken) as exc:
|
||||
|
||||
@@ -1048,7 +1048,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
except q_exc.NetworkNotFound:
|
||||
continue
|
||||
pairs.append((c, lswitches))
|
||||
if len(pairs) == 0:
|
||||
if not pairs:
|
||||
raise q_exc.NetworkNotFound(net_id=netw_id)
|
||||
LOG.debug(_("Returning pairs for network: %s"), pairs)
|
||||
return pairs
|
||||
@@ -1172,7 +1172,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
|
||||
# do not make the case in which switches are found in NVP
|
||||
# but not in Quantum catastrophic.
|
||||
if len(nvp_lswitches):
|
||||
if nvp_lswitches:
|
||||
LOG.warning(_("Found %s logical switches not bound "
|
||||
"to Quantum networks. Quantum and NVP are "
|
||||
"potentially out of sync"), len(nvp_lswitches))
|
||||
@@ -1304,7 +1304,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
lports.append(quantum_lport)
|
||||
# do not make the case in which ports are found in NVP
|
||||
# but not in Quantum catastrophic.
|
||||
if len(nvp_lports):
|
||||
if nvp_lports:
|
||||
LOG.warning(_("Found %s logical ports not bound "
|
||||
"to Quantum ports. Quantum and NVP are "
|
||||
"potentially out of sync"), len(nvp_lports))
|
||||
@@ -1561,7 +1561,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
msg = (_("Network '%s' is not a valid external "
|
||||
"network") % network_id)
|
||||
raise q_exc.BadRequest(resource='router', msg=msg)
|
||||
if len(ext_net.subnets):
|
||||
if ext_net.subnets:
|
||||
ext_subnet = ext_net.subnets[0]
|
||||
nexthop = ext_subnet.gateway_ip
|
||||
cluster = self._find_target_cluster(router)
|
||||
@@ -1610,7 +1610,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
msg = (_("Network '%s' is not a valid external "
|
||||
"network") % network_id)
|
||||
raise q_exc.BadRequest(resource='router', msg=msg)
|
||||
if len(ext_net.subnets):
|
||||
if ext_net.subnets:
|
||||
ext_subnet = ext_net.subnets[0]
|
||||
nexthop = ext_subnet.gateway_ip
|
||||
cluster = self._find_target_cluster(router)
|
||||
@@ -1721,7 +1721,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
|
||||
# do not make the case in which routers are found in NVP
|
||||
# but not in Quantum catastrophic.
|
||||
if len(nvp_lrouters):
|
||||
if nvp_lrouters:
|
||||
LOG.warning(_("Found %s logical routers not bound "
|
||||
"to Quantum routers. Quantum and NVP are "
|
||||
"potentially out of sync"), len(nvp_lrouters))
|
||||
@@ -1748,7 +1748,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
results = nvplib.query_lswitch_lports(
|
||||
cluster, '*',
|
||||
filters={'tag': port_id, 'tag_scope': 'q_port_id'})
|
||||
if len(results):
|
||||
if results:
|
||||
ls_port = results[0]
|
||||
else:
|
||||
raise nvp_exc.NvpPluginException(
|
||||
@@ -1825,7 +1825,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
cluster, '*', relations="LogicalPortAttachment",
|
||||
filters={'tag': port_id, 'tag_scope': 'q_port_id'})
|
||||
lrouter_port_id = None
|
||||
if len(results):
|
||||
if results:
|
||||
lport = results[0]
|
||||
attachment_data = lport['_relations'].get('LogicalPortAttachment')
|
||||
lrouter_port_id = (attachment_data and
|
||||
|
||||
@@ -95,7 +95,7 @@ def main(argv):
|
||||
print "NVP Default Cluster Name %s" % nvp_opts.default_cluster_name
|
||||
|
||||
print "-----------Cluster Options--------------------"
|
||||
if not len(clusters_opts):
|
||||
if not clusters_opts:
|
||||
print "No NVP Clusters detected in nvp.ini!"
|
||||
exit(1)
|
||||
clusters, default_cluster = QuantumPlugin.parse_clusters_opts(
|
||||
|
||||
@@ -137,7 +137,7 @@ def _build_uri_path(resource,
|
||||
params.extend(['%s=%s' % (k, v) for (k, v) in filters.iteritems()])
|
||||
uri_path = "%s/%s" % (URI_PREFIX, res_path)
|
||||
non_empty_params = [x for x in params if x is not None]
|
||||
if len(non_empty_params):
|
||||
if non_empty_params:
|
||||
query_string = '&'.join(non_empty_params)
|
||||
if query_string:
|
||||
uri_path += "?%s" % query_string
|
||||
@@ -1127,7 +1127,7 @@ def update_security_group_rules(cluster, spid, rules):
|
||||
'port_range_max': constants.DHCP_RESPONSE_PORT,
|
||||
'ip_prefix': '0.0.0.0/0'})
|
||||
# If there are no ingress rules add bunk rule to drop all ingress traffic
|
||||
if not len(rules['logical_port_ingress_rules']):
|
||||
if not rules['logical_port_ingress_rules']:
|
||||
rules['logical_port_ingress_rules'].append(
|
||||
{'ethertype': 'IPv4', 'ip_prefix': '127.0.0.1/32'})
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user