Skip to content

Commit 0118ef1

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add CT tags field to the database and API"
2 parents e24bf62 + 332e2b6 commit 0118ef1

File tree

12 files changed

+71
-5
lines changed

12 files changed

+71
-5
lines changed

api-ref/source/clustertemplates.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Request
5757
- dns_nameserver: dns_nameserver
5858
- floating_ip_enabled: floating_ip_enabled
5959
- hidden: hidden
60+
- tags: tags
6061

6162
Request Example
6263
----------------
@@ -102,6 +103,7 @@ Response
102103
- master_lb_enabled: master_lb_enabled
103104
- dns_nameserver: dns_nameserver
104105
- hidden: hidden
106+
- tags: tags
105107

106108
Response Example
107109
----------------
@@ -167,6 +169,7 @@ Response
167169
- master_lb_enabled: master_lb_enabled
168170
- dns_nameserver: dns_nameserver
169171
- hidden: hidden
172+
- tags: tags
170173

171174
Response Example
172175
----------------
@@ -240,6 +243,7 @@ Response
240243
- master_lb_enabled: master_lb_enabled
241244
- dns_nameserver: dns_nameserver
242245
- hidden: hidden
246+
- tags: tags
243247

244248
Response Example
245249
----------------
@@ -364,9 +368,10 @@ Return new cluster templates with updated attributes.
364368
- master_lb_enabled: master_lb_enabled
365369
- dns_nameserver: dns_nameserver
366370
- hidden: hidden
371+
- tags: tags
367372

368373
Response Example
369374
----------------
370375

371376
.. literalinclude:: samples/clustertemplate-create-resp.json
372-
:language: javascript
377+
:language: javascript

api-ref/source/parameters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,12 @@ status_reason:
559559
in: body
560560
required: true
561561
type: string
562+
tags:
563+
description: |
564+
Administrator tags for the cluster template.
565+
in: body
566+
required: false
567+
type: array
562568
tls_disabled:
563569
description: |
564570
Transport Layer Security (TLS) is normally enabled to secure the

magnum/api/controllers/v1/baymodel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class BayModel(base.APIBase):
141141
hidden = wsme.wsattr(types.boolean, default=False)
142142
"""Indicates whether the Baymodel is hidden or not."""
143143

144+
tags = wtypes.StringType(min_length=0, max_length=255)
145+
"""A comma separated list of tags."""
146+
144147
def __init__(self, **kwargs):
145148
self.fields = []
146149
for field in objects.ClusterTemplate.fields:

magnum/api/controllers/v1/cluster_template.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class ClusterTemplate(base.APIBase):
156156
hidden = wsme.wsattr(types.boolean, default=False)
157157
"""Indicates whether the ClusterTemplate is hidden or not."""
158158

159+
tags = wtypes.StringType(min_length=0, max_length=255)
160+
"""A comma separated list of tags."""
161+
159162
def __init__(self, **kwargs):
160163
self.fields = []
161164
for field in objects.ClusterTemplate.fields:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
"""added_tags_to_cluster_template
13+
14+
Revision ID: f1d8b0ab8b8d
15+
Revises: 95096e2334ee
16+
Create Date: 2020-08-26 08:38:11.567618
17+
18+
"""
19+
20+
# revision identifiers, used by Alembic.
21+
revision = 'f1d8b0ab8b8d'
22+
down_revision = '95096e2334ee'
23+
24+
from alembic import op # noqa: E402
25+
import sqlalchemy as sa # noqa: E402
26+
27+
28+
def upgrade():
29+
op.add_column('cluster_template',
30+
sa.Column('tags',
31+
sa.String(length=255), nullable=True))

magnum/db/sqlalchemy/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ def _is_cluster_template_referenced(self, session, cluster_template_uuid):
389389
def _is_publishing_cluster_template(self, values):
390390
if (len(values) == 1 and (
391391
('public' in values and values['public'] is True) or
392-
('hidden' in values))):
392+
('hidden' in values) or
393+
('tags' in values and values['tags'] is not None))):
393394
return True
394395
return False
395396

magnum/db/sqlalchemy/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class ClusterTemplate(Base):
191191
master_lb_enabled = Column(Boolean, default=False)
192192
floating_ip_enabled = Column(Boolean, default=True)
193193
hidden = Column(Boolean, default=False)
194+
tags = Column(String(255))
194195

195196

196197
class X509KeyPair(Base):

magnum/objects/cluster_template.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class ClusterTemplate(base.MagnumPersistentObject, base.MagnumObject,
4343
# Version 1.17: 'coe' field type change to ClusterTypeField
4444
# Version 1.18: DockerStorageDriver is a StringField (was an Enum)
4545
# Version 1.19: Added 'hidden' field
46-
VERSION = '1.19'
46+
# Version 1.20: Added 'tags' field
47+
VERSION = '1.20'
4748

4849
dbapi = dbapi.get_instance()
4950

@@ -80,6 +81,7 @@ class ClusterTemplate(base.MagnumPersistentObject, base.MagnumObject,
8081
'master_lb_enabled': fields.BooleanField(default=False),
8182
'floating_ip_enabled': fields.BooleanField(default=True),
8283
'hidden': fields.BooleanField(default=False),
84+
'tags': fields.StringField(nullable=True),
8385
}
8486

8587
@staticmethod

magnum/tests/unit/api/controllers/v1/test_cluster_template.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class TestListClusterTemplate(api_base.FunctionalTest):
6464
'image_id', 'registry_enabled', 'no_proxy',
6565
'keypair_id', 'https_proxy', 'tls_disabled',
6666
'public', 'labels', 'master_flavor_id',
67-
'volume_driver', 'insecure_registry', 'hidden')
67+
'volume_driver', 'insecure_registry', 'hidden',
68+
'tags',)
6869

6970
def test_empty(self):
7071
response = self.get_json('/clustertemplates')

magnum/tests/unit/db/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def get_test_cluster_template(**kw):
5757
'master_lb_enabled': kw.get('master_lb_enabled', True),
5858
'floating_ip_enabled': kw.get('floating_ip_enabled', True),
5959
'hidden': kw.get('hidden', False),
60+
'tags': kw.get('tags', ""),
6061
}
6162

6263

0 commit comments

Comments
 (0)