

@classmethod
def initialize(cls, path, authority, hostname, begin=None):
    '\n        Generate a certificate signed by the supplied root certificate.\n\n        :param FilePath path: Directory where the certificate will be stored.\n        :param RootCredential authority: The certificate authority with\n            which this certificate will be signed.\n        :param datetime begin: The datetime from which the generated\n            certificate should be valid.\n        :param bytes hostname: The hostname of the node where the control\n            service will be running.\n        '
    name = b'control-service'
    organizational_unit = authority.organizational_unit
    dn = DistinguishedName(commonName=name, organizationalUnitName=organizational_unit)
    keypair = flocker_keypair()
    request = keypair.keypair.requestObject(dn)
    serial = os.urandom(16).encode(b'hex')
    serial = int(serial, 16)
    try:
        IPAddress(hostname)
    except ValueError:
        alt_name = (b'DNS:' + hostname)
    else:
        alt_name = (b'IP:' + hostname)
    cert = sign_certificate_request(authority.credential.keypair.keypair, authority.credential.certificate.original.get_subject(), request, keypair, EXPIRY_20_YEARS, 'sha256', start=begin, additional_extensions=[crypto.X509Extension(b'subjectAltName', False, (b'DNS:control-service,' + alt_name))])
    credential = FlockerCredential(path=path, keypair=keypair, certificate=cert)
    credential.write_credential_files(b'control-{}.key'.format(hostname), b'control-{}.crt'.format(hostname))
    instance = cls(credential=credential)
    return instance

dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py ControlCredential.initialize/VarMisuse@151/364 `serial`->`keypair`