@classmethod
    def initialize(cls, path, name, begin=None, cluster_id=None):
        """
        Generate new private/public key pair and self-sign, then store in given
        directory.

        :param FilePath path: Directory where private key and certificate are
            stored.
        :param bytes name: The name of the cluster. This is used as the
            subject and issuer identities of the generated root certificate.
        :param datetime begin: The datetime from which the generated
            certificate should be valid.
        :param UUID cluster_id: The unique identifier of the cluster for which
            to generate the key and certificate.  If not given, a random
            identifier will be generated.

        :return RootCredential: Initialized certificate authority.
        """
        if cluster_id is None:
            cluster_id = uuid4()

        dn = DistinguishedName(
            commonName=name,
            organizationalUnitName=bytes(cluster_id),
        )
        keypair = flocker_keypair()
        request = keypair.keypair.requestObject(dn)
        serial = os.urandom(16).encode(b"hex")
        serial = int(serial, 16)
        certificate = create_certificate_authority(
            keypair.keypair, dn, request, serial,
            EXPIRY_20_YEARS, b'sha256', start=begin
        )
        credential = FlockerCredential(
            path=path, keypair=keypair, certificate=certificate)
        credential.write_credential_files(
            AUTHORITY_KEY_FILENAME, AUTHORITY_CERTIFICATE_FILENAME)
        instance = cls(credential=credential)
        return instance
dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py/RootCredential.initialize/original