¡@

Home 

OpenStack Study: 001_init.py

OpenStack Index

**** CubicPower OpenStack Study ****

def upgrade(migrate_engine):

    meta = MetaData()

    meta.bind = migrate_engine

    bm_nodes = Table('bm_nodes', meta,

        Column('created_at', DateTime),

        Column('updated_at', DateTime),

        Column('deleted_at', DateTime),

        Column('deleted', Boolean),

        Column('id', Integer, primary_key=True, nullable=False),

        Column('cpus', Integer),

        Column('memory_mb', Integer),

        Column('local_gb', Integer),

        Column('pm_address', String(length=255)),

        Column('pm_user', String(length=255)),

        Column('pm_password', String(length=255)),

        Column('service_host', String(length=255)),

        Column('prov_mac_address', String(length=255)),

        Column('instance_uuid', String(length=36)),

        Column('registration_status', String(length=16)),

        Column('task_state', String(length=255)),

        Column('prov_vlan_id', Integer),

        Column('terminal_port', Integer),

        mysql_engine='InnoDB',

        #mysql_charset='utf8'

    )

    bm_interfaces = Table('bm_interfaces', meta,

        Column('created_at', DateTime),

        Column('updated_at', DateTime),

        Column('deleted_at', DateTime),

        Column('deleted', Boolean),

        Column('id', Integer, primary_key=True, nullable=False),

        Column('bm_node_id', Integer),

        Column('address', String(length=255), unique=True),

        Column('datapath_id', String(length=255)),

        Column('port_no', Integer),

        Column('vif_uuid', String(length=36), unique=True),

        mysql_engine='InnoDB',

        #mysql_charset='utf8'

    )

    bm_pxe_ips = Table('bm_pxe_ips', meta,

        Column('created_at', DateTime),

        Column('updated_at', DateTime),

        Column('deleted_at', DateTime),

        Column('deleted', Boolean),

        Column('id', Integer, primary_key=True, nullable=False),

        Column('address', String(length=255), unique=True),

        Column('bm_node_id', Integer),

        Column('server_address', String(length=255), unique=True),

        mysql_engine='InnoDB',

        #mysql_charset='utf8'

    )

    bm_deployments = Table('bm_deployments', meta,

        Column('created_at', DateTime),

        Column('updated_at', DateTime),

        Column('deleted_at', DateTime),

        Column('deleted', Boolean),

        Column('id', Integer, primary_key=True, nullable=False),

        Column('bm_node_id', Integer),

        Column('key', String(length=255)),

        Column('image_path', String(length=255)),

        Column('pxe_config_path', String(length=255)),

        Column('root_mb', Integer),

        Column('swap_mb', Integer),

        mysql_engine='InnoDB',

        #mysql_charset='utf8'

    )

    bm_nodes.create()

    bm_interfaces.create()

    bm_pxe_ips.create()

    bm_deployments.create()

    Index('idx_bm_nodes_service_host_deleted',

          bm_nodes.c.service_host, bm_nodes.c.deleted)\

          .create(migrate_engine)

    Index('idx_bm_nodes_instance_uuid_deleted',

          bm_nodes.c.instance_uuid, bm_nodes.c.deleted)\

          .create(migrate_engine)

    Index('idx_bm_nodes_hmcld',

          bm_nodes.c.service_host, bm_nodes.c.memory_mb, bm_nodes.c.cpus,

          bm_nodes.c.local_gb, bm_nodes.c.deleted)\

          .create(migrate_engine)

    Index('idx_bm_interfaces_bm_node_id_deleted',

          bm_interfaces.c.bm_node_id, bm_interfaces.c.deleted)\

          .create(migrate_engine)

    Index('idx_bm_pxe_ips_bm_node_id_deleted',

          bm_pxe_ips.c.bm_node_id, bm_pxe_ips.c.deleted)\

          .create(migrate_engine)

**** CubicPower OpenStack Study ****

def downgrade(migrate_engine):

    raise NotImplementedError('Downgrade from 001_init is unsupported.')