Пример #1
0
    def execute(self, arguments, properties):
        host = arguments.h
        Fail.fail_on_no_host(host)
        self.fail_on_blocked_hosts(host, properties)

        default_schemes = properties.get_property('schemes')
        schemes = Ora.nvl(arguments.s, default_schemes)
        Fail.fail_on_invalid_schema(arguments.s, properties)

        default_environment = properties.get_property('default_environment')
        environment = Ora.nvl(arguments.e, default_environment)
        Fail.fail_on_invalid_environment(arguments.e, properties)

        database = properties.get_property('database')
        objects = properties.get_property('drop_objects')

        # alias = arguments.a
        # Fail.fail_on_invalid_alias(arguments.a, properties)
        #
        # # if an alias is given, only the alias database will be installed, other databases will be ignored.
        # if alias:
        #     print "using alias :" + alias
        #     databases = [alias]

        for schema in schemes:
            print "dropping schema '" + schema + "' in database '" + database + "on host '" + host + "' using environment '" + environment + "'"

            users = properties.get_property('mssql_users')
            username = PropertyHelper.get_mssql_user(users, host, schema)
            password = PropertyHelper.get_mssql_password(users, host, schema)

            connector = self.get_connector()

            executor = {}
            executor['host'] = host
            executor['database'] = database
            executor['schema'] = schema
            executor['username'] = username
            executor['password'] = password

            for object in objects:
                folder = File(
                    os.path.join(self.get_drop_dir(properties), object))
                ConnectionExecutor.execute(connector, executor, properties,
                                           folder)

            print "schema '" + schema + "' dropped."
Пример #2
0
    def execute(self, arguments, properties):
        properties.set_property(
            'create.dir',
            os.path.join(properties.get_property('current.dir'), 'create'))
        properties.set_property(
            'alter.dir',
            os.path.join(properties.get_property('current.dir'), 'alter'))

        host = arguments.h
        Fail.fail_on_no_host(host)

        version = arguments.v
        Fail.fail_on_no_version(version)

        default_schemes = properties.get_property('schemes')
        schemes = Ora.nvl(arguments.s, default_schemes)
        Fail.fail_on_invalid_schema(arguments.s, properties)

        default_environment = properties.get_property('default_environment')
        environment = Ora.nvl(arguments.e, default_environment)
        Fail.fail_on_invalid_environment(arguments.e, properties)

        database = properties.get_property('database')
        objects = properties.get_property('create_objects')

        version_schema = properties.get_property('version_schema')

        alter_dir = properties.get_property('alter.dir')

        self.fail_on_unknown_version(version, properties)

        # alias = arguments.a
        # database_aliases = properties.get_property('database_aliases')
        # Fail.fail_on_invalid_alias(alias, properties)
        #
        # # if an alias is given, only this database will be installed, other databases will be ignored.
        # if alias:
        #     print "using alias :" + alias
        #     databases = [alias]

        connector = self.get_connector()

        for schema in schemes:
            print "updating schema '" + schema + "' in database '" + database + "' on host '" + host + "' using environment '" + environment + "'"

            users = properties.get_property('mssql_users')
            username = PropertyHelper.get_mssql_user(users, host, schema)
            password = PropertyHelper.get_mssql_password(users, host, schema)

            executor = {}
            executor['host'] = host
            executor['database'] = database
            executor['username'] = username
            executor['password'] = password

            # database_folder = PropertyHelper.get_database_folder(database, database_aliases)

            if schema == version_schema:
                self.fail_on_invalid_environment(connector, executor,
                                                 environment, properties)
                self.fail_on_invalid_version(connector, executor, version,
                                             properties)

            for object in objects:
                # global ddl objects
                folder = File(
                    os.path.join(alter_dir, version, schema, 'ddl', object))
                ConnectionExecutor.execute(connector, executor, properties,
                                           folder)

                # environment specific ddl objects
                folder = File(
                    os.path.join(alter_dir, version, schema, 'ddl', object,
                                 environment))
                ConnectionExecutor.execute(connector, executor, properties,
                                           folder)

            # global dat objects
            folder = File(os.path.join(alter_dir, version, schema, 'dat'))
            ConnectionExecutor.execute(connector, executor, properties, folder)

            # environment specific dat objects
            folder = File(
                os.path.join(alter_dir, version, schema, 'dat', environment))
            ConnectionExecutor.execute(connector, executor, properties, folder)

            print "database '" + database + "' updated."