예제 #1
0
def main():

    # In this example, we are YOURNAME
    myName = "Charlie"

    # This file defines the network of virtual quantum nodes
    simulaqron_path = get_simulaqron_path.main()
    virtualFile = os.path.join(simulaqron_path, "config/virtualNodes.cfg")

    # This file defines the nodes acting as servers in the classical communication network
    classicalFile = os.path.join(os.path.dirname(__file__), "classicalNet.cfg")

    # Read configuration files for the virtual quantum, as well as the classical network
    virtualNet = socketsConfig(virtualFile)
    classicalNet = socketsConfig(classicalFile)

    # Check if we should run a local classical server. If so, initialize the code
    # to handle remote connections on the classical communication network
    if myName in classicalNet.hostDict:
        lNode = localNode(classicalNet.hostDict[myName], classicalNet)
    else:
        lNode = None

        # Set up the local classical server if applicable, and connect to the virtual
        # node and other classical servers. Once all connections are set up, this will
        # execute the function runClientNode
    setup_local(myName, virtualNet, classicalNet, lNode, runClientNode)
def main():

    # In this example, we are Bob.
    myName = "Repeater1"

    # This file defines the network of virtual quantum nodes
    simulaqron_path = get_simulaqron_path.main()
    virtualFile = os.path.join(simulaqron_path, "config/virtualNodes.cfg")

    # This file defines the nodes acting as servers in the classical communication network
    classicalFile = "repeater1_classical_net.cfg"

    # Read configuration files for the virtual quantum, as well as the classical network
    virtualNet = socketsConfig(virtualFile)
    classicalNet = socketsConfig(classicalFile)

    # Check if we should run a local classical server. If so, initialize the code
    # to handle remote connections on the classical communication network
    if myName in classicalNet.hostDict:
        lNode = localNode(classicalNet.hostDict[myName], classicalNet)
        logging.debug("LOCAL %s: Initialise a classical server..: %s.", myName, lNode)
    else:
        lNode = None
        logging.debug("LOCAL %s: No initialisation of classical server..: %s.", myName, lNode)

        # Set up the local classical server if applicable, and connect to the virtual
        # node and other classical servers. Once all connections are set up, this will
        # execute the function runClientNode
    setup_local(myName, virtualNet, classicalNet, lNode, runClientNode)
예제 #3
0
def main():

    # In this example, we are Bob.
    myName = "Bob"

    # This file defines the network of virtual quantum nodes
    network_file = simulaqron_settings.network_config_file

    # This file defines the nodes acting as servers in the classical communication network
    classicalFile = "classicalNet.cfg"

    # Read configuration files for the virtual quantum, as well as the classical network
    virtualNet = socketsConfig(network_file)
    classicalNet = socketsConfig(classicalFile)

    # Check if we should run a local classical server. If so, initialize the code
    # to handle remote connections on the classical communication network
    if myName in classicalNet.hostDict:
        lNode = localNode(classicalNet.hostDict[myName], classicalNet)
    else:
        lNode = None

        # Set up the local classical server if applicable, and connect to the virtual
        # node and other classical servers. Once all connections are set up, this will
        # execute the function runClientNode
    setup_local(myName, virtualNet, classicalNet, lNode, runClientNode)
예제 #4
0
    def test_load_file(self):
        file_path1 = os.path.join(PATH_TO_HERE, "resources", "sockets.cfg")
        conf1 = socketsConfig(file_path1)

        file_path2 = os.path.join(PATH_TO_HERE, "resources", "network.json")
        conf2 = socketsConfig(file_path2, config_type="cqc")

        for node_name, host in conf1.hostDict.items():
            self.assertEqual(host.port, conf2.hostDict[node_name].port)
            self.assertEqual(host.hostname, conf2.hostDict[node_name].hostname)
예제 #5
0
def main(myName, network_name="default"):
    """Start the indicated backend CQC Server"""
    signal.signal(signal.SIGTERM, sigterm_handler)
    signal.signal(signal.SIGINT, sigterm_handler)

    logging.basicConfig(
        format="%(asctime)s:%(levelname)s:%(message)s",
        level=simulaqron_settings.log_level,
    )

    if simulaqron_settings.network_config_file is not None:
        # Since version 3.0.0 a single config file is used
        virtualFile = simulaqron_settings.network_config_file
        cqcFile = simulaqron_settings.network_config_file
    else:
        # This file defines the network of virtual quantum nodes
        virtualFile = simulaqron_settings.vnode_file

        # This file defines the network of CQC servers interfacing to virtual quantum nodes
        cqcFile = simulaqron_settings.cqc_file

    # Read configuration files for the virtual quantum, as well as the classical network
    virtualNet = socketsConfig(virtualFile, network_name=network_name, config_type="vnode")
    cqcNet = socketsConfig(cqcFile, network_name=network_name, config_type="cqc")

    # Check if we are in the host-dictionary
    if myName in cqcNet.hostDict:
        myHost = cqcNet.hostDict[myName]
        cqc_factory = CQCFactory(myHost, myName, cqcNet, SimulaqronCQCHandler, network_name=network_name)
    else:
        logging.error("LOCAL %s: Cannot start classical communication servers.", myName)
        return

        # Connect to the local virtual node simulating the "local" qubits
    connect_to_virtNode(myName, cqc_factory, virtualNet)

    # Run reactor
    reactor.run()
예제 #6
0
    def _get_net_configs(self, use_classical_communication, backend,
                         network_name):
        cqc_net = None
        app_net = None
        if backend is None or backend == "simulaqron":
            if _simulaqron_major < 3:
                raise ValueError(
                    "If (socket_address is None or use_classical_communication is True)"
                    "and (backend is None or 'simulaqron'\n"
                    "you need simulaqron>=3.0.0 installed.")
            else:
                network_config_file = simulaqron_settings.network_config_file
                cqc_net = socketsConfig(network_config_file,
                                        network_name=network_name,
                                        config_type="cqc")
                if use_classical_communication:
                    app_net = socketsConfig(network_config_file,
                                            network_name=network_name,
                                            config_type="app")
        else:
            raise ValueError("Unknown backend")

        return cqc_net, app_net
예제 #7
0
    def setup_node(name, node_code, classical_net_file, send_end):
        # This file defines the network of virtual quantum nodes
        virtualFile = os.path.join(os.path.dirname(__file__), "configs",
                                   "network.json")

        # This file defines the nodes acting as servers in the classical communication network
        classicalFile = os.path.join(os.path.dirname(__file__), "configs",
                                     classical_net_file)

        # Read configuration files for the virtual quantum, as well as the classical network
        virtualNet = socketsConfig(virtualFile)
        classicalNet = socketsConfig(classicalFile)

        # Check if we should run a local classical server. If so, initialize the code
        # to handle remote connections on the classical communication network
        if name in classicalNet.hostDict:
            lNode = localNode(classicalNet.hostDict[name], classicalNet)
        else:
            lNode = None

        # Set up the local classical server if applicable, and connect to the virtual
        # node and other classical servers. Once all connections are set up, this will
        # execute the function runClientNode
        setup_local(name, virtualNet, classicalNet, lNode, node_code, send_end)