def __init__(self, node_addresses, package_source, distribution, dataset_backend, dataset_backend_configuration, identity, cert_path, logging_config): """ :param list: A ``list`` of public IP addresses or ``[private_address, public_address]`` lists. See ``ManagedRunner`` and ``ManagedNode`` for other parameter documentation. """ # Blow up if the list contains mixed types. [address_type] = set(type(address) for address in node_addresses) if address_type is list: # A list of 2 item lists self._nodes = pvector( ManagedNode( address=address, private_address=private_address, distribution=distribution ) for (private_address, address) in node_addresses ) else: # A list of strings. self._nodes = pvector( ManagedNode(address=address, distribution=distribution) for address in node_addresses ) self.package_source = package_source self.dataset_backend = dataset_backend self.dataset_backend_configuration = dataset_backend_configuration self.identity = identity self.cert_path = cert_path self.logging_config = logging_config
def start_cluster(self, reactor): # Destroy the box to begin, so that we are guaranteed # a clean build. yield run(reactor, ['vagrant', 'destroy', '-f'], path=self.vagrant_path.path) if self.package_source.version: env = extend_environ(FLOCKER_BOX_VERSION=vagrant_version( self.package_source.version)) else: env = os.environ # Boot the VMs yield run(reactor, ['vagrant', 'up'], path=self.vagrant_path.path, env=env) for node in self.NODE_ADDRESSES: yield remove_known_host(reactor, node) nodes = pvector( ManagedNode(address=address, distribution=self.distribution) for address in self.NODE_ADDRESSES) certificates = Certificates(self.certificates_path) cluster = Cluster(all_nodes=pvector(nodes), control_node=nodes[0], agent_nodes=nodes, dataset_backend=self.dataset_backend, certificates=certificates) returnValue(cluster)
def __init__(self, node_addresses, package_source, distribution, dataset_backend, dataset_backend_configuration): self._nodes = pvector( ManagedNode(address=address, distribution=distribution) for address in node_addresses) self.package_source = package_source self.dataset_backend = dataset_backend self.dataset_backend_configuration = dataset_backend_configuration
def test_cluster_id(self): """ The certificates generated are for a cluster with the given identifier. """ cluster_id = UUID("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb") node = ManagedNode( address=b"192.0.2.17", distribution=DISTRIBUTIONS[0], ) certificates = generate_certificates(cluster_id, [node]) root = RootCredential.from_path(certificates.directory) self.assertEqual( cluster_id, UUID(root.organizational_unit), )
def start_cluster(self, reactor): # Destroy the box to begin, so that we are guaranteed # a clean build. yield run( reactor, ['vagrant', 'destroy', '-f'], path=self.vagrant_path.path) if self.package_source.version: env = extend_environ( FLOCKER_BOX_VERSION=vagrant_version( self.package_source.version)) else: env = os.environ # Boot the VMs yield run( reactor, ['vagrant', 'up'], path=self.vagrant_path.path, env=env) for node in self.NODE_ADDRESSES: yield remove_known_host(reactor, node) nodes = pvector( ManagedNode(address=address, distribution=self.distribution) for address in self.NODE_ADDRESSES ) certificates = Certificates(self.certificates_path) # Default volume size is meaningless here as Vagrant only uses ZFS, and # not a block device backend. # XXX Change ``Cluster`` to not require default_volume_size default_volume_size = int(GiB(1).to_Byte().value) cluster = Cluster( all_nodes=pvector(nodes), control_node=nodes[0], agent_nodes=nodes, dataset_backend=self.dataset_backend, certificates=certificates, default_volume_size=default_volume_size, ) returnValue(cluster)