Commit Graph

105 Commits

Author SHA1 Message Date
Hamza Alqtaishat 990287677b Adding the senlin resource
This handle the senlin cluster disable/clean
for disable it will detach the polices from the cluster
and resize the cluster to zero (empty cluster)

for clean it will deatach the policies from cluster
clean the policies, receivers then clean the clusters then clean
the profiles

Change-Id: I09421d55c66d91a747bc786fdd250730c79dfd34
2019-10-24 20:31:38 +00:00
Adam Harwell a7b9786f4a Revert "Url quoting of swift object names when deleting"
This reverts commit fc73a2e881.

Change-Id: I7d0d0d4f6af53dec2cf96e1bbc8de70d5f6c7ba3
2019-10-21 15:41:05 -07:00
Zuul 0f517cf361 Merge "Adding the disable feature" 2019-10-15 16:20:27 +00:00
Hamza Alqtaishat 39a159f8c7 Adding the disable feature
This feature allow the disable of most of the project resources
in some cases the admin want to disable the project and wait
for period of time before deleting the resources just in case
some resources are still usable or need to be moved to another
project

for nova the disable will stop the servers
for neutron it will change the admin_state_up to false which
will change the status of resource to down
for glance it will deactivate the images
for swift it will remove the read/write acls to container
for octaivia chenge the admin_state_up to false making the
status of loadbalancer down
for cinder it will change the volume to readonly

for the resources that dont have a way of disabling the
resource it will just log a warning

Change-Id: Ic2af6ad1ffb1e749a3d1ba687950264b5098bcdb
2019-10-14 21:33:38 +00:00
Zuul 30a24580cf Merge "Fix auth order issue introduced in modernize patch" 2019-10-11 14:54:18 +00:00
sreinke 18ba71715b Add ha_router_replicated_interface to router interfaces
Change-Id: I8cf94d123555b37fa80c9dc93005e089ef2f5042
2019-10-09 10:07:04 +00:00
Adam Harwell 3ca9f412b4 Fix auth order issue introduced in modernize patch
Was introduced in Ieecc4043b613e333948c32e7e93ad1d383d1f3ec

Co-Authored-By: Hamza Mahmoud Abdallah Alqtaishat <hamalq@verizonmedia.com>
Change-Id: Id70b60de95fac44a50b06166486a5fcc80d12eda
2019-10-06 14:13:26 -07:00
Zuul c94a3fa9fb Merge "Add Octavia support" 2019-10-02 15:37:08 +00:00
Zuul 8a75ebb283 Merge "Allow entry points to override existing resources" 2019-10-02 15:11:57 +00:00
Adam Harwell 7044205c34 Add Octavia support
Includes functional testing.

Change-Id: I8d2152d2f354cfb882f534d23f150d6962195b0f
2019-10-01 20:09:37 -07:00
Adam Harwell 0421d12397 Modernize testing and clients
Update to use a new-style zuul role for devstack testing.
Remove references to Shade/os_client_config and use OpenstackSDK.

Change-Id: Ieecc4043b613e333948c32e7e93ad1d383d1f3ec
2019-10-01 20:09:32 -07:00
Yves-Gwenael Bourhis fc73a2e881 Url quoting of swift object names when deleting
shade sends the swift object or container name unquoted as an url and in
shade.openstackcloud.py in get_object_metadata where OpenStackCloudException
errors with 404 status_code are silently ignored.
If the name contains special characters such as a '#' we therefore get no
metadata without errors.
The same thing happens after in shade.openstackcloud.py in delete_object when
calling self._object_store_client.delete : an OpenStackCloudHTTPError is
caught and the delete method returns False.
This resulted in ospurge not deleting such objects without even getting
an exception.
After investigation, the issue would be the same in openstacksdk which
copies the same code as shade.
Since nor shade nor openstacksdks perform url encoding of the name, we url
encode it ourselves before calling shade, since shade makes an http
request by calling the swift api with the object name as an url.

Closes-Bug: #1831753

Change-Id: Ie7aea2a14d920ca11012ff26d7f74017704765f5
2019-06-05 18:04:37 +02:00
Yves-Gwenael Bourhis 4df8423bdf Allow entry points to override existing resources
Third party modules may want to modify existing resources behaviours.
To allow overriding existing resources, entry point modules need to be
loaded first.
It is not an issue to load them first since we sort the classes afterwards.

Change-Id: I92999d98df249649b79b13ca2be2691efdde737f
2019-06-04 14:34:36 +02:00
Yves-Gwenael Bourhis 79ecb6f53c To get tenant, use openstacksdk instead of shade.
Shade retrieves the list of all tenants and filters the result.
This can be a huge issue on platforms with tons of tenants.

OpenstackSDK's get_project method acts also like shade's get_project method,
but OpenstackSDK's identity manager just recovers the desired tenant, so we
use this.

Also we pass the OpenStackConfig instance to shade or openstacksdk
because if we don't, they re-instantiate one uselessly.

Closes-Bug: #1820616

Change-Id: I737b031fa9f2e4394d58ac204bf28b422cec1c28
2019-06-04 14:33:33 +02:00
Yves-Gwenael Bourhis 8a69363f8e Fix test_get_resource_classes parameter passing
In utils.get_resource_classes we expect a list of strings.
However we are passing a string.
The test was succeding by pure luck.
If we pass something else (such as 'Stacks') we had multiple results.
This test was confusing for other developers implementing other tests.

Closes-Bug: #1820033

Change-Id: I8414b7582d94b199457a01e4916a7e7b6e51edbc
2019-03-14 10:50:28 +01:00
Yves-Gwenael Bourhis 02bcffc174 Add support for entry points
Change-Id: I11fd40645479a815b29afaac0b12d45f6f7e6c21
2019-03-13 15:50:35 +01:00
Graham Hayes bd1588ac19
Add Designate support
Change-Id: Ia4aab5f6ccc6405eba20750b505ebdf32a6ab82d
Signed-off-by: Graham Hayes <gr@ham.ie>
2018-10-15 16:49:02 +01:00
Oleg Bondarev 5b92014541 Neutron: handle DVR router interfaces
DVR uses different device_owner name for router interfaces

Change-Id: I9f78cf3372456326d5c5be93cca57230481472fb
2018-09-09 17:47:53 +00:00
Zuul 64a70a0b54 Merge "Add heat stacks cleanup" 2018-09-09 13:53:28 +00:00
Tobias Urdin 9189d5da71 Add heat stacks cleanup
Add support to cleanup heat stacks.
Order it early since Heat is probably
orchestrating some servers, volumes etc
that will be removed.

Change-Id: I98c70ff5ac1c8ba5389cd97193152dfb29bec8e4
2018-09-08 15:50:10 +02:00
Victor Stinner af88d16028 Python2: Fix tox -e py27
With this change, unit tests now pass on Python 2.7: tox -e py27.

Changes:

* Replace "yield from ..." with "for item in ...: yield item"
* Remove last annotations from utils.py
* tox.ini: use python3 as basepython rather than python3.5 to support
  Python 2.7 and Python 3.6
* tox.ini: add py27 to envlist

Related-Bug: 1726399
Change-Id: Ief1a95402e8a31a34ada2937a7ae6a604f7f8757
2017-11-13 09:13:46 +01:00
Victor Stinner c1d38f741b Python2: Fix metaclass, super() and OrderedMeta
* Add six dependency
* Replace "metaclass=" syntax with six.with_metaclass()
* Add parameters to super()
* Only define OrderedMeta on Python 3

Related-Bug: 1726399
Change-Id: I21800320ef23cc95fc07278864e73b64bb7d6d08
2017-11-13 09:13:43 +01:00
Victor Stinner b73c938a93 Python 2: Move type annotations to .pyi files
Python 2 doesn't support type annotations: raise SyntaxError. Move
them to separated .pyi files to add Python 2 support without loosing
annotations.

Keep inline comments like "# type: Optional[str]".

Related-Bug: 1726399
Change-Id: Ib1a837e88cf76908f1007b3881703ffb433e6c2f
2017-11-09 16:11:57 +01:00
Zuul 44cab87d5f Merge "Python2: Add mock and unittest2 test dependencies" 2017-11-09 14:50:17 +00:00
Zuul 6ec607639b Merge "Python2: Add funcsigs dependency" 2017-11-09 14:40:42 +00:00
Zuul 725df86557 Merge "Python2: Add SimpleNamespace for Python 2" 2017-11-09 12:53:02 +00:00
Victor Stinner 50560fc91c Python2: Add funcsigs dependency
inspect.signature() was added to Python 3.3: add funcsigs on Python
2.7.

funcsigs dependency is specific to Python 2.7 and so not installed on
Python 3.

Change-Id: I951e7df9fcebdc2148cca477f4b064fc9a028e55
Related-Bug: 1726399
2017-11-09 13:30:11 +01:00
Victor Stinner 67fc801e69 Python2: Use __name__ rather than __qualname__
The __qualname__ attribute was added in Python 3. Falls back on
__name__ for Python 2 compatibility, when __qualname__ is not
available.

Related-Bug: 1726399
Change-Id: I19d07dc978250e5340327f05ea6ab62ac55489ed
2017-11-09 10:43:51 +00:00
Victor Stinner 17162e6506 Python2: Add mock and unittest2 test dependencies
* unittest.mock was added in Python 3.3 standard library: use
  external 'mock' module, backport for Python 2.7
* assertRaisesRegex() method was added to Python 3.2 unittest module:
  use external 'unitttest2' backport for Python 2.7 to not have to
  rewrite unit tests just because of Python 2.7

Both added dependencies are specific to Python 2.7 and have no impact
on Python 3.

Related-Bug: 1726399
Change-Id: Ieb32e85d6f40f9b7bed5ba99900be2432d18da9e
2017-11-09 10:43:20 +00:00
Victor Stinner c2d1728dee Python2: Add SimpleNamespace for Python 2
types.SimpleNamespace was added in Python 3.3. Reimplement it in 3
lignes to add compatibility with Python 2.7.

Related-Bug: 1726399
Change-Id: I1553a39ecbf315b5e89d3ec8070b15769cabb8d2
2017-11-09 10:43:03 +00:00
rocky 36cf3d9c29 Fix the resources load issue
The resources cannot be loaded correctly if the command
is not issued at the top level of the package.

Bug report: https://bugs.launchpad.net/ospurge/+bug/1693409

Change-Id: I14dd2b62b1c30de8aee451b851af02577ad61957
2017-09-04 19:00:53 +10:00
Jordan Pittier 57481bc598 Code Cleanup
Also, this allows to pass several times the --resource argument.

Change-Id: I54b055b03b51ce0a3527c140d615024e0d9bd851
Related-bug: #1685630
2017-07-12 12:28:32 +00:00
suresh kumar 0b4977a8d1 Adds Resource specific purge support
Implements `--resource` arg for purging the specific resource type.

Change-Id: I9a493d767df3283b8ccd4531109cd5c15e2a3b50
2017-07-11 21:11:30 +00:00
Jordan Pittier 7bf67dd293 Gate functional job: assert volumes are correctly cleaned up
After OSPurge has ran on one project, this patch asserts that volumes
and volume backups in other projects have not been deleted.

Also, we must separate the case when cinder-backup is running and when
it is not. We know (for now) that c-bak is enabled in Gate runs.

Change-Id: I0064e43c7b8476943370aa365b6c0d3160d157b0
2017-03-13 15:55:54 +01:00
Jenkins bddfe4f8cf Merge "Make MyPy checks stricter" 2017-02-28 12:07:19 +00:00
Jordan Pittier f83b138fa8 Update functional job
Change-Id: Ie29ceecb56aaae6e7bf2b9d91634b2b17a9ae9c3
2017-02-27 22:04:23 +01:00
Jordan Pittier 5cca232ba4 Make MyPy checks stricter
Change-Id: I87018c5d5a5dc04af386b257d4438b759461459c
2017-02-01 16:59:29 +01:00
Jordan Pittier 5e6c61f443 Disable worrying warning message related to resource owner.
Change-Id: I14af68f55e10201700c324fededae6f902ac6f75
2017-01-10 17:14:47 +01:00
Jordan Pittier 3a612efd53 OSPurge version 2
This commit is a whole new version of OSPurge. Currently OSPurge suffers
from the following limitations:
* It's slow (monothread)
* It's not guaranteed to complete. If a resource fails to be deleted then
OSPurge can choke on deleting other resources that depends on the first one.
* Not properly unit tested.
* Not modular (one huge file to deal with all services)

This new version is:
* Faster (multithreaded, thanks to a ThreadPoolExecutor)
* Safe (we check and wait for some prerequisites before attempting a
delete)
* 100% unit tested.
* Modular (one file per service)

Note that it's Python3.5 compatible. It also uses OpenStack Shade
and OpenStack client-config libraries so that OSPurge focuses on the
cleaning logic only.

Overall I believe this is a better version of OSPurge and more future
proof. NOte that we tagged and released OSPurge 1.3 recently in case
the new version was not satisfactory to everybody.

Change-Id: I5eb92a0556df210ea3cb4e471b8db3b5bf7ed5ee
2016-12-15 10:49:25 +01:00
zarrouk 712bb2bce5 Use unicode formatting
The openstack clients return unicode strings as ressource names.
In python2.7, we need to use unicode encoding when dealing with string
formatting otherwise it is treated as python2 str and we try to cast
a unicode string into an str.
In python 3 prefixing a string with u has no effect and is supported
and considered as a python3 str which are natively unicode strings.

Change-Id: Id77ed2f28fd206b900a0e273fece244517e55505
Closes-Bug: #1645761
2016-12-09 16:02:06 +01:00
jurajama d18f6617b4 Fix to delete router interfaces with DVR enabled
Now also interfaces with owner "network:router_interface_distributed" are deleted.
Before this fix, interface and router deletion failed if DVR is enabled.

Change-Id: I33c5304845d4d7c2eee729aa334ec745dcac970e
Closes-Bug: #1552336
2016-11-20 16:14:29 +02:00
Pierre-Alexandre Bardina aa909316b7 Add support for keystone v2 - v3
Ospurge can be used with keystone v2 and v3 with the new
authentication plugin (Session), the old one is deprecated.

Change-Id: Ife87da432f3f56c13679e6a93c8571620c635615
2016-07-25 16:10:50 +02:00
Praveen Yalagandula 328f6d23c8 Adapting the test code to account for changes in heat client code
Change-Id: I19203f70dcc4d0b20ae8b961160b95f8c41109de
2016-03-16 23:02:24 +00:00
Steve Martinelli 2b43c70daf do not use deprecated keystone.apiclient.exceptions
use keystoneclient.exceptions instead, the ones under apiclient
have been deprecated for a while.

also, the exceptions under keystoneclient.openstack.common are
just redirects to the top level keystone.exceptions, so fix a
reference of that as well.

Change-Id: I0912d5a96f42b7f61422a27f318752a17b7238cb
2015-12-14 13:02:58 -05:00
Yves-Gwenael Bourhis cdcf2cbf58 Not sending auth-url to ceilometerclient
If ceilometerclient gets an auth-url, it tries some keystone
requests with the publicURL even if endpoint_type is 'internalURL'.

We force the endpoint-type and region name without providing auth-url.

Closes-Bug: #1513544

Change-Id: Ib214f9d25f32f7cd1f06c27d73a889ce032915e0
2015-11-19 21:47:23 +00:00
Christian Berendt 22b7c1790a Move decorator and base classes into a separate module
Change-Id: Iac555cdf656199c6f0f3d2d132c286e9e4edce23
2015-11-03 16:28:30 +01:00
Christian Berendt 0ae31c5d3a Move exceptions into a separate module
Change-Id: I92e2d79962d9fe87a2ae5a5bf7876706c5c9c8db
2015-10-22 10:54:29 +00:00
Christian Berendt d3d8d6a096 Move constants into a separate module
Change-Id: Ie458514c7159976e426b75060655e93d2eaf4375
2015-10-22 10:54:22 +00:00
Christian Berendt 0da7bb43fe Rename module ospurge to client
Change-Id: I1f6bc2b3d0ceb0078a21ecc0975c1a1123068fc8
2015-10-22 12:54:16 +02:00
Jenkins 1d36f26242 Merge "Make the name of the admin role configurable" 2015-10-21 14:07:05 +00:00