Skip to content

Evaluate string "true" and "false" to Booleans in openstack_config #214

@EarthmanT

Description

@EarthmanT

This code tests that the insecure variable is True or False. This is assuming that the user is providing a YAML value. However, if this value is set via an intrinsic function, the value will be evaluated as string, because all intrinsic function values are strings.

Basically, want to change something from fig 1 to something essentially the same as fig2 :

fig 1:

verify = not (cfg[AUTH_PARAM_INSECURE] is True)

fig 2:

cfg_insecure = cfg[AUTH_PARAM_INSECURE]
if isinstance(cfg_insecure, basestring) and cfg_insecure.Capitalize() == 'True':
    cfg[AUTH_PARAM_INSECURE] = True
verify = not (cfg[AUTH_PARAM_INSECURE] is True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions