def _validate_and_prepare(self, properties, arguments): prepared_args = {} host = arguments.get('host') Fail.fail_on_no_host(host) Fail.fail_on_invalid_host(host, properties) prepared_args['host'] = host environment = arguments.get('environment') default_environment = properties.get('default_environment') environment = Ora.nvl(environment, default_environment) Fail.fail_on_invalid_environment(environment, properties) prepared_args['environment'] = environment alias = arguments.get('alias') 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: {}".format(alias)) prepared_args['databases'] = [alias] else: database = arguments.get('database') Fail.fail_on_invalid_database(database, properties) default_databases = properties.get('databases') databases = Ora.nvl(database, default_databases) prepared_args['databases'] = databases return prepared_args
def _validate_and_prepare(self, properties, arguments): prepared_args = {} host = arguments.get('host') Fail.fail_on_no_host(host) Fail.fail_on_invalid_host(host, properties) prepared_args['host'] = host environment = arguments.get('environment') default_environment = properties.get('default_environment') environment = Ora.nvl(environment, default_environment) Fail.fail_on_invalid_environment(environment, properties) prepared_args['environment'] = environment return prepared_args
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."
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_databases = properties.get_property('databases') databases = Ora.nvl(arguments.d, default_databases) Fail.fail_on_invalid_database(arguments.d, properties) default_environment = properties.get_property('default_environment') environment = Ora.nvl(arguments.e, default_environment) Fail.fail_on_invalid_environment(arguments.e, properties) objects = properties.get_property('create_objects') version_database = properties.get_property('version_database') 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 database in databases: print "updating database '" + database + "' on host '" + host + "' using environment '" + environment + "'" users = properties.get_property('mysql_users') username = PropertyHelper.get_mysql_user(users, host, database) password = PropertyHelper.get_mysql_passwd(users, host, database) executor = {} executor['host'] = host executor['database'] = database executor['username'] = username executor['password'] = password database_folder = PropertyHelper.get_database_folder( database, database_aliases) if database == version_database: 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, database_folder, 'ddl', object)) ConnectionExecutor.execute(connector, executor, properties, folder) # environment specific ddl objects folder = File( os.path.join(alter_dir, version, database_folder, 'ddl', object, environment)) ConnectionExecutor.execute(connector, executor, properties, folder) # global dat objects folder = File( os.path.join(alter_dir, version, database_folder, 'dat')) ConnectionExecutor.execute(connector, executor, properties, folder) # environment specific dat objects folder = File( os.path.join(alter_dir, version, database_folder, 'dat', environment)) ConnectionExecutor.execute(connector, executor, properties, folder) print "database '" + database + "' updated."
def execute(self, arguments, properties): properties.set_property('create.dir', os.path.join(properties.get_property('current.dir'), 'create')) host = arguments.h Fail.fail_on_no_host(host) 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') # # 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() create_dir = properties.get_property('create.dir') for schema in schemes: print "creating 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) for object in objects: # global ddl objects folder = File(os.path.join(create_dir, schema, 'ddl', object)) ConnectionExecutor.execute(connector, executor, properties, folder) # environment specific ddl objects folder = File(os.path.join(create_dir, schema, 'ddl', object, environment)) ConnectionExecutor.execute(connector, executor, properties, folder) # global dat objects folder = File(os.path.join(create_dir, schema, 'dat')) ConnectionExecutor.execute(connector, executor, properties, folder) # environment specific dat objects folder = File(os.path.join(create_dir, schema, 'dat', environment)) ConnectionExecutor.execute(connector, executor, properties, folder) print "schema '" + schema + "' created."