Replace warn with warning method

There is a following deprecation warning
"DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead"
This patch changes warn to warning method to fix the DeprecationWarning

Change-Id: Id2173c89be889ea2c227e515db0237a1e6674702
Related-Bug: #1838765
This commit is contained in:
Sergii Golovatiuk 2019-08-02 12:01:53 +02:00
parent c10329fc0e
commit 299718997c
3 changed files with 12 additions and 9 deletions

View File

@ -2046,9 +2046,9 @@ def check_file_for_enabled_service(env_file):
for service in constants.DEPRECATED_SERVICES.keys():
try:
if content["resource_registry"][service] != "OS::Heat::None":
LOG.warn("service " + service + " is enabled in "
+ str(env_file) + ". " +
constants.DEPRECATED_SERVICES[service])
LOG.warning("service " + service + " is enabled in "
+ str(env_file) + ". " +
constants.DEPRECATED_SERVICES[service])
deprecated_services_enabled.append(service)
except (KeyError, TypeError) as e:
# ignore if content["resource_registry"] is empty

View File

@ -455,7 +455,8 @@ class PrepareImageFiles(command.Command):
if parsed_args.output_env_file:
params = prepare_data[parsed_args.output_env_file]
if os.path.exists(parsed_args.output_env_file):
self.log.warn("Output env file exists, moving it to backup.")
self.log.warning("Output env file exists, \
moving it to backup.")
shutil.move(parsed_args.output_env_file,
parsed_args.output_env_file + ".backup")
with os.fdopen(os.open(parsed_args.output_env_file,
@ -723,7 +724,8 @@ class TripleOImagePrepareDefault(command.Command):
self.app.stdout.write(env_data)
if parsed_args.output_env_file:
if os.path.exists(parsed_args.output_env_file):
self.log.warn("Output env file exists, moving it to backup.")
self.log.warning("Output env file exists, \
moving it to backup.")
shutil.move(parsed_args.output_env_file,
parsed_args.output_env_file + ".backup")
with os.fdopen(os.open(parsed_args.output_env_file,
@ -822,7 +824,8 @@ class TripleOImagePrepare(command.Command):
env_data = build_env_file(params, self.app.command_options)
if parsed_args.output_env_file:
if os.path.exists(parsed_args.output_env_file):
self.log.warn("Output env file exists, moving it to backup.")
self.log.warning("Output env file exists, \
moving it to backup.")
shutil.move(parsed_args.output_env_file,
parsed_args.output_env_file + ".backup")
with os.fdopen(os.open(parsed_args.output_env_file,

View File

@ -238,9 +238,9 @@ class UploadOvercloudImage(command.Command):
def _get_environment_var(self, envvar, default, deprecated=[]):
for env_key in deprecated:
if env_key in os.environ:
self.log.warn(('Found deprecated environment var \'%s\', '
'please use \'%s\' instead' % (env_key,
envvar)))
self.log.warning(('Found deprecated environment var \'%s\', '
'please use \'%s\' instead' % (env_key,
envvar)))
return os.environ.get(env_key)
return os.environ.get(envvar, default)