Use six.iterkeys(x) instead of x.keys()

Implements: partial blueprint heat-python34-support
Change-Id: I6f1c3091ca65dbef0f36bd6ba7f7fcbf77ff2e40
changes/93/176293/5
Tetiana Lashchova 8 years ago
parent 15f813b01f
commit 4ace95ad47
  1. 5
      contrib/heat_mistral/heat_mistral/resources/workflow.py
  2. 8
      contrib/rackspace/rackspace/resources/cloud_loadbalancer.py
  3. 20
      contrib/rackspace/rackspace/tests/test_cloud_loadbalancer.py
  4. 8
      doc/source/ext/resources.py
  5. 4
      heat/api/cloudwatch/watch.py
  6. 3
      heat/api/openstack/v1/actions.py
  7. 2
      heat/common/serializers.py
  8. 6
      heat/engine/api.py
  9. 2
      heat/engine/cfn/functions.py
  10. 3
      heat/engine/clients/os/nova.py
  11. 4
      heat/engine/environment.py
  12. 2
      heat/engine/hot/functions.py
  13. 2
      heat/engine/hot/template.py
  14. 2
      heat/engine/nova_utils.py
  15. 2
      heat/engine/parameters.py
  16. 4
      heat/engine/resource.py
  17. 3
      heat/engine/resources/openstack/heat/software_deployment.py
  18. 4
      heat/engine/resources/openstack/neutron/loadbalancer.py
  19. 10
      heat/engine/resources/openstack/neutron/network_gateway.py
  20. 10
      heat/engine/resources/openstack/neutron/neutron.py
  21. 4
      heat/engine/resources/openstack/neutron/provider_net.py
  22. 2
      heat/engine/resources/wait_condition.py
  23. 2
      heat/engine/service.py
  24. 3
      heat/engine/stack.py
  25. 7
      heat/engine/template.py
  26. 2
      heat/openstack/common/policy.py
  27. 3
      heat/scaling/cooldown.py
  28. 2
      heat/tests/db/test_migrations.py
  29. 33
      heat/tests/nova/fakes.py
  30. 3
      heat/tests/test_api_cloudwatch.py
  31. 8
      heat/tests/test_engine_api_utils.py
  32. 6
      heat/tests/test_hot.py
  33. 3
      heat/tests/test_server.py
  34. 3
      heat/tests/test_signal.py
  35. 7
      heat/tests/test_template.py
  36. 2
      heat/tests/test_template_format.py
  37. 5
      heat/tests/test_user.py

@ -203,7 +203,7 @@ class Workflow(signal_responder.SignalResponder,
raise exception.StackValidationFailed(
error=_('Signal data error'),
message=message)
for key in input_value.keys():
for key in six.iterkeys(input_value):
if (self.properties.get(self.INPUT) is None
or key not in self.properties.get(self.INPUT)):
message = _('Unknown input %s') % key
@ -291,7 +291,8 @@ class Workflow(signal_responder.SignalResponder,
defn_name: {self.TYPE: props[self.TYPE],
self.DESCRIPTION: props[self.DESCRIPTION],
self.OUTPUT: props[self.OUTPUT],
self.INPUT: props[self.INPUT].keys(),
self.INPUT: list(six.iterkeys(
props[self.INPUT])),
self.TASKS: {}}}
for task in self.build_tasks(props):

@ -607,7 +607,7 @@ class CloudLoadBalancer(resource.Resource):
checkers.extend(self._update_nodes(lb, updated_nodes))
updated_props = {}
for prop in prop_diff.keys():
for prop in six.iterkeys(prop_diff):
if prop in self.LB_UPDATE_PROPS:
updated_props[prop] = prop_diff[prop]
if updated_props:
@ -674,8 +674,8 @@ class CloudLoadBalancer(resource.Resource):
node[self.NODE_PORT]), node)
for node in diff_nodes)
old_set = set(old.keys())
new_set = set(new.keys())
old_set = set(six.iterkeys(old))
new_set = set(six.iterkeys(new))
deleted = old_set.difference(new_set)
added = new_set.difference(old_set)
@ -701,7 +701,7 @@ class CloudLoadBalancer(resource.Resource):
# Update nodes that have been changed
for node in updated:
node_changed = False
for attribute in new[node].keys():
for attribute in six.iterkeys(new[node]):
new_value = new[node][attribute]
if new_value and new_value != getattr(old[node], attribute):
node_changed = True

@ -1029,7 +1029,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_health_monitor_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
hm = {'type': "HTTP", 'delay': 10, 'timeout': 10,
'attemptsBeforeDeactivation': 4, 'path': "/",
'statusRegex': "^[234][0-9][0-9]$", 'bodyRegex': ".* testing .*",
@ -1081,7 +1081,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_session_persistence_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties'][
'sessionPersistence'] = "SOURCE_IP"
expected_body = copy.deepcopy(self.expected_body)
@ -1133,7 +1133,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_ssl_termination_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties']['sslTermination'] = {
'securePort': 443, 'privatekey': private_key, 'certificate': cert,
'secureTrafficOnly': False}
@ -1184,7 +1184,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_metadata_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties']['metadata'] = {
'a': 1, 'b': 2}
expected_body = copy.deepcopy(self.expected_body)
@ -1239,7 +1239,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_errorpage_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
error_page = (
'<html><head><title>Service Unavailable</title></head><body><h2>'
'Service Unavailable</h2>The service is unavailable</body></html>')
@ -1289,7 +1289,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_connection_logging_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties'][
'connectionLogging'] = True
expected_body = copy.deepcopy(self.expected_body)
@ -1316,7 +1316,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_connection_logging_disable(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties'][
'connectionLogging'] = True
expected_body = copy.deepcopy(self.expected_body)
@ -1366,7 +1366,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_connection_throttle_delete(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties'][
'connectionThrottle'] = {'maxConnections': 1000}
expected_body = copy.deepcopy(self.expected_body)
@ -1417,7 +1417,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_content_caching_deleted(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties'][
'contentCaching'] = 'ENABLED'
# Enabling the content cache is done post-creation, so no need
@ -1445,7 +1445,7 @@ class LoadBalancerTest(common.HeatTestCase):
def test_update_content_caching_disable(self):
template = copy.deepcopy(self.lb_template)
lb_name = template['Resources'].keys()[0]
lb_name = list(six.iterkeys(template['Resources']))[0]
template['Resources'][lb_name]['Properties'][
'contentCaching'] = 'ENABLED'
# Enabling the content cache is done post-creation, so no need

@ -137,7 +137,7 @@ class ResourcePages(compat.Directive):
def contribute_hot_syntax(self, parent):
section = self._section(parent, _('HOT Syntax'), '%s-hot')
props = []
for prop_key in sorted(self.props_schemata.keys()):
for prop_key in sorted(six.iterkeys(self.props_schemata)):
prop = self.props_schemata[prop_key]
if (prop.implemented
and prop.support_status.status == support.SUPPORTED):
@ -162,7 +162,7 @@ resources:
def contribute_yaml_syntax(self, parent):
section = self._section(parent, _('YAML Syntax'), '%s-yaml')
props = []
for prop_key in sorted(self.props_schemata.keys()):
for prop_key in sorted(six.iterkeys(self.props_schemata)):
prop = self.props_schemata[prop_key]
if (prop.implemented
and prop.support_status.status == support.SUPPORTED):
@ -188,7 +188,7 @@ Resources:
section = self._section(parent, _('JSON Syntax'), '%s-json')
props = []
for prop_key in sorted(self.props_schemata.keys()):
for prop_key in sorted(six.iterkeys(self.props_schemata)):
prop = self.props_schemata[prop_key]
if (prop.implemented
and prop.support_status.status == support.SUPPORTED):
@ -352,7 +352,7 @@ def _filter_resources(prefix=None, path=None):
return path is None or cls.__module__.startswith(path)
filtered_resources = {}
for name in sorted(all_resources.keys()):
for name in sorted(six.iterkeys(all_resources)):
if prefix_match(name):
for cls in all_resources.get(name):
if path_match(cls):

@ -66,7 +66,7 @@ class WatchController(object):
"""
newdims = []
for count, d in enumerate(dims, 1):
for key in d.keys():
for key in six.iterkeys(d):
newdims.append({'Name': key, 'Value': d[key]})
return newdims
@ -302,7 +302,7 @@ class WatchController(object):
msg = _('Invalid state %(state)s, '
'expecting one of %(expect)s') % {
'state': state,
'expect': state_map.keys()}
'expect': list(six.iterkeys(state_map))}
LOG.error(msg)
return exception.HeatInvalidParameterValueError(msg)

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from webob import exc
from heat.api.openstack.v1 import util
@ -51,7 +52,7 @@ class ActionController(object):
if len(body) > 1:
raise exc.HTTPBadRequest(_("Multiple actions specified"))
ac = body.keys()[0]
ac = next(six.iterkeys(body))
if ac not in self.ACTIONS:
raise exc.HTTPBadRequest(_("Invalid action %s specified") % ac)

@ -77,7 +77,7 @@ class XMLResponseSerializer(object):
def to_xml(self, data):
# Assumption : root node is dict with single key
root = data.keys()[0]
root = next(six.iterkeys(data))
eltree = etree.Element(root)
self.object_to_element(data.get(root), eltree)
response = etree.tostring(eltree)

@ -152,7 +152,7 @@ def format_resource_attributes(resource, with_attr=None):
return None
resolver = resource.attributes
if 'show' in resolver.keys():
if 'show' in six.iterkeys(resolver):
show_attr = resolver['show']
if isinstance(show_attr, collections.Mapping):
resolver = show_attr
@ -160,7 +160,7 @@ def format_resource_attributes(resource, with_attr=None):
if not with_attr:
with_attr = []
attributes = set(resolver.keys() + with_attr)
attributes = set(list(six.iterkeys(resolver)) + with_attr)
return dict((attr, resolve(attr, resolver))
for attr in attributes)
@ -173,7 +173,7 @@ def format_resource_properties(resource):
return None
return dict((prop, get_property(prop))
for prop in resource.properties_schema.keys())
for prop in six.iterkeys(resource.properties_schema))
def format_stack_resource(resource, detail=True, with_props=False,

@ -188,7 +188,7 @@ class GetAtt(function.Function):
res = self._resource()
attr = function.resolve(self._attribute)
if (type(res).FnGetAtt == resource.Resource.FnGetAtt and
attr not in res.attributes_schema.keys()):
attr not in six.iterkeys(res.attributes_schema)):
raise exception.InvalidTemplateAttribute(
resource=self._resource_name, key=attr)

@ -396,7 +396,8 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
"""Delete/Add the metadata in nova as needed."""
metadata = self.meta_serialize(metadata)
current_md = server.metadata
to_del = [key for key in current_md.keys() if key not in metadata]
to_del = [key for key in six.iterkeys(current_md)
if key not in metadata]
client = self.client()
if len(to_del) > 0:
client.servers.delete_meta(server, to_del)

@ -228,7 +228,7 @@ class ResourceRegistry(object):
if info is None:
if name.endswith('*'):
# delete all matching entries.
for res_name in registry.keys():
for res_name in list(six.iterkeys(registry)):
if (isinstance(registry[res_name], ResourceInfo) and
res_name.startswith(name[:-1])):
LOG.warn(_LW('Removing %(item)s from %(path)s'), {
@ -348,7 +348,7 @@ class ResourceRegistry(object):
# handle: "OS::*" -> "Dreamhost::*"
def is_a_glob(resource_type):
return resource_type.endswith('*')
globs = itertools.ifilter(is_a_glob, self._registry.keys())
globs = itertools.ifilter(is_a_glob, six.iterkeys(self._registry))
for pattern in globs:
if self._registry[pattern].matches(resource_type):
yield self._registry[pattern]

@ -335,7 +335,7 @@ class Repeat(function.Function):
def result(self):
for_each = function.resolve(self._for_each)
keys = for_each.keys()
keys = list(six.iterkeys(for_each))
lists = [for_each[key] for key in keys]
template = function.resolve(self._template)
return [self._do_replacement(keys, items, template)

@ -172,7 +172,7 @@ class HOTemplate20130523(template.Template):
def get_section_name(self, section):
cfn_to_hot_attrs = dict(
zip(six.itervalues(self._RESOURCE_HOT_TO_CFN_ATTRS),
self._RESOURCE_HOT_TO_CFN_ATTRS.keys()))
six.iterkeys(self._RESOURCE_HOT_TO_CFN_ATTRS)))
return cfn_to_hot_attrs.get(section, section)
def _translate_outputs(self, outputs):

@ -364,7 +364,7 @@ def meta_update(client, server, metadata):
'Use self.client_plugin("nova").meta_update')
metadata = meta_serialize(metadata)
current_md = server.metadata
to_del = [key for key in current_md.keys() if key not in metadata]
to_del = [key for key in six.iterkeys(current_md) if key not in metadata]
if len(to_del) > 0:
client.servers.delete_meta(server, to_del)

@ -536,7 +536,7 @@ class Parameters(collections.Mapping):
def _validate_tmpl_parameters(self):
param = None
for key in self.tmpl.t.keys():
for key in six.iterkeys(self.tmpl.t):
if key == 'Parameters' or key == 'parameters':
param = key
break

@ -349,8 +349,8 @@ class Resource(object):
None.
'''
# Create a set containing the keys in both current and update template
template_keys = set(before.keys())
template_keys.update(set(after.keys()))
template_keys = set(six.iterkeys(before))
template_keys.update(set(six.iterkeys(after)))
# Create a set of keys which differ (or are missing/added)
changed_keys_set = set([k for k in template_keys

@ -12,6 +12,7 @@
# under the License.
import copy
import six
import uuid
from oslo_config import cfg
@ -631,7 +632,7 @@ class SoftwareDeployments(resource_group.ResourceGroup):
}
def _resource_names(self):
return self.properties.get(self.SERVERS, {}).keys()
return six.iterkeys(self.properties.get(self.SERVERS, {}))
def _do_prop_replace(self, res_name, res_def_template):
res_def = copy.deepcopy(res_def_template)

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
@ -695,7 +697,7 @@ class LoadBalancer(resource.Resource):
new_props[self.MEMBERS] is not None)):
members = set(new_props[self.MEMBERS] or [])
rd_members = self.data()
old_members = set(rd_members.keys())
old_members = set(six.iterkeys(rd_members))
client = self.neutron()
for member in old_members - members:
member_id = rd_members[member]

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
@ -184,7 +186,7 @@ class NetworkGateway(neutron.NeutronResource):
for connection in connections:
self.client_plugin().resolve_network(
connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
if self.NETWORK in six.iterkeys(connection):
connection.pop(self.NETWORK)
self.neutron().connect_network_gateway(
ret['id'], connection
@ -200,7 +202,7 @@ class NetworkGateway(neutron.NeutronResource):
try:
self.client_plugin().resolve_network(
connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
if self.NETWORK in six.iterkeys(connection):
connection.pop(self.NETWORK)
client.disconnect_network_gateway(
self.resource_id, connection
@ -236,7 +238,7 @@ class NetworkGateway(neutron.NeutronResource):
try:
self.client_plugin().resolve_network(
connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
if self.NETWORK in six.iterkeys(connection):
connection.pop(self.NETWORK)
self.neutron().disconnect_network_gateway(
self.resource_id, connection
@ -246,7 +248,7 @@ class NetworkGateway(neutron.NeutronResource):
for connection in connections:
self.client_plugin().resolve_network(
connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
if self.NETWORK in six.iterkeys(connection):
connection.pop(self.NETWORK)
self.neutron().connect_network_gateway(
self.resource_id, connection

@ -43,11 +43,11 @@ class NeutronResource(resource.Resource):
Also ensures that shared and tenant_id is not specified
in value_specs.
'''
if 'value_specs' in properties.keys():
if 'value_specs' in six.iterkeys(properties):
vs = properties.get('value_specs')
banned_keys = set(['shared', 'tenant_id']).union(
properties.keys())
for k in banned_keys.intersection(vs.keys()):
six.iterkeys(properties))
for k in banned_keys.intersection(six.iterkeys(vs)):
return '%s not allowed in value_specs' % k
@staticmethod
@ -78,10 +78,10 @@ class NeutronResource(resource.Resource):
props = dict((k, v) for k, v in properties.items()
if v is not None and k != 'value_specs')
if 'name' in properties.keys():
if 'name' in six.iterkeys(properties):
props.setdefault('name', name)
if 'value_specs' in properties.keys():
if 'value_specs' in six.iterkeys(properties):
props.update(properties.get('value_specs'))
return props

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
@ -106,7 +108,7 @@ class ProviderNet(net.Net):
self.add_provider_extension(props, self.PROVIDER_PHYSICAL_NETWORK)
if self.PROVIDER_SEGMENTATION_ID in props.keys():
if self.PROVIDER_SEGMENTATION_ID in six.iterkeys(props):
self.add_provider_extension(props, self.PROVIDER_SEGMENTATION_ID)
def handle_create(self):

@ -49,7 +49,7 @@ class BaseWaitConditionHandle(signal_responder.SignalResponder):
return status in self.WAIT_STATUSES
def _metadata_format_ok(self, metadata):
if sorted(tuple(metadata.keys())) == sorted(self.METADATA_KEYS):
if sorted(tuple(six.iterkeys(metadata))) == sorted(self.METADATA_KEYS):
return self._status_ok(metadata[self.STATUS])
def handle_signal(self, metadata=None):

@ -377,7 +377,7 @@ class EngineService(service.Service):
self.engine_id)
# Wait for all active threads to be finished
for stack_id in self.thread_group_mgr.groups.keys():
for stack_id in six.iterkeys(self.thread_group_mgr.groups):
# Ignore dummy service task
if stack_id == cfg.CONF.periodic_interval:
continue

@ -613,7 +613,8 @@ class Stack(collections.Mapping):
self.t.validate_resource_definitions(self)
# Check duplicate names between parameters and resources
dup_names = set(self.parameters.keys()) & set(self.keys())
dup_names = (set(six.iterkeys(self.parameters)) &
set(six.iterkeys(self)))
if dup_names:
LOG.debug("Duplicate names %s" % dup_names)

@ -68,7 +68,7 @@ class TemplatePluginNotRegistered(exception.HeatException):
def get_template_class(template_data):
available_versions = _template_classes.keys()
available_versions = list(six.iterkeys(_template_classes))
version = get_version(template_data, available_versions)
version_type = version[0]
try:
@ -116,7 +116,8 @@ class Template(collections.Mapping):
self.files = files or {}
self.maps = self[self.MAPPINGS]
self.env = env or environment.Environment({})
self.version = get_version(self.t, _template_classes.keys())
self.version = get_version(self.t,
list(six.iterkeys(_template_classes)))
def __deepcopy__(self, memo):
return Template(copy.deepcopy(self.t, memo), files=self.files,
@ -228,7 +229,7 @@ class Template(collections.Mapping):
'''
# check top-level sections
for k in self.t.keys():
for k in six.iterkeys(self.t):
if k not in self.SECTIONS:
raise exception.InvalidTemplateSection(section=k)

@ -916,7 +916,7 @@ class HttpCheck(Check):
# empty dict to avoid circular reference detection
# errors in jsonutils.dumps().
temp_target = copy.deepcopy(target)
for key in target.keys():
for key in six.iterkeys(target):
element = target.get(key)
if type(element) is object:
temp_target[key] = {}

@ -12,6 +12,7 @@
# under the License.
from oslo_utils import timeutils
import six
class CooldownMixin(object):
@ -30,7 +31,7 @@ class CooldownMixin(object):
metadata = self.metadata_get()
if metadata and cooldown != 0:
last_adjust = metadata.keys()[0]
last_adjust = next(six.iterkeys(metadata))
if not timeutils.is_older_than(last_adjust, cooldown):
inprogress = True
return inprogress

@ -104,7 +104,7 @@ class HeatMigrationsCheckers(test_migrations.WalkVersionsMixin,
index_columns = None
for idx in t.indexes:
if idx.name == index:
index_columns = idx.columns.keys()
index_columns = six.iterkeys(idx.columns)
break
self.assertEqual(sorted(members), sorted(index_columns))

@ -18,6 +18,7 @@ import mock
from novaclient import client as base_client
from novaclient import exceptions as nova_exceptions
import requests
import six
from six.moves.urllib import parse as urlparse
from heat.tests import fakes
@ -243,19 +244,19 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_servers_1234_action(self, body, **kw):
_body = None
resp = 202
assert len(body.keys()) == 1
action = body.keys()[0]
assert len(list(six.iterkeys(body))) == 1
action = list(six.iterkeys(body))[0]
if action == 'reboot':
assert body[action].keys() == ['type']
assert list(six.iterkeys(body[action])) == ['type']
assert body[action]['type'] in ['HARD', 'SOFT']
elif action == 'rebuild':
keys = body[action].keys()
keys = list(six.iterkeys(body[action]))
if 'adminPass' in keys:
keys.remove('adminPass')
assert keys == ['imageRef']
_body = self.get_servers_1234()[1]
elif action == 'resize':
assert body[action].keys() == ['flavorRef']
assert list(six.iterkeys(body[action])) == ['flavorRef']
elif action == 'confirmResize':
assert body[action] is None
# This one method returns a different response code
@ -268,27 +269,27 @@ class FakeHTTPClient(base_client.HTTPClient):
]:
assert body[action] is None
elif action == 'addFixedIp':
assert body[action].keys() == ['networkId']
assert list(six.iterkeys(body[action])) == ['networkId']
elif action in ['removeFixedIp',
'addFloatingIp',
'removeFloatingIp',
]:
assert body[action].keys() == ['address']
assert list(six.iterkeys(body[action])) == ['address']
elif action == 'createImage':
assert set(body[action].keys()) == set(['name', 'metadata'])
assert set(six.iterkeys(body[action])) == set(['name', 'metadata'])
resp = {"status": 202,
"location": "http://blah/images/456"}
elif action == 'changePassword':
assert body[action].keys() == ['adminPass']
assert list(six.iterkeys(body[action])) == ['adminPass']
elif action == 'os-getConsoleOutput':
assert body[action].keys() == ['length']
assert list(six.iterkeys(body[action])) == ['length']
return (202, {'output': 'foo'})
elif action == 'os-getVNCConsole':
assert body[action].keys() == ['type']
assert list(six.iterkeys(body[action])) == ['type']
elif action == 'os-migrateLive':
assert set(body[action].keys()) == set(['host',
'block_migration',
'disk_over_commit'])
assert set(six.iterkeys(body[action])) == set(['host',
'block_migration',
'disk_over_commit'])
else:
raise AssertionError("Unexpected server action: %s" % action)
return (resp, _body)
@ -296,8 +297,8 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_servers_5678_action(self, body, **kw):
_body = None
resp = 202
assert len(body.keys()) == 1
action = body.keys()[0]
assert len(list(six.iterkeys(body))) == 1
action = list(six.iterkeys(body))[0]
if action in ['addFloatingIp',
'removeFloatingIp',
]:

@ -12,6 +12,7 @@
# under the License.
import os
import six
from oslo_config import cfg
@ -446,7 +447,7 @@ class WatchControllerTest(common.HeatTestCase):
'ALARM': rpc_api.WATCH_STATE_ALARM,
'INSUFFICIENT_DATA': rpc_api.WATCH_STATE_NODATA}
for state in state_map.keys():
for state in six.iterkeys(state_map):
params = {u'StateValue': state,
u'StateReason': u'',
u'AlarmName': u'HttpFailureAlarm',

@ -88,10 +88,10 @@ class FormatTest(common.HeatTestCase):
)))
formatted = api.format_stack_resource(res, True)
self.assertEqual(resource_details_keys, set(formatted.keys()))
self.assertEqual(resource_details_keys, set(six.iterkeys(formatted)))
formatted = api.format_stack_resource(res, False)
self.assertEqual(resource_keys, set(formatted.keys()))
self.assertEqual(resource_keys, set(six.iterkeys(formatted)))
@mock.patch.object(api, 'format_resource_properties')
def test_format_stack_resource_with_props(self, mock_format_props):
@ -207,7 +207,7 @@ class FormatTest(common.HeatTestCase):
rpc_api.RES_REQUIRED_BY))
formatted = api.format_stack_resource(res, False)
self.assertEqual(resource_keys, set(formatted.keys()))
self.assertEqual(resource_keys, set(six.iterkeys(formatted)))
def test_format_stack_resource_with_nested_stack_empty(self):
res = self.stack['generic1']
@ -254,7 +254,7 @@ class FormatTest(common.HeatTestCase):
rpc_api.EVENT_RES_PROPERTIES))
formatted = api.format_event(event)
self.assertEqual(event_keys, set(formatted.keys()))
self.assertEqual(event_keys, set(six.iterkeys(formatted)))
event_id_formatted = formatted[rpc_api.EVENT_ID]
event_identifier = identifier.EventIdentifier(

@ -750,7 +750,7 @@ class HOTemplateTest(common.HeatTestCase):
{'foo': {'Type': 'String',
'Required': True}}})
self.assertEqual(expected_description, tmpl['description'])
self.assertNotIn('parameters', tmpl.keys())
self.assertNotIn('parameters', six.iterkeys(tmpl))
def test_invalid_hot_version(self):
"""
@ -835,7 +835,7 @@ class HOTemplateTest(common.HeatTestCase):
self.resolve,
snippet,
stack.t, stack)
self.assertIn(snippet.keys()[0], six.text_type(error))
self.assertIn(list(six.iterkeys(snippet))[0], six.text_type(error))
def test_resource_facade_missing_deletion_policy(self):
snippet = {'resource_facade': 'deletion_policy'}
@ -859,7 +859,7 @@ class HOTemplateTest(common.HeatTestCase):
error = self.assertRaises(exception.InvalidTemplateVersion,
function.validate,
stack.t.parse(stack, snippet))
self.assertIn(snippet.keys()[0], six.text_type(error))
self.assertIn(next(six.iterkeys(snippet)), six.text_type(error))
def test_add_resource(self):
hot_tpl = template_format.parse('''

@ -2367,7 +2367,8 @@ class ServersTest(common.HeatTestCase):
self.assertIsInstance(console_urls, collections.Mapping)
supported_consoles = ('novnc', 'xvpvnc', 'spice-html5', 'rdp-html5',
'serial')
self.assertEqual(set(supported_consoles), set(console_urls.keys()))
self.assertEqual(set(supported_consoles),
set(six.iterkeys(console_urls)))
self.m.VerifyAll()
def test_default_instance_user(self):

@ -12,6 +12,7 @@
# under the License.
import datetime
import six
from keystoneclient import exceptions as kc_exceptions
from oslo_config import cfg
@ -114,7 +115,7 @@ class SignalTest(common.HeatTestCase):
self.assertEqual('verysecret', rs_data.get('secret_key'))
self.assertEqual('1234', rs_data.get('user_id'))
self.assertEqual(rsrc.resource_id, rs_data.get('user_id'))
self.assertEqual(4, len(rs_data.keys()))
self.assertEqual(4, len(list(six.iterkeys(rs_data))))
self.m.VerifyAll()
def test_get_user_id(self):

@ -812,7 +812,7 @@ Mappings:
template.Template(empty_template))
error = self.assertRaises(ValueError,
self.resolve, snippet, stk.t, stk)
self.assertIn(snippet.keys()[0], six.text_type(error))
self.assertIn(list(six.iterkeys(snippet))[0], six.text_type(error))
def test_resource_facade_missing_deletion_policy(self):
snippet = {'Fn::ResourceFacade': 'DeletionPolicy'}
@ -852,7 +852,7 @@ Mappings:
}
})
self.assertEqual(expected_description, tmpl['Description'])
self.assertNotIn('Parameters', tmpl.keys())
self.assertNotIn('Parameters', six.iterkeys(tmpl))
def test_add_resource(self):
cfn_tpl = template_format.parse('''
@ -998,7 +998,8 @@ class TemplateFnErrorTest(common.HeatTestCase):
error = self.assertRaises(self.expect,
resolve,
self.snippet)
self.assertIn(self.snippet.keys()[0], six.text_type(error))
self.assertIn(list(six.iterkeys(self.snippet))[0],
six.text_type(error))
class ResolveDataTest(common.HeatTestCase):

@ -186,7 +186,7 @@ class JsonYamlResolvedCompareTest(common.HeatTestCase):
del(t2nr['Resources'])
self.assertEqual(t1nr, t2nr)
self.assertEqual(set(stack1.keys()), set(stack2.keys()))
self.assertEqual(set(six.iterkeys(stack1)), set(six.iterkeys(stack2)))
for key in stack1:
self.assertEqual(stack1[key].t, stack2[key].t)

@ -12,6 +12,7 @@
# under the License.
from oslo_config import cfg
import six
from heat.common import exception
from heat.common import short_id
@ -324,7 +325,7 @@ class AccessKeyTest(common.HeatTestCase):
rs_data = resource_data_object.ResourceData.get_all(rsrc)
self.assertEqual(self.fc.secret, rs_data.get('secret_key'))
self.assertEqual(self.fc.credential_id, rs_data.get('credential_id'))
self.assertEqual(2, len(rs_data.keys()))
self.assertEqual(2, len(list(six.iterkeys(rs_data))))
self.assertEqual(utils.PhysName(stack.name, 'CfnUser'),
rsrc.FnGetAtt('UserName'))
@ -358,7 +359,7 @@ class AccessKeyTest(common.HeatTestCase):
resource_data_object.ResourceData.delete(rsrc, 'credential_id')
resource_data_object.ResourceData.delete(rsrc, 'secret_key')
rs_data = resource_data_object.ResourceData.get_all(rsrc)
self.assertEqual(0, len(rs_data.keys()))
self.assertEqual(0, len(list(six.iterkeys(rs_data))))
rsrc._secret = None
self.assertEqual(self.fc.secret,

Loading…
Cancel
Save