"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/common/sql/expand_repo/versions/056_expand_add_application_credential_access_rules.py" (13 May 2020, 1839 Bytes) of package /linux/misc/openstack/keystone-17.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "056_expand_add_application_credential_access_rules.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 16.0.1_vs_17.0.0.

    1 # Copyright 2019 SUSE Linux GmbH
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 # not use this file except in compliance with the License. You may obtain
    5 # a copy of the License at
    6 #
    7 #      http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 # License for the specific language governing permissions and limitations
   13 # under the License.
   14 
   15 import sqlalchemy as sql
   16 
   17 
   18 def upgrade(migrate_engine):
   19     meta = sql.MetaData()
   20     meta.bind = migrate_engine
   21 
   22     application_credential = sql.Table(
   23         'application_credential', meta, autoload=True)
   24     access_rule = sql.Table(
   25         'access_rule', meta,
   26         sql.Column('id', sql.Integer, primary_key=True, nullable=False),
   27         sql.Column('service', sql.String(64)),
   28         sql.Column('path', sql.String(128)),
   29         sql.Column('method', sql.String(16)),
   30         mysql_engine='InnoDB', mysql_charset='utf8'
   31     )
   32     app_cred_access_rule = sql.Table(
   33         'application_credential_access_rule', meta,
   34         sql.Column('application_credential_id', sql.Integer,
   35                    sql.ForeignKey(application_credential.c.internal_id,
   36                                   ondelete='CASCADE'),
   37                    primary_key=True, nullable=False),
   38         sql.Column('access_rule_id', sql.Integer,
   39                    sql.ForeignKey(access_rule.c.id,
   40                                   ondelete='CASCADE'),
   41                    primary_key=True, nullable=False),
   42         mysql_engine='InnoDB', mysql_charset='utf8'
   43     )
   44     access_rule.create(migrate_engine, checkfirst=True)
   45     app_cred_access_rule.create(migrate_engine, checkfirst=True)