예제 #1
0
    def create(self, args, config, connection):
        forest = Forest(args['name'],
                        args['forest_host'],
                        connection=connection)
        if forest.exists():
            self.logger.error("Forest already exists: {0}".format(
                args['name']))
            sys.exit(1)

        if args['json'] is not None:
            forest = self._read(args['name'], args['json'])
            if forest.host() is None:
                forest.set_host(args['forest_host'])

        self._properties(forest, args)
        dbname = forest.database()

        if dbname is not None:
            database = Database(dbname)
            database.read(connection)
        else:
            database = None

        self.logger.info("Create forest {0}...".format(args['name']))
        forest.create(connection=connection)

        if database is not None:
            database.add_forest_name(forest.forest_name())
            database.update(connection)
예제 #2
0
    def create(self, args, config, connection):
        forest = Forest(args['name'], args['forest_host'], connection=connection)
        if forest.exists():
            self.logger.error("Forest already exists: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            forest = self._read(args['name'], args['json'])
            if forest.host() is None:
                forest.set_host(args['forest_host'])

        self._properties(forest, args)
        dbname = forest.database()

        if dbname is not None:
            database = Database(dbname)
            database.read(connection)
        else:
            database = None

        self.logger.info("Create forest {0}...".format(args['name']))
        forest.create(connection=connection)

        if database is not None:
            database.add_forest_name(forest.forest_name())
            database.update(connection)
예제 #3
0
    def modify(self, args, config, connection):
        forest = Database(args['name'], connection=connection)
        if not forest.exists():
            print("Error: Forest does not exist: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            forest = self._read(args['name'], args['json'])
            if forest.host() is None:
                forest.set_host(args['forest_host'])

        self._properties(forest, args)
        print("Modify forest {0}...".format(args['name']))
        forest.update(connection=connection)
예제 #4
0
    def modify(self, args, config, connection):
        forest = Database(args['name'], connection=connection)
        if not forest.exists():
            print("Error: Forest does not exist: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            forest = self._read(args['name'], args['json'])
            if forest.host() is None:
                forest.set_host(args['forest_host'])

        self._properties(forest, args)
        print("Modify forest {0}...".format(args['name']))
        forest.update(connection=connection)
예제 #5
0
    def modify(self, args, config, connection):
        database = Database(args['name'], connection=connection)
        if not database.exists():
            print("Error: Database does not exist: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            database = self._read(args['name'], args['json'])

        self.forests = []
        self._properties(database, args)
        if len(self.forests) > 0:
            database.set_forest_names(self.forests)

        print("Modify database {0}...".format(args['name']))
        database.update(connection=connection)
    def modify(self, args, config, connection):
        database = Database(args['name'], connection=connection)
        if not database.exists():
            print("Error: Database does not exist: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            database = self._read(args['name'], args['json'])

        self.forests = []
        self._properties(database, args)
        if len(self.forests) > 0:
            database.set_forest_names(self.forests)

        print("Modify database {0}...".format(args['name']))
        database.update(connection=connection)
예제 #7
0
    def create(self, args, config, connection):
        name = args['name']
        host = args['forest_host']

        if args['json'] is not None:
            forest = self._read(name, args['json'], connection=connection)
            name = forest.forest_name()
            host = forest.host()
        else:
            forest = Forest(name, host, connection=connection)

        if forest.exists():
            self.logger.error("Forest already exists: {0}".format(name))
            sys.exit(1)

        self._properties(forest, args)
        dbname = forest.database()

        # Strip out properties that we know the server will reject
        cluster = LocalCluster(connection)
        cluster.read()
        if cluster.security_version() is None:
            for key in ['database-replication', 'failover-enable']:
                if key in forest._config:
                    del(forest._config[key])
                    self.logger.debug("Ignoring {0}, not supported by server"
                                      .format(key))

        if dbname is not None:
            database = Database(dbname)
            database.read(connection)
        else:
            database = None

        self.logger.info("Create forest {0}...".format(name))
        forest.create(connection=connection)

        if database is not None:
            database.add_forest_name(forest.forest_name())
            database.update(connection)
예제 #8
0
    def create(self, args, config, connection):
        name = args['name']
        host = args['forest_host']

        if args['json'] is not None:
            forest = self._read(name, args['json'], connection=connection)
            name = forest.forest_name()
            host = forest.host()
        else:
            forest = Forest(name, host, connection=connection)

        if forest.exists():
            self.logger.error("Forest already exists: {0}".format(name))
            sys.exit(1)

        self._properties(forest, args)
        dbname = forest.database()

        # Strip out properties that we know the server will reject
        cluster = LocalCluster(connection)
        cluster.read()
        if cluster.security_version() is None:
            for key in ['database-replication', 'failover-enable']:
                if key in forest._config:
                    del (forest._config[key])
                    self.logger.debug(
                        "Ignoring {0}, not supported by server".format(key))

        if dbname is not None:
            database = Database(dbname)
            database.read(connection)
        else:
            database = None

        self.logger.info("Create forest {0}...".format(name))
        forest.create(connection=connection)

        if database is not None:
            database.add_forest_name(forest.forest_name())
            database.update(connection)
# Create databases
for config in data['databases']:
    name = config['database-name']
    db = Database.lookup(conn, name)
    if db is None:
        print("Need to create database: {0}".format(name))
        db = Database(name)
        db.create(conn)

# Update databases
for config in data['databases']:
    name = config['database-name']
    db = Database.unmarshal(config)
    print("Updating database: {0}".format(name))
    db.update(conn)

# Update servers
for config in data['servers']:
    name = config['server-name']
    group = config['group-name']
    server = Server.lookup(conn, name, group)

    if server is None:
        verb = "Creating"
        server = Server.unmarshal(config)
        print("{0} server: {1}".format(verb, name))
        server.create(conn)
    else:
        verb = "Updating"
        server = Server.unmarshal(config)