예제 #1
0
    def isFile(self):

        node = self

        if not node:
            return False

        if not GremlinFS.operations().isFileLabel(node.get("label")):
            return False

        return True
예제 #2
0
def main(mount_point, gfs_host, gfs_port, gfs_username, gfs_password,
         **kwargs):

    try:

        logger = GFSLogger.getLogger("main")

        gfs = GremlinFS()
        gfs.configure(
            gfs_host=gfs_host,
            gfs_port=gfs_port,
            gfs_username=gfs_username,
            gfs_password=gfs_password,
        )
        GremlinFS.instance(gfs)

        operations = GremlinFSOperations()
        # operations = GremlinFSCachingOperations()
        operations.configure(mount_point=mount_point, gfs=gfs)

        FUSE(operations,
             mount_point,
             nothreads=True,
             foreground=True,
             allow_other=True)

    except Exception as e:
        logger.exception(' GremlinFS: main/init exception ', e)
예제 #3
0
    def createFolder(self):

        node = self

        label = node.get('label', None)
        name = node.get('name', None)

        if not label:
            label = GremlinFS.operations().defaultFolderLabel()

        newfolder = GFSVertex.fromV(self.api().createVertex(
            label, {"name": name}))

        return newfolder
예제 #4
0
    def parse(clazz, id):

        if not id:
            return {}

        # name@label
        # ^(.+)\@(.+)$
        matcher = GremlinFS.operations().utils().rematch(r"^(.+)\@(.+)$", id)
        if matcher:
            nodenme = matcher.group(1)
            nodelbl = matcher.group(2)
            return {"name": nodenme, "label": nodelbl}

        # default to label
        return {"label": id}
예제 #5
0
    def load(clazz, id):

        parts = clazz.parse(id)
        if parts and \
            "uuid" in parts and \
            "name" in parts and \
            "label" in parts:
            try:
                if parts["label"] == "vertex":
                    return GFSVertex.fromV(
                        GremlinFS.operations().api().vertices(
                            None, {"uuid": parts["uuid"]}))
                else:
                    return GFSVertex.fromV(
                        GremlinFS.operations().api().vertices(
                            parts["label"], {"uuid": parts["uuid"]}))
            except Exception as e:
                # self.logger.exception(' GremlinFS: node from path ID exception ', e)
                return None

        elif parts and \
            "uuid" in parts and \
            "label" in parts:
            try:
                if parts["label"] == "vertex":
                    return GFSVertex.fromV(
                        GremlinFS.operations().api().vertices(
                            None, {"uuid": parts["uuid"]}))
                else:
                    return GFSVertex.fromV(
                        GremlinFS.operations().api().vertices(
                            parts["label"], {"uuid": parts["uuid"]}))
            except Exception as e:
                # self.logger.exception(' GremlinFS: node from path ID exception ', e)
                return None

        elif parts and \
            "uuid" in parts:
            try:
                return GFSVertex.fromV(GremlinFS.operations().api().vertices(
                    None, {"uuid": parts["uuid"]}))
            except Exception as e:
                # self.logger.exception(' GremlinFS: node from path ID exception ', e)
                return None

        # Fallback try as straigt up DB id
        # OrientDB doesn't like invalid ID queries?
        elif id and ":" in id:
            try:
                return GFSVertex.fromV(GremlinFS.operations().api().vertex(id))
            except Exception as e:
                # self.logger.exception(' GremlinFS: node from path ID exception ', e)
                return None

        return None
예제 #6
0
    def parse(clazz, id):

        if not id:
            return {}

        # name.type@label@uuid
        # ^(.+)\.(.+)\@(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$
        matcher = GremlinFS.operations().utils().rematch(
            r"^(.+)\.(.+)\@(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$",
            id)
        if matcher:
            nodenme = matcher.group(1)
            nodetpe = matcher.group(2)
            nodelbl = matcher.group(3)
            nodeuid = matcher.group(4)
            return {
                "name": "%s.%s" % (nodenme, nodetpe),
                "type": nodetpe,
                "label": nodelbl,
                "uuid": nodeuid
            }

        # name@label@uuid
        # ^(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$
        matcher = GremlinFS.operations().utils().rematch(
            r"^(.+)\@(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$",
            id)
        if matcher:
            nodenme = matcher.group(1)
            nodelbl = matcher.group(2)
            nodeuid = matcher.group(3)
            return {"name": nodenme, "label": nodelbl, "uuid": nodeuid}

        # name.type@uuid
        # ^(.+)\.(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$
        matcher = GremlinFS.operations().utils().rematch(
            r"^(.+)\.(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$",
            id)
        if matcher:
            nodenme = matcher.group(1)
            nodetpe = matcher.group(2)
            nodeuid = matcher.group(3)
            return {
                "name": "%s.%s" % (nodenme, nodetpe),
                "type": nodetpe,
                "uuid": nodeuid
            }

        # name@uuid
        # ^(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$
        matcher = GremlinFS.operations().utils().rematch(
            r"^(.+)\@([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$",
            id)
        if matcher:
            nodenme = matcher.group(1)
            nodeuid = matcher.group(2)
            return {"name": nodenme, "uuid": nodeuid}

        # name.type
        # ^(.+)\.(.+)$
        matcher = GremlinFS.operations().utils().rematch(r"^(.+)\.(.+)$", id)
        if matcher:
            nodenme = matcher.group(1)
            nodetpe = matcher.group(2)
            return {"name": "%s.%s" % (nodenme, nodetpe), "type": nodetpe}

        # uuid
        # ([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})
        matcher = GremlinFS.operations().utils().rematch(
            r"^([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})$", id)
        if matcher:
            nodeuid = matcher.group(1)
            return {"uuid": nodeuid}

        # Default to name
        return {"name": id}