<s> """<STR_LIT>""" <EOL> revision = '<STR_LIT>' <EOL> down_revision = '<STR_LIT>' <EOL> from alembic import op <EOL> from oslo_serialization import jsonutils <EOL> import sqlalchemy as sa <EOL> from sqlalchemy . dialects import postgresql <EOL> from nailgun import consts <EOL> from nailgun . db . sqlalchemy . models import fields <EOL> from nailgun . utils . migration import drop_enum <EOL> from nailgun . utils . migration import upgrade_enum <EOL> release_states_old = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> release_states_new = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> task_statuses_old = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:error>' <EOL> ) <EOL> task_statuses_new = task_statuses_old + ( <EOL> '<STR_LIT>' , <EOL> ) <EOL> task_names_old = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> task_names_new = task_names_old + ( <EOL> '<STR_LIT>' , <EOL> ) <EOL> node_errors_old = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> node_errors_new = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> openstack_config_types = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def upgrade ( ) : <EOL> upgrade_nodegroups_name_cluster_constraint ( ) <EOL> upgrade_release_state ( ) <EOL> task_statuses_upgrade ( ) <EOL> task_names_upgrade ( ) <EOL> add_node_discover_error_upgrade ( ) <EOL> upgrade_neutron_parameters ( ) <EOL> upgrade_cluster_plugins ( ) <EOL> upgrade_add_baremetal_net ( ) <EOL> upgrade_with_components ( ) <EOL> plugin_links_upgrade ( ) <EOL> cluster_plugin_links_upgrade ( ) <EOL> upgrade_master_node_bootstrap_settings ( ) <EOL> upgrade_all_network_data_from_string_to_appropriate_data_type ( ) <EOL> create_openstack_configs_table ( ) <EOL> upgrade_master_node_ui_settings ( ) <EOL> upgrade_plugins_parameters ( ) <EOL> upgrade_oswl_stats_version_info ( ) <EOL> upgrade_nodegroups_parameters ( ) <EOL> def downgrade ( ) : <EOL> downgrade_nodegroups_parameters ( ) <EOL> downgrade_oswl_stats_version_info ( ) <EOL> downgrade_plugins_parameters ( ) <EOL> downgrade_master_node_ui_settings ( ) <EOL> downgrade_openstack_configs ( ) <EOL> downgrade_all_network_data_to_string ( ) <EOL> downgrade_master_node_bootstrap_settings ( ) <EOL> cluster_plugin_links_downgrade ( ) <EOL> plugin_links_downgrade ( ) <EOL> downgrade_with_components ( ) <EOL> downgrade_add_baremetal_net ( ) <EOL> downgrade_cluster_plugins ( ) <EOL> downgrade_neutron_parameters ( ) <EOL> add_node_discover_error_downgrade ( ) <EOL> task_names_downgrade ( ) <EOL> task_statuses_downgrade ( ) <EOL> downgrade_release_state ( ) <EOL> downgrade_nodegroups_name_cluster_constraint ( ) <EOL> def upgrade_release_state ( ) : <EOL> connection = op . get_bind ( ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> upgrade_enum ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:state>' , <EOL> '<STR_LIT>' , <EOL> release_states_old , <EOL> release_states_new , <EOL> ) <EOL> connection . execute ( sa . sql . text ( <EOL> "<STR_LIT>" ) ) <EOL> def upgrade_nodegroups_name_cluster_constraint ( ) : <EOL> connection = op . get_bind ( ) <EOL> select_query = sa . sql . text ( <EOL> "<STR_LIT>" ) <EOL> update_query = sa . sql . text ( <EOL> "<STR_LIT>" ) <EOL> ng_query = sa . sql . text ( <EOL> "<STR_LIT>" ) <EOL> for name in connection . execute ( select_query ) : <EOL> for i , data in enumerate ( connection . execute ( ng_query , name = name [ <NUM_LIT:0> ] ) ) : <EOL> connection . execute ( <EOL> update_query , <EOL> ng_id = data [ <NUM_LIT:0> ] , name = "<STR_LIT>" . format ( data [ <NUM_LIT:1> ] , i ) ) <EOL> op . create_unique_constraint ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:name>' <EOL> ] <EOL> ) <EOL> def downgrade_nodegroups_name_cluster_constraint ( ) : <EOL> op . drop_constraint ( '<STR_LIT>' , '<STR_LIT>' , ) <EOL> def upgrade_with_components ( ) : <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> fields . JSON ( ) , <EOL> server_default = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> fields . JSON ( ) , <EOL> server_default = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> fields . JSON ( ) , <EOL> nullable = False , <EOL> server_default = '<STR_LIT>' ) <EOL> ) <EOL> def create_openstack_configs_table ( ) : <EOL> op . create_table ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT:id>' , sa . Integer , nullable = False ) , <EOL> sa . Column ( '<STR_LIT>' , sa . Boolean , nullable = False ) , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> sa . Enum ( * openstack_config_types , name = '<STR_LIT>' ) , <EOL> nullable = False ) , <EOL> sa . Column ( '<STR_LIT>' , sa . Integer , nullable = False ) , <EOL> sa . Column ( '<STR_LIT>' , sa . Integer , nullable = True ) , <EOL> sa . Column ( '<STR_LIT>' , sa . String ( length = <NUM_LIT:64> ) , nullable = True ) , <EOL> sa . Column ( '<STR_LIT>' , sa . DateTime , nullable = False ) , <EOL> sa . Column ( <EOL> '<STR_LIT>' , fields . JSON , <EOL> nullable = False , server_default = '<STR_LIT:{}>' ) , <EOL> sa . ForeignKeyConstraint ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) , <EOL> sa . ForeignKeyConstraint ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) , <EOL> sa . PrimaryKeyConstraint ( '<STR_LIT:id>' ) <EOL> ) <EOL> def downgrade_openstack_configs ( ) : <EOL> op . drop_table ( '<STR_LIT>' ) <EOL> drop_enum ( '<STR_LIT>' ) <EOL> def downgrade_release_state ( ) : <EOL> connection = op . get_bind ( ) <EOL> connection . execute ( sa . sql . text ( <EOL> "<STR_LIT>" ) ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> sa . Boolean ( ) , <EOL> nullable = False , <EOL> server_default = '<STR_LIT:true>' , <EOL> ) <EOL> ) <EOL> upgrade_enum ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:state>' , <EOL> '<STR_LIT>' , <EOL> release_states_new , <EOL> release_states_old , <EOL> ) <EOL> def task_statuses_upgrade ( ) : <EOL> upgrade_enum ( '<STR_LIT>' , '<STR_LIT:status>' , '<STR_LIT>' , <EOL> task_statuses_old , task_statuses_new ) <EOL> def task_statuses_downgrade ( ) : <EOL> upgrade_enum ( '<STR_LIT>' , '<STR_LIT:status>' , '<STR_LIT>' , <EOL> task_statuses_new , task_statuses_old ) <EOL> def task_names_upgrade ( ) : <EOL> upgrade_enum ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:name>" , <EOL> "<STR_LIT>" , <EOL> task_names_old , <EOL> task_names_new <EOL> ) <EOL> def task_names_downgrade ( ) : <EOL> upgrade_enum ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:name>" , <EOL> "<STR_LIT>" , <EOL> task_names_new , <EOL> task_names_old <EOL> ) <EOL> def add_node_discover_error_upgrade ( ) : <EOL> upgrade_enum ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> node_errors_old , <EOL> node_errors_new <EOL> ) <EOL> def add_node_discover_error_downgrade ( ) : <EOL> upgrade_enum ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> node_errors_new , <EOL> node_errors_old <EOL> ) <EOL> def upgrade_neutron_parameters ( ) : <EOL> connection = op . get_bind ( ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT>' , sa . String ( length = <NUM_LIT:50> ) , nullable = True ) ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT>' , sa . String ( length = <NUM_LIT:50> ) , nullable = True ) ) <EOL> connection . execute ( sa . sql . text ( """<STR_LIT>""" ) ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , nullable = False ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , nullable = False ) <EOL> select_query = sa . sql . text ( "<STR_LIT>" ) <EOL> for id_ , networks_metadata in connection . execute ( select_query ) : <EOL> networks_metadata = jsonutils . loads ( networks_metadata ) <EOL> if networks_metadata . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) is not None : <EOL> networks_metadata [ '<STR_LIT>' ] [ '<STR_LIT>' ] . update ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> connection . execute ( <EOL> sa . sql . text ( """<STR_LIT>""" ) , <EOL> id = id_ , <EOL> networks_metadata = jsonutils . dumps ( networks_metadata ) ) <EOL> def downgrade_neutron_parameters ( ) : <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def upgrade_cluster_plugins ( ) : <EOL> op . alter_column ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> nullable = False <EOL> ) <EOL> op . drop_constraint ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> type_ = '<STR_LIT>' <EOL> ) <EOL> op . create_foreign_key ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , [ '<STR_LIT:id>' ] , <EOL> ondelete = '<STR_LIT>' <EOL> ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> sa . Boolean , <EOL> nullable = False , <EOL> server_default = '<STR_LIT:false>' <EOL> ) <EOL> ) <EOL> op . add_column ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> fields . JSON ( ) , <EOL> nullable = False , <EOL> server_default = '<STR_LIT:{}>' <EOL> ) <EOL> ) <EOL> connection = op . get_bind ( ) <EOL> q_get_plugins = sa . text ( '''<STR_LIT>''' ) <EOL> q_get_cluster_attributes = sa . text ( '''<STR_LIT>''' ) <EOL> q_update_cluster_attributes = sa . text ( '''<STR_LIT>''' ) <EOL> q_get_cluster_plugins = sa . text ( '''<STR_LIT>''' ) <EOL> q_update_cluster_plugins = sa . text ( '''<STR_LIT>''' ) <EOL> q_insert_cluster_plugins = sa . text ( '''<STR_LIT>''' ) <EOL> plugins = list ( connection . execute ( q_get_plugins ) ) <EOL> for cluster_id , editable in connection . execute ( q_get_cluster_attributes ) : <EOL> editable = jsonutils . loads ( editable ) <EOL> for plugin_id , plugin_name in plugins : <EOL> if plugin_name in editable : <EOL> attributes = editable . pop ( plugin_name ) <EOL> metadata = attributes . pop ( '<STR_LIT>' ) <EOL> if connection . execute ( q_get_cluster_plugins , <EOL> cluster_id = cluster_id , <EOL> plugin_id = plugin_id ) . first ( ) : <EOL> action = q_update_cluster_plugins <EOL> else : <EOL> action = q_insert_cluster_plugins <EOL> connection . execute ( <EOL> action , <EOL> cluster_id = cluster_id , <EOL> plugin_id = plugin_id , <EOL> enabled = metadata [ '<STR_LIT>' ] , <EOL> attributes = jsonutils . dumps ( attributes ) <EOL> ) <EOL> connection . execute ( <EOL> q_update_cluster_attributes , <EOL> cluster_id = cluster_id , <EOL> editable = jsonutils . dumps ( editable ) <EOL> ) <EOL> def downgrade_cluster_plugins ( ) : <EOL> connection = op . get_bind ( ) <EOL> q_get_cluster_attributes = sa . text ( '''<STR_LIT>''' ) <EOL> q_get_plugins = sa . text ( '''<STR_LIT>''' ) <EOL> q_update_cluster_attributes = sa . text ( '''<STR_LIT>''' ) <EOL> for cluster_id , editable in connection . execute ( q_get_cluster_attributes ) : <EOL> editable = jsonutils . loads ( editable ) <EOL> plugins = connection . execute ( q_get_plugins , cluster_id = cluster_id ) <EOL> for p_id , p_name , p_title , p_enabled , p_attr in plugins : <EOL> p_attr = jsonutils . loads ( p_attr ) <EOL> p_attr [ '<STR_LIT>' ] . update ( { <EOL> '<STR_LIT>' : p_id , <EOL> '<STR_LIT>' : p_enabled , <EOL> '<STR_LIT:label>' : p_title <EOL> } ) <EOL> editable [ p_name ] = p_attr <EOL> connection . execute ( q_update_cluster_attributes , <EOL> cluster_id = cluster_id , <EOL> editable = jsonutils . dumps ( editable ) ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> op . drop_constraint ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> type_ = '<STR_LIT>' <EOL> ) <EOL> op . create_foreign_key ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , [ '<STR_LIT:id>' ] <EOL> ) <EOL> op . alter_column ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> nullable = None <EOL> ) <EOL> def upgrade_add_baremetal_net ( ) : <EOL> op . add_column ( '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT>' , sa . String ( length = <NUM_LIT> ) , <EOL> nullable = True ) ) <EOL> op . add_column ( '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT>' , fields . JSON ( ) , nullable = True , <EOL> server_default = '<STR_LIT>' ) ) <EOL> def upgrade_master_node_bootstrap_settings ( ) : <EOL> connection = op . get_bind ( ) <EOL> select_query = sa . sql . text ( "<STR_LIT>" ) <EOL> master_settings = jsonutils . loads ( <EOL> connection . execute ( select_query ) . scalar ( ) ) <EOL> bootstrap_settings = { <EOL> "<STR_LIT:error>" : { <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT:value>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:10> <EOL> } <EOL> } <EOL> master_settings [ '<STR_LIT>' ] = bootstrap_settings <EOL> update_query = sa . sql . text ( <EOL> "<STR_LIT>" ) <EOL> connection . execute ( update_query , settings = jsonutils . dumps ( master_settings ) ) <EOL> def downgrade_master_node_bootstrap_settings ( ) : <EOL> connection = op . get_bind ( ) <EOL> select_query = sa . sql . text ( "<STR_LIT>" ) <EOL> master_settings = jsonutils . loads ( <EOL> connection . execute ( select_query ) . scalar ( ) ) <EOL> master_settings . pop ( '<STR_LIT>' , None ) <EOL> update_query = sa . sql . text ( <EOL> "<STR_LIT>" ) <EOL> connection . execute ( update_query , settings = jsonutils . dumps ( master_settings ) ) <EOL> def downgrade_add_baremetal_net ( ) : <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def downgrade_with_components ( ) : <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def cluster_plugin_links_upgrade ( ) : <EOL> op . create_table ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT:id>' , sa . Integer ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT>' , sa . Integer ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT:title>' , sa . Text ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT:url>' , sa . Text ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT:description>' , sa . Text ( ) ) , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> sa . Boolean ( ) , <EOL> nullable = False , <EOL> server_default = '<STR_LIT:false>' <EOL> ) , <EOL> sa . ForeignKeyConstraint ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] , ) , <EOL> sa . PrimaryKeyConstraint ( '<STR_LIT:id>' ) <EOL> ) <EOL> op . create_index ( '<STR_LIT>' , <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> def cluster_plugin_links_downgrade ( ) : <EOL> op . drop_table ( '<STR_LIT>' ) <EOL> def plugin_links_upgrade ( ) : <EOL> op . create_table ( <EOL> '<STR_LIT>' , <EOL> sa . Column ( '<STR_LIT:id>' , sa . Integer ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT>' , sa . Integer ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT:title>' , sa . Text ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT:url>' , sa . Text ( ) , nullable = False ) , <EOL> sa . Column ( '<STR_LIT:description>' , sa . Text ( ) ) , <EOL> sa . Column ( <EOL> '<STR_LIT>' , <EOL> sa . Boolean ( ) , <EOL> nullable = False , <EOL> server_default = '<STR_LIT:false>' <EOL> ) , <EOL> sa . ForeignKeyConstraint ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] , ) , <EOL> sa . PrimaryKeyConstraint ( '<STR_LIT:id>' ) <EOL> ) <EOL> op . create_index ( '<STR_LIT>' , <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> def plugin_links_downgrade ( ) : <EOL> op . drop_table ( '<STR_LIT>' ) <EOL> def upgrade_all_network_data_from_string_to_appropriate_data_type ( ) : <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> convert_column_type ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def convert_column_type ( table_name , column_name , psql_type ) : <EOL> op . execute ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( table_name , <EOL> column_name , <EOL> psql_type ) ) <EOL> def downgrade_all_network_data_to_string ( ) : <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , type_ = sa . String ( length = <NUM_LIT> ) ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , <EOL> type_ = fields . LowercaseString ( <NUM_LIT> ) ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , <EOL> type_ = sa . String ( length = <NUM_LIT> ) ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , <EOL> type_ = sa . String ( length = <NUM_LIT> ) ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , type_ = fields . LowercaseString ( <NUM_LIT> ) ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:15> ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , <EOL> type_ = fields . LowercaseString ( <NUM_LIT> ) ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> ip_type_to_string ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , type_ = sa . String ( length = <NUM_LIT:50> ) ) <EOL> def ip_type_to_string ( table_name , column_name , string_len ) : <EOL> op . execute ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( table_name , <EOL> column_name , <EOL> string_len ) <EOL> ) <EOL> def upgrade_master_node_ui_settings ( ) : <EOL> connection = op . get_bind ( ) <EOL> q_get_master_node_data = sa . text ( '''<STR_LIT>''' ) <EOL> q_update_master_node_settings = sa . text ( '''<STR_LIT>''' ) <EOL> master_node_data = connection . execute ( q_get_master_node_data ) <EOL> for master_node_uid , settings in master_node_data : <EOL> master_node_settings = jsonutils . loads ( settings ) <EOL> master_node_settings . update ( { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : [ { '<STR_LIT:status>' : '<STR_LIT>' } ] , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } ) <EOL> connection . execute ( q_update_master_node_settings , <EOL> master_node_uid = master_node_uid , <EOL> settings = jsonutils . dumps ( master_node_settings ) ) <EOL> alter_settings = sa . sql . text ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> connection . execute ( alter_settings ) <EOL> op . alter_column ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> nullable = True , <EOL> existing_nullable = False , <EOL> server_default = '<STR_LIT:{}>' <EOL> ) <EOL> def downgrade_master_node_ui_settings ( ) : <EOL> connection = op . get_bind ( ) <EOL> op . alter_column ( '<STR_LIT>' , '<STR_LIT>' , <EOL> nullable = True , server_default = False , <EOL> type_ = sa . Text ) <EOL> q_get_master_node_data = sa . text ( '''<STR_LIT>''' ) <EOL> q_update_master_node_settings = sa . text ( '''<STR_LIT>''' ) <EOL> master_node_data = connection . execute ( q_get_master_node_data ) <EOL> for master_node_uid , settings in master_node_data : <EOL> master_node_settings = jsonutils . loads ( settings ) <EOL> del master_node_settings [ '<STR_LIT>' ] <EOL> connection . execute ( q_update_master_node_settings , <EOL> master_node_uid = master_node_uid , <EOL> settings = jsonutils . dumps ( master_node_settings ) ) <EOL> def upgrade_plugins_parameters ( ) : <EOL> op . add_column ( <EOL> '<STR_LIT>' , sa . Column ( '<STR_LIT>' , sa . Boolean ( ) , nullable = True ) <EOL> ) <EOL> def downgrade_plugins_parameters ( ) : <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def upgrade_oswl_stats_version_info ( ) : <EOL> op . add_column ( <EOL> '<STR_LIT>' , sa . Column ( '<STR_LIT>' , postgresql . JSON , <EOL> nullable = True , server_default = '<STR_LIT:{}>' ) <EOL> ) <EOL> def downgrade_oswl_stats_version_info ( ) : <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def upgrade_nodegroups_parameters ( ) : <EOL> connection = op . get_bind ( ) <EOL> op . add_column ( '<STR_LIT>' , sa . Column ( '<STR_LIT>' , sa . Boolean ( ) , <EOL> nullable = False , <EOL> server_default = '<STR_LIT:false>' , <EOL> index = True ) ) <EOL> update_query = sa . text ( '''<STR_LIT>''' ) <EOL> connection . execute ( update_query , is_default = True , <EOL> default_nodegroup_name = consts . NODE_GROUPS . default ) <EOL> def downgrade_nodegroups_parameters ( ) : <EOL> op . drop_column ( '<STR_LIT>' , '<STR_LIT>' ) </s>
