Exemplo n.º 1
0
 def generate_uri(self, service_name=None):
     if self.cert == "full":
         raise NotImplementedError(
             "Full certificates are not yet supported")
     elif self.cert == "ssc":
         cert_key_pair = make_self_signed_certificate()
     else:
         cert_key_pair = None, None
     service = Neo4jService.single_instance(name=service_name,
                                            image_tag=self.release_str,
                                            auth=("neo4j", "password"),
                                            cert_key_pair=cert_key_pair)
     service.start()
     try:
         addresses = [
             instance.addresses[self.scheme]
             for instance in service.instances
         ]
         uris = [
             "{}://{}:{}".format(self.scheme, address.host, address.port)
             for address in addresses
         ]
         yield service, uris[0]
     finally:
         service.stop()
Exemplo n.º 2
0
def server(name, image, auth, self_signed_certificate, verbose):
    """ Start a Neo4j service in a Docker container.
    """
    con = Neo4jConsole()
    con.verbosity = verbose
    try:
        if self_signed_certificate:
            cert_key_pair = make_self_signed_certificate()
        else:
            cert_key_pair = None
        with Neo4jService.single_instance(name, image, auth, cert_key_pair) as neo4j:
            con.service = neo4j
            con.env()
            con.loop()
    except KeyboardInterrupt:
        exit(130)
    except Exception as e:
        message = " ".join(map(str, e.args))
        if hasattr(e, 'explanation'):
            message += "\n" + e.explanation
        print(message, file=stderr)
        exit(1)