Commit Graph

100 Commits (master)

Author SHA1 Message Date
devfu c33d8d98bd Update "if .. if .." to "if .. in .."
Make the code structure looks more clear and more clean.

Change-Id: I5cfce411d7cc182d3ac50170b2ea6a4bc2598525
2 years ago
caihui e5f36293e5 Fix CI error
1. no_voting for lower-constraints CI
2.pep8 create: /home/zuul/src/opendev.org/openstack/freezer/.tox/pep8
pep8 installdeps: -c/home/zuul/src/opendev.org/openstack/requirements/upper-constraints.txt, -r/home/zuul/src/opendev.org/openstack/freezer/test-requirements.txt
ERROR: invocation failed (exit code 1), logfile: /home/zuul/src/opendev.org/openstack/freezer/.tox/pep8/log/pep8-1.log
================================== log start ===================================
Looking in indexes: https://mirror.bhs1.ovh.opendev.org/pypi/simple, https://mirror.bhs1.ovh.opendev.org/wheel/ubuntu-20.04-x86_64
Collecting astroid==2.1.0
  Downloading 8809bc008b36396c0cff6279841e8a/astroid-2.1.0-py3-none-any.whl (176 kB)
Collecting pylint==2.3.1
  Downloading b3f73f4ac00277237721ef1c151f0d/pylint-2.3.1-py3-none-any.whl (765 kB)
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of astroid to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install -r /home/zuul/src/opendev.org/openstack/freezer/test-requirements.txt (line 23) and astroid==2.1.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested astroid==2.1.0
    pylint 2.3.1 depends on astroid<3 and >=2.2.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
WARNING: You are using pip version 20.3.3; however, version 21.0 is available.
You should consider upgrading via the '/home/zuul/src/opendev.org/openstack/freezer/.tox/pep8/bin/python -m pip install --upgrade pip' command.
================================ log end ===============================

Change-Id: I898d03d716ebc6c6285c4589cd30f7875b0c51d2
2 years ago
Caihui 19aae78daf Fix bug "AttributeError: 'generator' object has no attribute 'next'"
1. the bug:
   Captured traceback:
   ~~~~~~~~~~~~~~~~~~~
	Traceback (most recent call last):

	File "/opt/stack/freezer/freezer/tests/unit/scheduler/test_utils.py", line 53, in test_find_config_files_path
	ret = utils.find_config_files(temp_path)

	File "/opt/stack/freezer/freezer/scheduler/utils.py", line 53, in find_config_files
	for fname in os.walk(expanded_path).next()[2]:

	AttributeError: 'generator' object has no attribute 'next'

2. fix:
To get iterobject next element  is  changed to next(iterobject,defalt) in python3.x.

Change-Id: I558bbfecb4a9670a10b1fc649821d88619b7917c
3 years ago
Caihui 1e304b5826 Remove keystone v2 related code
Kyestone V2 support was removed in Train, so it's safe to do such cleanup.

Change-Id: I6a379ef79429eb218c6095397949fd8116a934c2
3 years ago
Michal Arbet c446ec389b Fix parsing config file for freezer job
Config parsers do not guess datatypes of values
in configuration files, always storing them internally
as strings. So, we need to test if action_v is not NoneType,
and if it is not, retype to String. Retype is needed if
we get boolean value.

Change-Id: I2ddade105a9825a82e18aaf27650d769aedee4cf
3 years ago
caihui 02e435f0ed Remove six usage from freezer package
We don't support Python 2 anymore so we don't need this
compatibility library.

This patch remove six usage.

Change-Id: I661e9cdaf33e89bdb905d1f34a001f3853c4c366
3 years ago
Michal Arbet 89558a7202 Fix python3 compatibility
Change-Id: I01a142cab62253719f2534b0eda8e5954db76730
3 years ago
zhulingjie 63b5e271e4 Update json module to jsonutils
json is deprecated, should use oslo_serialization.jsonutils
instead.

Change-Id: Ib4b562c3f37a5c133f3a6ae8efa00a26c8b41846
4 years ago
gengchc2 43b64a1c63 Correct errors about freezer-api supporting for V1 and V2 api
At present, the codes as follows:
db/elastic/driver.py:
Def get_engine (self):
    If not self._engine:
        Self._engine = db_session.ElasticSearchEngineV2(self.backend)
    Return self._engine
There is that freezer-api can't support support v1.
Actually, there is enable_v1_api ,but it is not used correctly.
The documents will be modified in other patches.

For example:
1)freezer-api v1:
  /etc/freezer/freezer-api.conf:
      [DEFAULT]
          enable_v1_api = True
	  [storage]
          driver = elasticsearch
          backend = elasticsearch
	  [elasticsearch]
          hosts = http://172.16.1.200:9200
          number_of_replicas = 0
          index = freezer

  /etc/freezer/scheduler.conf:
      [DEFAULT]
          enable_v1_api = True

   command: freezer --os-backup-api-version 1  job-list

2)freezer-api v2:
  /etc/freezer/freezer-api.conf:
      [DEFAULT]
          enable_v1_api = False
		  or
		  # enable_v1_api = False
	  [storage]
          driver = elasticsearch
          backend = elasticsearch
	  [elasticsearch]
          hosts = http://172.16.1.200:9200
          number_of_replicas = 0
          index = freezer

  /etc/freezer/scheduler.conf:
      [DEFAULT]
         enable_v1_api = False
		 or
		 # enable_v1_api = False

   command: freezer job-list

Change-Id: I9eb490c874efa0d752982f38f0971f80bcab14f3
5 years ago
Cai Hui f6320229f9 Remove "--os-identity-api-version" argument
The argument of "--os-identity-api-version" is no longer required
in freezerclient module.

Change-Id: I5851163137d75f980b4254e45202b167fab8c2a7
5 years ago
Chen 3c9528d0fa Remove unneeded if statements
Change-Id: I333dea283bedd2391b46978d99d251cfa77ce5c1
5 years ago
Nguyen Hai 29a4e902aa Fix openstack-tox-docs failure
Change-Id: I01035d5cb04b5908571d1d5e177176e9d8f24091
5 years ago
Zuul f40833754c Merge "Fixes starting freezer-scheduler with --no-daemon" 5 years ago
Jakub Jursa ac7d039201 Fixes starting freezer-scheduler with --no-daemon
When using flag --no-daemon, freezer-scheduler --no-daemon start fails with
AttributeError: 'NoDaemon' object has no attribute 'restart'
(freezer_scheduler.py: L251). This patch adds missing dummy methods for reload
and restart actions.

Change-Id: I72a0a4f68503b7c143cbe6c6f13cfbdc08e6ccbb
5 years ago
David Rabel 9f8d6c382e Fix license boilerplates
license boilerplates as docstring are included in automatically
generated documentation which leads to wrong formatting.

For example the indented hyperlink to the license is formatted as
quotation.

Change-Id: I9d6088ab48d6787f29b593bfa5445b6a84e99de7
5 years ago
wangqi f4fd101d5a delete all qpid related explanations
Qpid was removed in Mitaka from Oslo Messaging, so we
can remove all qpid related explanations

Change-Id: If6a8cfdd1340c8b81d080ac837bb793d9ca38e4e
5 years ago
Zuul ff069f524f Merge "Revert "Optimise the code style"" 5 years ago
Saad Zaher 075362ed70 Freezer-scheduler support both APIs
This patch allows freezer-scheduler to use either API v1 or v2
You can alter it using OS_BACKUP_API_VERSION env variable

Depends-On: I83000f8bf39eed41d067ed663de9f459439eca9a
Change-Id: I2e5724b1f1a75121952e2beb3844d2c489e4df68
5 years ago
Saad Zaher 5d0151c405 Revert "Optimise the code style"
This reverts commit a8f776cc77.

Change-Id: I75082a71fe1ab1dd2a1fce94ef12d472c32c5263
Closes-Bug: #1749919
5 years ago
caoyuan a8f776cc77 Optimise the code style
the change is not means bugs, just optimise the code style.

Change-Id: I5f8873717f232b1b7266ec56aeae0dc982157c99
5 years ago
caoyuan 8ddd174374 Remove the unnecessary statement for possible_action check
"CONF.action is None" in included in "CONF.action not in possible_action"
it is unnecessary. this patch to review it.

Change-Id: Ia0e21122a11ab0c1f36886b86df9613dac42f3ea
5 years ago
Jenkins a9f529937f Merge "Fix job stop info log print duplicately" 6 years ago
Jenkins a2ee5430cf Merge "Remove unused variable's local value" 6 years ago
Jenkins 4409629230 Merge "Replace six.iteritems() with .items()" 6 years ago
howardlee 7a27bc922d Add restart command for freezer-scheduler
Currently, freezer-scheduler doesn't have restart command. If we
modified scheduler.conf, we should stop freezer-scheduler firstly,
and then start freezer-scheduler. Restart command can simplify the
operation of an user.

Closes-Bug: #1685192
Change-Id: Iad7ebc8a8303d151bc91030bc67d765ea0eadeab
6 years ago
howardlee 54e955d4b6 Fix job stop info log print duplicately
Now, when you stop a job whose status is ScheduledState or RunningState,
freezer-scheduler will print the job stop info log many times. In fact,
whatever status the job is in, it is appropriate to print its stop info
log only when it's in StopState status.

Closes-Bug: #1685187
Change-Id: I6efe9ee67980db1d438b051cb718f49935deb23d
6 years ago
Pengju Jiao 75f2a124ed Remove unused variable's local value
The local variable 'config_file_name' is not
used in the code scope, so we should remove it to
clean the code.

Change-Id: Ia660848bdb028621d7c635f13b0a973726d3caa3
6 years ago
Pengju Jiao 95ee8b0094 Fix freezer-scheduler can be started multiple times
Currently, freezer-scheduler process can be started
multiple times, but when we use 'freezer-scheduler
stop' to stop it, only the latest started scheduler
process will be stoped. This patch ensures the
freezer-scheduler process just start up once.

Change-Id: I4bf5bb643f364d5cf79c7ea2ccb8c6a496cd77fe
Closes-Bug: #1678033
6 years ago
DeepaJon 77be8fa29c Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using six.iteritems to
achieve iterators. We can use dict.items instead, as it will
return iterators in PY3 as well. And dict.items/keys will more
readable.
2.In py2, the performance about list should be negligible,
see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I522e8f06e8a31b0d591db825d0c1608f162cbbc6
6 years ago
zhangguoqing 0c8f5ae305 Replaces uuid.uuid4 with uuidutils.generate_uuid()
Openstack common has a wrapper for generating uuids. We should
use that function when generating uuids for consistency.

Change-Id: Ide5cdaf48a27e9c080fd8691b100a601f82ca2bf
Closes-Bug: #1082248
6 years ago
Pierre-Arthur MATHIEU ffd99c4a2e Allow for multiple jobs to be executed at the same time
Change-Id: I2fa6f989a21f7964cc573010f58d68ad003788d5
6 years ago
Saad Zaher 96cc1855f9 Added missing Auth OS options
Added some configuration options were missing and were causing problems
during connection to freezer-api

Change-Id: Id3ffbf390d704e5973e2b6822168a1f8caecfa2d
6 years ago
Jenkins d0d4985120 Merge "Fix scheduler_cron have a error get cron args use dict" 6 years ago
yangyapeng a8538fff92 Fix scheduler_cron have a error get cron args use dict
Change-Id: I81939177a776318fe9732f22093373a2b2a1dd60
6 years ago
Partha Bera 638efd25b4 Remove default=None for config options
In the cfg module default=None is set as the
default value. It's not necessary to set it
again when defining config options.

Change-Id: I9fc33e44fdf038684195a19027255ce1bfe61dc6
Closes-bug: #1323975
7 years ago
Shangzhong Zhu 8101e2a7b0 Remove unused code from freezer-scheduler
The freezer client has been switched to python-freezerclient,
the code related to use freezer-scheduler as a command line client
should be removed.

Change-Id: I999d0f2e72cf135fdf3b9373461648416c9e0902
Closes-Bug: #1645635
Signed-off-by: Shangzhong Zhu <zhu.shangzhong@zte.com.cn>
7 years ago
Ruslan Aliev 16b64376d7 Fix print warning when scheduler starts
Messages about creating new directory or finding already created
directory should not be treated as "WARNING", it's normal behavior.
Also, there is no need to print this messages every execution
of scheduler.

Change-Id: I31dc9acc06b0b1556b265da9fef4ef2a74c20e06
Closes-Bug: #1646851
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
7 years ago
howardlee 8000e5392c Import only modules rather than objects
Do not import objects, only modules (*)

http://docs.openstack.org/developer/hacking/#imports

Change-Id: I70fdffbe4e83698fefc0d1efa4a627d6c1a6bfa8
7 years ago
Memo García d98de1ac2b Switch to python-freezerclient
Implements: blueprint switch-to-python-freezer-client
Closes-Bug: #1642921
Depends-On: Ie108d99d56ca76614cdf6927f614a44106a0a922
Change-Id: I2627a5326c8ad4acc96177605f0250925748fb67
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
7 years ago
Jenkins bcd67c6117 Merge "Use LOG.error to record log when initializing LOG" 7 years ago
Jenkins f320b35137 Merge "Fix removing temp file" 7 years ago
Shangzhong Zhu 16ff90ce06 Use LOG.error to record log when initializing LOG
Delete the directory "scheduler" under /etc/freezer/, start
freezer-scheduler, print the error info as follow:
No handlers could be found for logger "freezer.scheduler.arguments"

In the process of initializing oslo_log, _LOG.error was used to
record error info. Before the initialization is finished, the
_LOG.error can't be used to record log info.

Use freezer_utils.create_dir() to check if the directory exist or
not, if not, will create the directory. If the error occurs, The
log info will be wrote into log file.

Change-Id: I19d7b6efd52af66142c01e017e29db3792ef0398
Closes-Bug: #1627245
7 years ago
Cao Xuan Hoang 61ee6a331a Clean imports in code
This patch set modifies lines which are importing objects
instead of modules. As per openstack import guide lines, user should
import modules in a file not objects.
Also, imports was regrouped and placed in alphabetical order.

http://docs.openstack.org/developer/hacking/#imports

Change-Id: I192b8bf6f50a85e19640975f0902a014c4ba0878
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
7 years ago
Ruslan Aliev afca2bd2e4 Fix removing temp file
There is no need to call os.remove() with temp file,
it will be removed automatically after closed.
Actually, freezer.log has warning messages about it:
WARNING freezer.utils.utils [-] Error deleting file /tmp/tmpSNedJh
This patch will fix it.
Also, added newline to info message that using scheduler is deprecated
and more verbose output if there is a problem with deleting file.

Change-Id: I8dc31684bfece130eed6dd89806e965a4e1eabea
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
7 years ago
Jenkins 85ab97121e Merge "Fix job_schedule trigger cron" 7 years ago
Fabrizio Vanni dcc76e031f fix job_schedule result and start/end timestamps
The following fields of the job document are now correctly updated
when the freezer_scheduler starts and stops a job.

- time_started
- time_ended
- result

In case of recurring job the "result" field is updated with the
result of the last job's execution.

Change-Id: I35d804b12f65d2123fdcb558b770cf6eef871d1e
Closes-Bug: #1631074
7 years ago
yangyapeng e4011c0c86 Fix job_schedule trigger cron
when schedule json_file has some key eg: schedule_{year, week, day}
and so on, it should trigger cron to schedule use apschedule.
But it is unavailable now. This patch should fix it use cron date.

Change-Id: I0113158d60605109fdeefe74f45f4050b5a75d7a
Closes-Bug: #1599715
7 years ago
Jenkins 927fdab24e Merge "failed to stop freezer-scheduler" 7 years ago
Pierre-Arthur MATHIEU 7a27163c54 Fixing max_retries
Max_retries implies number of RE-Try, not number of tries.
Also, this fixes an issue if someone gave max_retries value of 0.

Change-Id: Ibf67f4a0d7c0bbd65daf93ef20fb852e5bdf868f
7 years ago
Pierre-Arthur MATHIEU c385a7953a Remove deprecated code
And deprecates freezer-scheduler cli, use python-freezerclient

Change-Id: I2960b1f21758a47e11a9df1723a962b745474bd8
7 years ago