Пример #1
0
def generate_certificates(nodes):
    """
    Generate a new set of certificates for the given nodes.

    :return: A ``Certificates`` instance referring to the newly generated
        certificates.
    """
    certificates_path = FilePath(mkdtemp())
    print ("Generating certificates in: {}".format(certificates_path.path))
    certificates = Certificates.generate(certificates_path, nodes[0].address, len(nodes))
    return certificates
Пример #2
0
def generate_certificates(nodes):
    """
    Generate a new set of certificates for the given nodes.

    :return: A ``Certificates`` instance referring to the newly generated
        certificates.
    """
    certificates_path = FilePath(mkdtemp())
    print("Generating certificates in: {}".format(certificates_path.path))
    certificates = Certificates.generate(certificates_path, nodes[0].address,
                                         len(nodes))
    return certificates
Пример #3
0
def generate_certificates(cluster_id, nodes):
    """
    Generate a new set of certificates for the given nodes.

    :param UUID cluster_id: The unique identifier of the cluster for which to
        generate the certificates.
    :param list nodes: The ``INode`` providers that make up the cluster.

    :return: A ``Certificates`` instance referring to the newly generated
        certificates.
    """
    certificates_path = FilePath(mkdtemp())
    print ("Generating certificates in: {}".format(certificates_path.path))
    certificates = Certificates.generate(certificates_path, nodes[0].address, len(nodes), cluster_id=cluster_id)
    return certificates
Пример #4
0
    def _setup_control_node(self, reactor, node, index):
        print "Selecting node {} for control service".format(node.name)
        certificates = Certificates.generate(
            directory=self.cert_path,
            control_hostname=node.address,
            num_nodes=0,
            cluster_name=self.identity.name,
            cluster_id=self.identity.id,
        )
        dataset_backend_config_file = save_backend_configuration(
            self.dataset_backend, self.dataset_backend_configuration
        )
        cluster = Cluster(
            all_nodes=[node],
            control_node=node,
            agent_nodes=[],
            dataset_backend=self.dataset_backend,
            default_volume_size=get_default_volume_size(
                self.dataset_backend_configuration
            ),
            certificates=certificates,
            dataset_backend_config_file=dataset_backend_config_file
        )
        commands = configure_control_node(
            cluster,
            'libcloud',
            logging_config=self.config.get('logging'),
        )
        d = perform(make_dispatcher(reactor), commands)

        def configure_failed(failure):
            print "Failed to configure control node"
            write_failure(failure)
            return failure

        # It should be sufficient to configure just the control service here,
        # but there is an assumption that the control node is both a control
        # node and an agent node.
        d.addCallbacks(
            lambda _: self._add_node_to_cluster(
                reactor, cluster, node, index
            ),
            errback=configure_failed,
        )
        # Return the cluster.
        d.addCallback(lambda _: cluster)
        return d
Пример #5
0
    def _setup_control_node(self, reactor, node, index):
        print "Selecting node {} for control service".format(node.name)
        certificates = Certificates.generate(
            directory=self.cert_path,
            control_hostname=node.address,
            num_nodes=0,
            cluster_name=self.identity.name,
            cluster_id=self.identity.id,
        )
        dataset_backend_config_file = save_backend_configuration(
            self.dataset_backend, self.dataset_backend_configuration
        )
        cluster = Cluster(
            all_nodes=[node],
            control_node=node,
            agent_nodes=[],
            dataset_backend=self.dataset_backend,
            default_volume_size=get_default_volume_size(
                self.dataset_backend_configuration
            ),
            certificates=certificates,
            dataset_backend_config_file=dataset_backend_config_file
        )
        commands = configure_control_node(
            cluster,
            'libcloud',
            logging_config=self.config.get('logging'),
        )
        d = perform(make_dispatcher(reactor), commands)

        def configure_failed(failure):
            print "Failed to configure control node"
            write_failure(failure)
            return failure

        # It should be sufficient to configure just the control service here,
        # but there is an assumption that the control node is both a control
        # node and an agent node.
        d.addCallbacks(
            lambda _: self._add_node_to_cluster(
                reactor, cluster, node, index
            ),
            errback=configure_failed,
        )
        # Return the cluster.
        d.addCallback(lambda _: cluster)
        return d
Пример #6
0
def generate_certificates(cluster_id, nodes):
    """
    Generate a new set of certificates for the given nodes.

    :param UUID cluster_id: The unique identifier of the cluster for which to
        generate the certificates.
    :param list nodes: The ``INode`` providers that make up the cluster.

    :return: A ``Certificates`` instance referring to the newly generated
        certificates.
    """
    certificates_path = FilePath(mkdtemp())
    print("Generating certificates in: {}".format(certificates_path.path))
    certificates = Certificates.generate(
        certificates_path,
        nodes[0].address,
        len(nodes),
        cluster_id=cluster_id,
    )
    return certificates
Пример #7
0
def generate_certificates(cluster_name, cluster_id, nodes, cert_path):
    """
    Generate a new set of certificates for the given nodes.

    :param bytes cluster_name: The name of the cluster.
    :param UUID cluster_id: The unique identifier of the cluster for which to
        generate the certificates.  If ``None`` then a new random identifier
        is generated.
    :param list nodes: The ``INode`` providers that make up the cluster.
    :param FilePath cert_path: The directory where the generated certificate
        files are to be placed.

    :return: A ``Certificates`` instance referring to the newly generated
        certificates.
    """
    print("Generating certificates in: {}".format(cert_path.path))
    certificates = Certificates.generate(
        cert_path,
        nodes[0].address,
        len(nodes),
        cluster_name=cluster_name,
        cluster_id=cluster_id,
    )
    return certificates
Пример #8
0
#!/usr/bin/env python

# Copyright ClusterHQ Inc.  See LICENSE file for details.
# Generates a set of cluster, node and user certificates and keys for
# use with the tutorial Vagrant box.

from twisted.python.filepath import FilePath
from flocker.provision._ca import Certificates

Certificates.generate(
    FilePath(__file__).sibling('credentials'),
    '172.16.255.250',
    2
)
Пример #9
0
def main(reactor, args, base_path, top_level):
    """
    :param reactor: Reactor to use.
    :param list args: The arguments passed to the script.
    :param FilePath base_path: The executable being run.
    :param FilePath top_level: The top-level of the flocker repository.
    """
    options = RunOptions(top_level=top_level)

    add_destination(eliot_output)
    try:
        options.parseOptions(args)
    except UsageError as e:
        sys.stderr.write("%s: %s\n" % (base_path.basename(), e))
        raise SystemExit(1)

    runner = options.runner

    try:
        nodes = yield runner.start_nodes(reactor)

        ca_directory = FilePath(mkdtemp())
        print("Generating certificates in: {}".format(ca_directory.path))
        certificates = Certificates.generate(ca_directory, nodes[0].address,
                                             len(nodes))

        yield perform(
            make_dispatcher(reactor),
            parallel([
                run_remotely(
                    username='******',
                    address=node.address,
                    commands=task_pull_docker_images()
                ) for node in nodes
            ]),
        )

        control_node = nodes[0]
        dataset_backend = options.dataset_backend

        yield perform(
            make_dispatcher(reactor),
            configure_cluster(control_node=control_node, agent_nodes=nodes,
                              certificates=certificates,
                              dataset_backend=dataset_backend))

        result = yield run_tests(
            reactor=reactor,
            nodes=nodes,
            control_node=control_node,
            agent_nodes=nodes,
            dataset_backend=dataset_backend,
            trial_args=options['trial-args'],
            certificates_path=ca_directory)
    except:
        result = 1
        raise
    finally:
        # Unless the tests failed, and the user asked to keep the nodes, we
        # delete them.
        if not (result != 0 and options['keep']):
            runner.stop_nodes(reactor)
        elif options['keep']:
            print "--keep specified, not destroying nodes."
            print ("To run acceptance tests against these nodes, "
                   "set the following environment variables: ")

            environment_variables = {
                'FLOCKER_ACCEPTANCE_NODES':
                    ':'.join(node.address for node in nodes),
                'FLOCKER_ACCEPTANCE_CONTROL_NODE': control_node.address,
                'FLOCKER_ACCEPTANCE_AGENT_NODES':
                    ':'.join(node.address for node in nodes),
                'FLOCKER_ACCEPTANCE_VOLUME_BACKEND': dataset_backend.name,
                'FLOCKER_ACCEPTANCE_API_CERTIFICATES_PATH': ca_directory.path,
            }

            for environment_variable in environment_variables:
                print "export {name}={value};".format(
                    name=environment_variable,
                    value=environment_variables[environment_variable],
                )

    raise SystemExit(result)