1 This patchset is for bug: |
|
2 |
|
3 22726240 - Ironic needs to support MySQL Cluster |
|
4 |
|
5 This fixes the following aspects of Ironic: |
|
6 1. Implementation of an oslo.db configuration parameter to specify the MySQL |
|
7 storage engine (mysql_storage_engine). |
|
8 2. Replacement of hardcoded SQL statements that set the engine to "InnoDB" |
|
9 to the above configuration value. |
|
10 3. Logic to handle SQL differences between MySQL InnoDB and MySQL Cluster (NDB). |
|
11 This includes column lengths, constraints, foreign keys, and indexes. |
|
12 4. Changes the conductor table column "online" to "online_status" to make it |
|
13 more portable. "online" is a reserved word in MySQL and other databases. |
|
14 |
|
15 This has not been committed upstream, but has been filed in launchpad: |
|
16 |
|
17 https://bugs.launchpad.net/ironic/+bug/1564110 |
|
18 |
|
19 |
|
20 --- ironic-2015.1.2/ironic/db/sqlalchemy/models.py.orig 2016-07-29 12:25:49.797916170 -0600 |
|
21 +++ ironic-2015.1.2/ironic/db/sqlalchemy/models.py 2016-07-28 14:06:28.682668208 -0600 |
|
22 @@ -49,8 +49,12 @@ db_options.set_defaults(cfg.CONF, _DEFAU |
|
23 def table_args(): |
|
24 engine_name = urlparse.urlparse(cfg.CONF.database.connection).scheme |
|
25 if engine_name == 'mysql': |
|
26 - return {'mysql_engine': cfg.CONF.database.mysql_engine, |
|
27 - 'mysql_charset': "utf8"} |
|
28 + if cfg.CONF.database.mysql_storage_engine == "NDBCLUSTER": |
|
29 + return {'mysql_engine': cfg.CONF.database.mysql_storage_engine, |
|
30 + 'mysql_charset': "utf8"} |
|
31 + else: |
|
32 + return {'mysql_engine': cfg.CONF.database.mysql_engine, |
|
33 + 'mysql_charset': "utf8"} |
|
34 return None |
|
35 |
|
36 |
|
37 @@ -135,7 +139,7 @@ class Conductor(Base): |
|
38 id = Column(Integer, primary_key=True) |
|
39 hostname = Column(String(255), nullable=False) |
|
40 drivers = Column(JSONEncodedList) |
|
41 - online = Column(Boolean, default=True) |
|
42 + online = Column('online', Boolean, default=True, quote=True) |
|
43 |
|
44 |
|
45 class Node(Base): |
|
46 --- ironic-2015.1.2/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py.orig 2016-07-29 12:25:57.319572657 -0600 |
|
47 +++ ironic-2015.1.2/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py 2016-07-29 12:27:49.354646151 -0600 |
|
48 @@ -24,8 +24,10 @@ revision = '2581ebaf0cb2' |
|
49 down_revision = None |
|
50 |
|
51 from alembic import op |
|
52 +from oslo_config import cfg |
|
53 import sqlalchemy as sa |
|
54 |
|
55 +CONF = cfg.CONF |
|
56 |
|
57 def upgrade(): |
|
58 # commands auto generated by Alembic - please adjust! |
|
59 @@ -38,7 +40,7 @@ def upgrade(): |
|
60 sa.Column('drivers', sa.Text(), nullable=True), |
|
61 sa.PrimaryKeyConstraint('id'), |
|
62 sa.UniqueConstraint('hostname', name='uniq_conductors0hostname'), |
|
63 - mysql_ENGINE='InnoDB', |
|
64 + mysql_ENGINE=CONF.database.mysql_storage_engine, |
|
65 mysql_DEFAULT_CHARSET='UTF8' |
|
66 ) |
|
67 op.create_table( |
|
68 @@ -51,7 +53,7 @@ def upgrade(): |
|
69 sa.Column('description', sa.String(length=255), nullable=True), |
|
70 sa.PrimaryKeyConstraint('id'), |
|
71 sa.UniqueConstraint('uuid', name='uniq_chassis0uuid'), |
|
72 - mysql_ENGINE='InnoDB', |
|
73 + mysql_ENGINE=CONF.database.mysql_storage_engine, |
|
74 mysql_DEFAULT_CHARSET='UTF8' |
|
75 ) |
|
76 op.create_table( |
|
77 @@ -77,7 +79,7 @@ def upgrade(): |
|
78 sa.ForeignKeyConstraint(['chassis_id'], ['chassis.id'], ), |
|
79 sa.PrimaryKeyConstraint('id'), |
|
80 sa.UniqueConstraint('uuid', name='uniq_nodes0uuid'), |
|
81 - mysql_ENGINE='InnoDB', |
|
82 + mysql_ENGINE=CONF.database.mysql_storage_engine, |
|
83 mysql_DEFAULT_CHARSET='UTF8' |
|
84 ) |
|
85 op.create_index('node_instance_uuid', 'nodes', ['instance_uuid'], |
|
86 @@ -95,7 +97,7 @@ def upgrade(): |
|
87 sa.PrimaryKeyConstraint('id'), |
|
88 sa.UniqueConstraint('address', name='uniq_ports0address'), |
|
89 sa.UniqueConstraint('uuid', name='uniq_ports0uuid'), |
|
90 - mysql_ENGINE='InnoDB', |
|
91 + mysql_ENGINE=CONF.database.mysql_storage_engine, |
|
92 mysql_DEFAULT_CHARSET='UTF8' |
|
93 ) |
|
94 # end Alembic commands |
|
95 --- ironic-2015.1.2/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py.orig 2016-07-29 12:26:04.346647881 -0600 |
|
96 +++ ironic-2015.1.2/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py 2016-07-28 14:06:28.683182607 -0600 |
|
97 @@ -29,7 +29,7 @@ import sqlalchemy as sa |
|
98 def upgrade(): |
|
99 op.add_column( |
|
100 'conductors', |
|
101 - sa.Column('online', sa.Boolean(), default=True)) |
|
102 + sa.Column('online', sa.Boolean(), default=True, quote=True)) |
|
103 op.add_column( |
|
104 'nodes', |
|
105 sa.Column('conductor_affinity', sa.Integer(), |
|
106 @@ -42,4 +42,4 @@ def downgrade(): |
|
107 op.drop_constraint('nodes_conductor_affinity_fk', 'nodes', |
|
108 type_='foreignkey') |
|
109 op.drop_column('nodes', 'conductor_affinity') |
|
110 - op.drop_column('conductors', 'online') |
|
111 + op.drop_column('conductors', 'online', quote=True) |
|