示例#1
0
async def calculate_crush(key: str = Form(...)):
    c = crush.Crush()
    c.parse(json.loads(get_current_map()))
    hashed_val = jenkins.hashlittle(key) % 2147483647
    print(hashed_val)
    ans = c.map(rule="data", value=hashed_val, replication_count=3)
    return {'device_list': ans}
示例#2
0
def import_edge_to_ubigraph(u, edge):
    """xmlrpc server, dict -> NoneType

        Takes an xml rpc server and a edge dictionary and sends
         the edge to the ubigraph server.
         
    """
    # Create a copy of the edge
    e = edge.copy()

    # Hash the source/target to make an ID for the edge
    edgeID = jenkins.hashlittle("{0}{1}".format(e["source"], e["target"]))
    sourceID = jenkins.hashlittle(e.pop("source"))
    targetID = jenkins.hashlittle(e.pop("target"))

    # Create the node
    u.new_edge_w_id(edgeID, sourceID, targetID)
示例#3
0
def import_edge_to_ubigraph(u, edge):
    """xmlrpc server, dict -> NoneType

        Takes an xml rpc server and a edge dictionary and sends
         the edge to the ubigraph server.
         
    """
    # Create a copy of the edge
    e = edge.copy()

    # Hash the source/target to make an ID for the edge
    edgeID = jenkins.hashlittle("{0}{1}".format(e["source"], e["target"]))
    sourceID = jenkins.hashlittle(e.pop("source"))
    targetID = jenkins.hashlittle(e.pop("target"))

    # Create the node
    u.new_edge_w_id(edgeID, sourceID, targetID)
示例#4
0
def import_node_to_ubigraph(u, node):
    """xmlrpc server, dict -> NoneType 

        Takes an xml rpc server and a node dictionary and sends
         the node to the ubigraph server.
         
    """
    name = jenkins.hashlittle(node["name"])

    # Create Node
    u.new_vertex_w_id(name)

    # Add node name as a label
    u.set_vertex_attribute(name, "label", node["name"])
示例#5
0
def import_node_to_ubigraph(u, node):
    """xmlrpc server, dict -> NoneType 

        Takes an xml rpc server and a node dictionary and sends
         the node to the ubigraph server.
         
    """
    name = jenkins.hashlittle(node["name"])

    # Create Node
    u.new_vertex_w_id(name)

    # Add node name as a label
    u.set_vertex_attribute(name, "label", node["name"])
示例#6
0
def import_edge_to_gephi(graph_ws, edge):
    """websocket, dict -> NoneType

        Takes a websocket and a edge dictionary and adds the edge to
          gephi through a websocket.

    """
    # Make sure the edge is directional
    edge["directed"] = True
    
    # Hash the source/target to make an ID for the edge
    edgeID = jenkins.hashlittle("{0}{1}".format(edge["source"], edge["target"]))

    # Create the string formatted for the gephi websocket plugin
    s = json.dumps({"ae":{edgeID:edge}})

    # Add the edge with attributes
    graph_ws.send(s)
示例#7
0
def import_edge_to_gephi(graph_ws, edge):
    """websocket, dict -> NoneType

        Takes a websocket and a edge dictionary and adds the edge to
          gephi through a websocket.

    """
    # Make sure the edge is directional
    edge["directed"] = True

    # Hash the source/target to make an ID for the edge
    edgeID = jenkins.hashlittle("{0}{1}".format(edge["source"],
                                                edge["target"]))

    # Create the string formatted for the gephi websocket plugin
    s = json.dumps({"ae": {edgeID: edge}})

    # Add the edge with attributes
    graph_ws.send(s)
示例#8
0
 def keyhash(self, input):
   return jenkins.hashlittle(input) & self.size