Ejemplo n.º 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}
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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"])
Ejemplo n.º 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"])
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 8
0
 def keyhash(self, input):
   return jenkins.hashlittle(input) & self.size