Skip to content

[DWS] Add support for cluster tag managment#392

Merged
otc-zuul[bot] merged 13 commits intomasterfrom
366-tags-functionality-in-dws-sdk-is-not-defined
Dec 18, 2023
Merged

[DWS] Add support for cluster tag managment#392
otc-zuul[bot] merged 13 commits intomasterfrom
366-tags-functionality-in-dws-sdk-is-not-defined

Conversation

@Persimmonboy
Copy link
Copy Markdown
Contributor

@Persimmonboy Persimmonboy commented Dec 14, 2023

Closes #366

Artem Shakhbazian and others added 11 commits December 4, 2023 18:44
…k-is-not-defined' into 366-tags-functionality-in-dws-sdk-is-not-defined

# Conflicts:
#	otcextensions/sdk/dws/v1/_proxy.py
#	otcextensions/sdk/dws/v1/tag.py
#	otcextensions/tests/functional/sdk/dws/v1/test_tag.py
…k-is-not-defined' into 366-tags-functionality-in-dws-sdk-is-not-defined

# Conflicts:
#	otcextensions/sdk/dws/v1/_proxy.py
@Persimmonboy Persimmonboy force-pushed the 366-tags-functionality-in-dws-sdk-is-not-defined branch from b7e7ec3 to 89cec09 Compare December 14, 2023 13:48
artem-lifshits
artem-lifshits previously approved these changes Dec 14, 2023

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add please here: sdk.register_otc_extensions(conn)
also you will need to add this import: from otcextensions import sdk

this comment is for all examples

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the following to all examples:

<>
from otcextensions import sdk
<>
sdk.register_otc_extensions(conn)
<>

cluster_id = 'cluster-uuid'
tag = {'key': 'example_key', 'value': 'example_value'}

result = conn.dws.create_cluster_tag(cluster_id, tag)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**tag

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to **tag

{'key': 'key2'}
]

conn.dws.cluster_tags_batch_delete(cluster_id, tags_to_delete)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**tags_to_delete

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to *tags_to_delete

{'key': 'key2', 'value': 'value2'}
]

result = conn.dws.cluster_tags_batch_create(cluster_id, tags_to_create)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**tags_to_create

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to *tags_to_create

Comment thread otcextensions/sdk/dws/v1/_proxy.py Outdated
time.sleep(60)
self.wait_for_cluster(cluster, interval, wait)

def list_cluster_tags(self, cluster):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename please to cluster_tags

Copy link
Copy Markdown
Contributor Author

@Persimmonboy Persimmonboy Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed, also in test, doc sections

Comment thread otcextensions/sdk/dws/v1/_proxy.py Outdated
:param cluster: Cluster ID or an instance of
`otcextensions.sdk.dws.v1.cluster.Cluster`.
:param tags: List of dictionaries of tags to delete.
:return: Response object.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or object Tag, not response

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed response to 'otcextensions.sdk.dws.v1.tag.Tag'

Comment thread otcextensions/sdk/dws/v1/tag.py Outdated
uri = utils.urljoin('clusters', cluster_id, 'tags/action')

body = {'action': action, 'tags': tags}
return session.post(uri, json=body)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should return not 'clear' response, it must be object of class Tag

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to translate response into object

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed response into object


def test_list_cluster_tags(self):
"""Test listing all tags of a cluster."""
tags = list(self.client.list_cluster_tags(self.cluster_id))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to create instance and check that list returns more or equal 1, this test checks nothing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test

@Persimmonboy Persimmonboy force-pushed the 366-tags-functionality-in-dws-sdk-is-not-defined branch 2 times, most recently from 32cb134 to d975122 Compare December 15, 2023 16:30
@Persimmonboy Persimmonboy force-pushed the 366-tags-functionality-in-dws-sdk-is-not-defined branch from d975122 to 1f83446 Compare December 15, 2023 16:38
@Persimmonboy Persimmonboy force-pushed the 366-tags-functionality-in-dws-sdk-is-not-defined branch from 1f83446 to 3d12938 Compare December 18, 2023 08:53
@otc-zuul
Copy link
Copy Markdown
Contributor

otc-zuul Bot commented Dec 18, 2023

Build succeeded.
https://zuul.otc-service.com/t/eco/buildset/e06e79b6fa1745048a9cebedce0a6d76

✔️ otc-tox-docs SUCCESS in 14m 21s
✔️ build-otc-releasenotes SUCCESS in 7m 38s
✔️ otc-tox-py38 SUCCESS in 6m 33s
✔️ otc-tox-pep8 SUCCESS in 5m 30s
✔️ tox-functional-eu-de SUCCESS in 10m 19s
✔️ otce-upload-image SUCCESS in 3m 13s

@otc-zuul otc-zuul Bot merged commit fa2b17c into master Dec 18, 2023
@otc-zuul otc-zuul Bot deleted the 366-tags-functionality-in-dws-sdk-is-not-defined branch December 18, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tags functionality in DWS SDK is not defined

5 participants