summaryrefslogtreecommitdiff
path: root/ironic/db/sqlalchemy
diff options
context:
space:
mode:
authorJulia Kreger <juliaashleykreger@gmail.com>2018-11-16 11:10:15 -0800
committerJulia Kreger <juliaashleykreger@gmail.com>2018-12-10 14:27:31 -0800
commit052d90506fdb75479250705be4ba033f9f025c76 (patch)
treedb179129de168f2d96eefcbed8a84430cff3d6c9 /ironic/db/sqlalchemy
parent88e13746267f64376b7ed1cd9fd95a770b1b1989 (diff)
downloadironic-052d90506fdb75479250705be4ba033f9f025c76.tar.gz
Add "owner" information field
Adds "owner" field on the node object and exposes it for updates via the API. Additionally, fixed a couple minor items related to the prior where we missed updating version numbers in rebases. Change-Id: Iaaf3db97d21de9b11236cf2d18ffcc3f73f6e50c Story: #2001814 Task: #12550
Diffstat (limited to 'ironic/db/sqlalchemy')
-rw-r--r--ironic/db/sqlalchemy/alembic/versions/f190f9d00a11_add_node_owner.py32
-rw-r--r--ironic/db/sqlalchemy/api.py4
-rw-r--r--ironic/db/sqlalchemy/models.py2
3 files changed, 35 insertions, 3 deletions
diff --git a/ironic/db/sqlalchemy/alembic/versions/f190f9d00a11_add_node_owner.py b/ironic/db/sqlalchemy/alembic/versions/f190f9d00a11_add_node_owner.py
new file mode 100644
index 000000000..45ded937e
--- /dev/null
+++ b/ironic/db/sqlalchemy/alembic/versions/f190f9d00a11_add_node_owner.py
@@ -0,0 +1,32 @@
+# All Rights Reserved.
+#
+# 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.
+"""add_node_owner
+
+Revision ID: f190f9d00a11
+Revises: 93706939026c
+Create Date: 2018-11-12 00:33:58.575100
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+# revision identifiers, used by Alembic.
+revision = 'f190f9d00a11'
+down_revision = '93706939026c'
+
+
+def upgrade():
+ op.add_column('nodes', sa.Column('owner', sa.String(255),
+ nullable=True))
diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py
index e702a38ad..8d32d6385 100644
--- a/ironic/db/sqlalchemy/api.py
+++ b/ironic/db/sqlalchemy/api.py
@@ -224,7 +224,7 @@ class Connection(api.Connection):
'chassis_uuid', 'associated', 'reserved',
'reserved_by_any_of', 'provisioned_before',
'inspection_started_before', 'fault',
- 'conductor_group'}
+ 'conductor_group', 'owner'}
unsupported_filters = set(filters).difference(supported_filters)
if unsupported_filters:
msg = _("SqlAlchemy API does not support "
@@ -232,7 +232,7 @@ class Connection(api.Connection):
raise ValueError(msg)
for field in ['console_enabled', 'maintenance', 'driver',
'resource_class', 'provision_state', 'uuid', 'id',
- 'fault', 'conductor_group']:
+ 'fault', 'conductor_group', 'owner']:
if field in filters:
query = query.filter_by(**{field: filters[field]})
if 'chassis_uuid' in filters:
diff --git a/ironic/db/sqlalchemy/models.py b/ironic/db/sqlalchemy/models.py
index 37fdbcc71..2a17dfa65 100644
--- a/ironic/db/sqlalchemy/models.py
+++ b/ironic/db/sqlalchemy/models.py
@@ -179,7 +179,7 @@ class Node(Base):
protected = Column(Boolean, nullable=False, default=False,
server_default=false())
protected_reason = Column(Text, nullable=True)
-
+ owner = Column(String(255), nullable=True)
bios_interface = Column(String(255), nullable=True)
boot_interface = Column(String(255), nullable=True)
console_interface = Column(String(255), nullable=True)