Skip to content

Commit

Permalink
Set ignore_missing=True for DWS find and delete methods (#444)
Browse files Browse the repository at this point in the history
Set ignore_missing=True for DWS find and delete methods

Set ignore_missing=True for DWS find and delete methods.
Standardized PEP8 formatting for DWS using ruff and black formatters.

Reviewed-by: Anton Sidelnikov
  • Loading branch information
vineet-pruthi authored Jun 28, 2024
1 parent 8fb7832 commit da4e04c
Show file tree
Hide file tree
Showing 28 changed files with 993 additions and 877 deletions.
2 changes: 1 addition & 1 deletion doc/source/sdk/guides/dws.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This interface is used to query an DWS cluster list.
:class:`~otcextensions.sdk.dws.v1.cluster.Cluster`.

.. literalinclude:: ../examples/dws/list_clusters.py
:lines: 16-22
:lines: 16-21

Create DWS Cluster
^^^^^^^^^^^^^^^^^^
Expand Down
60 changes: 30 additions & 30 deletions examples/dws/batch_create_cluster_tags.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#!/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.
"""
Batch create tags for a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'
tags_to_create = [
{'key': 'key1', 'value': 'value1'},
{'key': 'key2', 'value': 'value2'}
]

result = conn.dws.batch_create_cluster_tags(cluster_id, tags_to_create)
print(result)
#!/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.
"""
Batch create tags for a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'
tags_to_create = [
{'key': 'key1', 'value': 'value1'},
{'key': 'key2', 'value': 'value2'}
]

result = conn.dws.batch_create_cluster_tags(cluster_id, tags_to_create)
print(result)
58 changes: 29 additions & 29 deletions examples/dws/batch_delete_cluster_tags.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/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.
"""
Batch delete tags from a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'
tags_to_delete = [
{'key': 'key1'},
{'key': 'key2'}
]

conn.dws.batch_delete_cluster_tags(cluster_id, tags_to_delete)
#!/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.
"""
Batch delete tags from a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'
tags_to_delete = [
{'key': 'key1'},
{'key': 'key2'}
]

conn.dws.batch_delete_cluster_tags(cluster_id, tags_to_delete)
50 changes: 25 additions & 25 deletions examples/dws/cluster_tags.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/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 tags for a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'

print(list(conn.dws.cluster_tags(cluster_id)))
#!/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 tags for a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'

print(list(conn.dws.cluster_tags(cluster_id)))
26 changes: 13 additions & 13 deletions examples/dws/create_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
conn = openstack.connect(cloud='otc')

attrs = {
"name": "dws-1",
"node_type": "dws.m3.xlarge",
"number_of_node": 3,
"availability_zone": "eu-de-01",
"vpc_id": "router-uuid",
"subnet_id": "network-uuid",
"security_group_id": "security-group-uuid",
"port": 8000,
"user_name": "dbadmin",
"user_pwd": "Password!",
"public_ip": {
"public_bind_type": "auto_assign",
"eip_id": ""
'name': 'dws-1',
'flavor': 'dws.m3.xlarge',
'num_nodes': 3,
'availability_zone': 'eu-de-01',
'router_id': 'router-uuid',
'network_id': 'network-uuid',
'security_group_id': 'security-group-uuid',
'port': 8000,
'user_name': 'dbadmin',
'user_pwd': 'Password!',
'public_ip': {
'public_bind_type': 'auto_assign',
'eip_id': ''
}
}
result = conn.dws.create_cluster(**attrs)
Expand Down
57 changes: 30 additions & 27 deletions examples/dws/create_cluster_tag.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
#!/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 a new tag for a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
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)
print(result)
#!/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 a new tag for a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
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)
print(result)
6 changes: 3 additions & 3 deletions examples/dws/create_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

cluster_id = 'cluster-uuid'
attrs = {
"name": "snapshot-3",
"cluster_id": cluster_id,
"description": "Snapshot-3 description"
'name': 'snapshot-3',
'cluster_id': cluster_id,
'description': 'Snapshot-3 description'
}

result = conn.dws.create_snapshot(**attrs)
Expand Down
52 changes: 26 additions & 26 deletions examples/dws/delete_cluster_tag.py
Original file line number Diff line number Diff line change
@@ -1,26 +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.
"""
Delete a tag from a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'
tag_key = "example_key"

conn.dws.delete_cluster_tag(cluster_id, tag_key)
#!/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 a tag from a specified DWS cluster.
"""
import openstack
from otcextensions import sdk

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

cluster_id = 'cluster-uuid'
tag_key = 'example_key'

conn.dws.delete_cluster_tag(cluster_id, tag_key)
1 change: 0 additions & 1 deletion examples/dws/list_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""
import openstack


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

Expand Down
18 changes: 9 additions & 9 deletions examples/dws/restore_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
conn = openstack.connect(cloud='otc')

attrs = {
"name": "dws-1",
"availability_zone": "eu-de-01",
"port": 8000,
"vpc_id": "router-uuid",
"subnet_id": "network-uuid",
"security_group_id": "security-group-uuid",
"public_ip": {
"public_bind_type": "auto_assign",
"eip_id": ""
'name': 'dws-1',
'availability_zone': 'eu-de-01',
'port': 8000,
'vpc_id': 'router-uuid',
'subnet_id': 'network-uuid',
'security_group_id': 'security-group-uuid',
'public_ip': {
'public_bind_type': 'auto_assign',
'eip_id': ''
}
}

Expand Down
Loading

0 comments on commit da4e04c

Please sign in to comment.