Skip to content

Commit

Permalink
CBR vault SDK resource (#169)
Browse files Browse the repository at this point in the history
CBR vault SDK resource

Reviewed-by: None <None>
Reviewed-by: Anton Kachurin <[email protected]>
Reviewed-by: Rodion Gyrbu <[email protected]>
Reviewed-by: Irina Pereiaslavskaia <None>
Reviewed-by: Artem Goncharov <[email protected]>
  • Loading branch information
tischrei authored Apr 20, 2021
1 parent de62466 commit cf8ee31
Show file tree
Hide file tree
Showing 18 changed files with 1,047 additions and 1 deletion.
83 changes: 82 additions & 1 deletion doc/source/sdk/guides/cbr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ or an instance of class
.. literalinclude:: ../examples/cbr/delete_backup.py
:lines: 16-23

Backup
Policy
------

List CBR Policies
Expand Down Expand Up @@ -138,3 +138,84 @@ volumes.

.. literalinclude:: ../examples/cbr/restore_data.py
:lines: 16-36

Vault
-----

List CBR Vaults
^^^^^^^^^^^^^^^

This interface is used to query CBR vaults and to filter
the output with query parameters.

.. literalinclude:: ../examples/cbr/list_vaults.py
:lines: 16-22

Get CBR Vault
^^^^^^^^^^^^^

This interface is used to get a CBR vault by ID or an instance of
class :class:`~otcextensions.sdk.cbr.v3.vault.Vault`.

.. literalinclude:: ../examples/cbr/get_vault.py
:lines: 16-23

Create CBR Vault
^^^^^^^^^^^^^^^^

This interface is used to create a CBR vault instance with
parameters.

.. literalinclude:: ../examples/cbr/create_vault.py
:lines: 16-46

Update CBR Vault
^^^^^^^^^^^^^^^^

This interface is used to update a CBR vault instance with
parameters.

.. literalinclude:: ../examples/cbr/update_vault.py
:lines: 16-29

Delete CBR Vault
^^^^^^^^^^^^^^^^

This interface is used to delete a CBR vault instance by id
or an instance of class
:class:`~otcextensions.sdk.cbr.v3.vault.Vault`.

.. literalinclude:: ../examples/cbr/delete_vault.py
:lines: 16-23

Bind Policy to CBR Vault
^^^^^^^^^^^^^^^^^^^^^^^^

This interface is used to bind a CBR policy to a CBR vault.

.. literalinclude:: ../examples/cbr/bind_policy.py
:lines: 16-26

Unbind Policy to CBR Vault
^^^^^^^^^^^^^^^^^^^^^^^^^^

This interface is used to release a CBR policy from a CBR vault.

.. literalinclude:: ../examples/cbr/unbind_policy.py
:lines: 16-26

Associate resources to CBR Vault
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This interface is used to add resources to a CBR vault.

.. literalinclude:: ../examples/cbr/associate_resources.py
:lines: 16-28

Dissociate resources from CBR Vault
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This interface is used to remove resources from CBR vault.

.. literalinclude:: ../examples/cbr/dissociate_resources.py
:lines: 16-27
9 changes: 9 additions & 0 deletions doc/source/sdk/proxies/cbr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ Restore Operations
.. autoclass:: otcextensions.sdk.cbr.v3._proxy.Proxy
:noindex:
:members: restore_data

Vault Operations
^^^^^^^^^^^^^^^^

.. autoclass:: otcextensions.sdk.cbr.v3._proxy.Proxy
:noindex:
:members: vaults, get_vault, find_vault, create_vault, update_vault,
delete_vault, bind_policy, unbind_policy,
associate_resources, dissociate_resources
1 change: 1 addition & 0 deletions doc/source/sdk/resources/cbr/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Cloud Backup and Recovery Resources
v3/checkpoint
v3/policy
v3/restore
v3/vault
34 changes: 34 additions & 0 deletions doc/source/sdk/resources/cbr/v3/vault.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
otcextensions.sdk.cbr.v3.vault
==============================

.. automodule:: otcextensions.sdk.cbr.v3.vault

The CBR Vault Class
-------------------

The ``Vault`` class inherits from
:class:`~otcextensions.sdk.sdk_resource.Resource`.

.. autoclass:: otcextensions.sdk.cbr.v3.vault.Vault
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.BillingSpec
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.BillingExtraInfoSpec
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.ResourceSpec
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.ResourceExtraInfoSpec
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.VolumeSpec
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.BindRuleSpec
:members:

.. autoclass:: otcextensions.sdk.cbr.v3.vault.TagSpec
:members:
28 changes: 28 additions & 0 deletions examples/cbr/associate_resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
'''
Bind resources to CBR vault
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


vault = 'vault_name_or_id'
resources = [{
'id': 'server_id',
'type': 'OS::Nova::Server'}]

vault = conn.cbr.find_vault(vault)
conn.cbr.associate_resources(vault=vault.id, resources=resources)
26 changes: 26 additions & 0 deletions examples/cbr/bind_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
'''
Bind policy to CBR vault
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


policy = 'name_or_id'
vault = 'name_or_id'
policy = conn.cbr.find_policy(policy)
vault = conn.cbr.find_vault(vault)
conn.cbr.bind_policy(vault=vault.id, policy=policy.id)
46 changes: 46 additions & 0 deletions examples/cbr/create_vault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
'''
Create CBR vault with attributes
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


attrs = {
'description': 'my vault',
'auto_bind': False,
'bind_rules': {},
'name': 'vault-name',
'billing': {
'protect_type': 'backup',
'object_type': 'server',
'size': 40,
'cloud_type': 'public',
'consistent_level': 'crash_consistent',
'charging_mode': 'post_paid'
},
'auto_expand': False,
'resources': [
{
'name': 'server-name',
'type': 'OS::Nova::Server',
'id': 'server-id',
}
]
}

vault = conn.cbr.create_vault(**attrs)
print(vault)
23 changes: 23 additions & 0 deletions examples/cbr/delete_vault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Delete CBR vault
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

name_or_id = 'name_or_id'
vault = conn.cbr.find_vault(name_or_id)
conn.cbr.delete_vault(vault=vault)
27 changes: 27 additions & 0 deletions examples/cbr/dissociate_resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
'''
Release resources from CBR vault
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


vault = 'vault_name_or_id'
resources = [
'list_of_resource_ids',
]
vault = conn.cbr.find_vault(vault)
conn.cbr.dissociate_resources(vault=vault.id, resources=resources)
23 changes: 23 additions & 0 deletions examples/cbr/find_vault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Find a single CBR vault by name or id
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

name_or_id = 'name_or_id'
vault = conn.cbr.find_vault(name_or_id)
print(vault)
23 changes: 23 additions & 0 deletions examples/cbr/get_vault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Get single CBR Vault
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

vault = 'vault_id'
vault = conn.cbr.get_vault(vault=vault)
print(vault)
22 changes: 22 additions & 0 deletions examples/cbr/list_vaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
List all CBR Vaults
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

for vault in conn.cbr.vaults():
print(vault)
26 changes: 26 additions & 0 deletions examples/cbr/unbind_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
'''
Unbind policy from CBR vault
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


policy = 'name_or_id'
vault = 'name_or_id'
policy = conn.cbr.find_policy(policy)
vault = conn.cbr.find_vault(vault)
conn.cbr.unbind_policy(vault=vault.id, policy=policy.id)
Loading

0 comments on commit cf8ee31

Please sign in to comment.