Example #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)
Example #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)
Example #3
0
    def modify(self, args, config, connection):
        name = args['name']
        forest = Forest(name, connection=connection)
        if not forest.exists():
            print("Error: Forest does not exist: {0}".format(name))
            sys.exit(1)

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

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

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

        self._properties(forest, args)
        print("Modify forest {0}...".format(name))
        forest.update(connection=connection)