本文整理汇总了Python中oslo_utils.strutils.mask_dict_password方法的典型用法代码示例。如果您正苦于以下问题:Python strutils.mask_dict_password方法的具体用法?Python strutils.mask_dict_password怎么用?Python strutils.mask_dict_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_utils.strutils
的用法示例。
在下文中一共展示了strutils.mask_dict_password方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _attach_volume
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def _attach_volume(self, context, connection_info, instance,
disk_bus=constants.CTRL_TYPE_SCSI,
update_device_metadata=False):
LOG.debug(
"Attaching volume: %(connection_info)s to %(instance_name)s",
{'connection_info': strutils.mask_dict_password(connection_info),
'instance_name': instance.name})
volume_driver = self._get_volume_driver(connection_info)
volume_driver.attach_volume(connection_info,
instance.name,
disk_bus)
if update_device_metadata:
# When attaching volumes to already existing instances,
# the connection info passed to the driver is not saved
# yet within the BDM table.
self._block_dev_man.set_volume_bdm_connection_info(
context, instance, connection_info)
self._vmops.update_device_metadata(
context, instance)
qos_specs = connection_info['data'].get('qos_specs') or {}
if qos_specs:
volume_driver.set_disk_qos_specs(connection_info,
qos_specs)
示例2: extend_volume
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def extend_volume(self, connection_properties):
"""Update the local kernel's size information.
Try and update the local kernel's size information
for an iSCSI volume.
"""
LOG.info("Extend volume for %s",
strutils.mask_dict_password(connection_properties))
volume_paths = self.get_volume_paths(connection_properties)
LOG.info("Found paths for volume %s", volume_paths)
if volume_paths:
return self._linuxscsi.extend_volume(
volume_paths, use_multipath=self.use_multipath)
else:
LOG.warning("Couldn't find any volume paths on the host to "
"extend volume for %(props)s",
{'props': strutils.mask_dict_password(
connection_properties)})
raise exception.VolumePathsNotFound()
示例3: detach_volume
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def detach_volume(self, context, connection_info, instance,
update_device_metadata=False):
LOG.debug("Detaching volume: %(connection_info)s "
"from %(instance_name)s",
{'connection_info': strutils.mask_dict_password(
connection_info),
'instance_name': instance.name})
volume_driver = self._get_volume_driver(connection_info)
volume_driver.detach_volume(connection_info, instance.name)
volume_driver.disconnect_volume(connection_info)
if update_device_metadata:
self._vmops.update_device_metadata(context, instance)
示例4: sanitize_secrets
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def sanitize_secrets(content, mask="****"):
"""Extends oslo_utils strutils to make mask passwords more robust."""
def mask_dict_password(dictionary, secret="***"):
"""Overriding strutils.mask_dict_password.
Overriding mask_dict_password to accept CaseInsenstiveDict as well.
"""
out = deepcopy(dictionary)
for k, v in dictionary.items():
if is_dict(v):
out[k] = mask_dict_password(v, secret=secret)
continue
for sani_key in strutils._SANITIZE_KEYS:
if sani_key in k:
out[k] = secret
break
else:
if isinstance(v, six.string_types):
out[k] = strutils.mask_password(v, secret=secret)
return out
strutils.mask_dict_password = mask_dict_password
if is_dict(content):
return strutils.mask_dict_password(content, mask)
if is_string(content):
return strutils.mask_password(content, mask)
示例5: _make_vim_dict
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def _make_vim_dict(self, vim_db, fields=None, mask_password=True):
res = dict((key, vim_db[key]) for key in VIM_ATTRIBUTES)
vim_auth_db = vim_db.vim_auth
res['auth_url'] = vim_auth_db[0].auth_url
res['vim_project'] = vim_auth_db[0].vim_project
res['auth_cred'] = vim_auth_db[0].auth_cred
res['auth_cred']['password'] = vim_auth_db[0].password
if mask_password:
res['auth_cred'] = strutils.mask_dict_password(res['auth_cred'])
return self._fields(res, fields)
示例6: test_dictionary
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_dictionary(self):
payload = {'password': 'TL0EfN33'}
expected = {'password': '***'}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'user': 'admin', 'password': 'TL0EfN33'}
expected = {'user': 'admin', 'password': '***'}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'strval': 'somestring',
'dictval': {'user': 'admin', 'password': 'TL0EfN33'}}
expected = {'strval': 'somestring',
'dictval': {'user': 'admin', 'password': '***'}}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'strval': '--password abc',
'dont_change': 'this is fine',
'dictval': {'user': 'admin', 'password': b'TL0EfN33'}}
expected = {'strval': '--password ***',
'dont_change': 'this is fine',
'dictval': {'user': 'admin', 'password': '***'}}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'ipmi_password': 'KeDrahishvowphyecMornEm0or('}
expected = {'ipmi_password': '***'}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'passwords': {'KeystoneFernetKey1': 'c5FijjS'}}
expected = {'passwords': {'KeystoneFernetKey1': '***'}}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'passwords': {'keystonecredential0': 'c5FijjS'}}
expected = {'passwords': {'keystonecredential0': '***'}}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
示例7: test_do_no_harm
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_do_no_harm(self):
payload = {}
expected = {}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
payload = {'somekey': 'somevalue',
'anotherkey': 'anothervalue'}
expected = {'somekey': 'somevalue',
'anotherkey': 'anothervalue'}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
示例8: test_do_an_int
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_do_an_int(self):
payload = {}
payload[1] = 2
expected = payload.copy()
self.assertEqual(expected,
strutils.mask_dict_password(payload))
示例9: test_mask_values
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_mask_values(self):
payload = {'somekey': 'test = cmd --password my\xe9\x80\x80pass'}
expected = {'somekey': 'test = cmd --password ***'}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
示例10: test_other_non_str_values
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_other_non_str_values(self):
payload = {'password': 'DK0PK1AK3', 'bool': True,
'dict': {'cat': 'meow', 'password': "*aa38skdjf"},
'float': 0.1, 'int': 123, 'list': [1, 2], 'none': None,
'str': 'foo'}
expected = {'password': '***', 'bool': True,
'dict': {'cat': 'meow', 'password': '***'},
'float': 0.1, 'int': 123, 'list': [1, 2], 'none': None,
'str': 'foo'}
self.assertEqual(expected,
strutils.mask_dict_password(payload))
示例11: test_non_dict
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_non_dict(self):
expected = {'password': '***',
'foo': 'bar',
}
payload = TestMapping()
self.assertEqual(expected, strutils.mask_dict_password(payload))
示例12: test_nested_non_dict
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def test_nested_non_dict(self):
expected = {'nested': {'password': '***',
'foo': 'bar',
}
}
payload = NestedMapping()
self.assertEqual(expected, strutils.mask_dict_password(payload))
示例13: attach_volume
# 需要导入模块: from oslo_utils import strutils [as 别名]
# 或者: from oslo_utils.strutils import mask_dict_password [as 别名]
def attach_volume(self, context, connection_info, instance,
disk_bus=constants.CTRL_TYPE_SCSI,
update_device_metadata=False):
tries_left = CONF.hyperv.volume_attach_retry_count + 1
while tries_left:
try:
self._attach_volume(context,
connection_info,
instance,
disk_bus,
update_device_metadata)
break
except Exception as ex:
tries_left -= 1
if not tries_left:
LOG.exception(
"Failed to attach volume %(connection_info)s "
"to instance %(instance_name)s. ",
{'connection_info': strutils.mask_dict_password(
connection_info),
'instance_name': instance.name})
# We're requesting a detach as the disk may have
# been attached to the instance but one of the
# post-attach operations failed.
self.detach_volume(context,
connection_info,
instance,
update_device_metadata)
raise exception.VolumeAttachFailed(
volume_id=connection_info['serial'],
reason=ex)
else:
LOG.warning(
"Failed to attach volume %(connection_info)s "
"to instance %(instance_name)s. "
"Tries left: %(tries_left)s.",
{'connection_info': strutils.mask_dict_password(
connection_info),
'instance_name': instance.name,
'tries_left': tries_left})
time.sleep(CONF.hyperv.volume_attach_retry_interval)