'Create a new certificate lineage.
Attempts to create a certificate lineage -- enrolled for
potential future renewal -- with the (suggested) lineage name
lineagename, and the associated cert, privkey, and chain (the
associated fullchain will be created automatically). Optional
configurator and renewalparams record the configuration that was
originally used to obtain this cert, so that it can be reused
later during automated renewal.
Returns a new RenewableCert object referring to the created
lineage. (The actual lineage name, as well as all the relevant
file paths, will be available within this object.)
:param str lineagename: the suggested name for this lineage
(normally the current cert\'s first subject DNS name)
:param str cert: the initial certificate version in PEM format
:param str privkey: the private key in PEM format
:param str chain: the certificate chain in PEM format
:param .NamespaceConfig cli_config: parsed command line
arguments
:returns: the newly-created RenewalCert object
:rtype: :class:`storage.renewableCert`'

@classmethod
def new_lineage(cls, lineagename, cert, privkey, chain, cli_config):

    for i in (cli_config.renewal_configs_dir, cli_config.default_archive_dir, cli_config.live_dir):
        if (not os.path.exists(i)):
            os.makedirs(i, 448)
            logger.debug('Creating    directory    %s.', i)
    (config_file, config_filename) = util.unique_lineage_name(cli_config.renewal_configs_dir, lineagename)
    lineagename = lineagename_for_filename(config_filename)
    archive = _full_archive_path(None, cli_config, lineagename)
    live_dir = _full_live_path(cli_config, lineagename)
    if os.path.exists(archive):
        raise errors.CertStorageError(('archive    directory    exists    for    ' + lineagename))
    if os.path.exists(live_dir):
        raise errors.CertStorageError(('live    directory    exists    for    ' + lineagename))
    os.mkdir(archive)
    os.mkdir(live_dir)
    logger.debug('Archive    directory    %s    and    live    directory    %s    created.', archive, live_dir)
    target = dict([(kind, os.path.join(live_dir, (kind + '.pem'))) for kind in ALL_FOUR])
    for kind in ALL_FOUR:
        os.symlink(os.path.join(_relpath_from_file(archive, target[kind]), (kind + '1.pem')), target[kind])
    with open(target['cert'], 'wb') as f:
        logger.debug('Writing    certificate    to    %s.', target['cert'])
        f.write(cert)
    with open(target['privkey'], 'wb') as f:
        logger.debug('Writing    private    key    to    %s.', target['privkey'])
        f.write(privkey)
    with open(target['chain'], 'wb') as f:
        logger.debug('Writing    chain    to    %s.', target['chain'])
        f.write(chain)
    with open(target['fullchain'], 'wb') as f:
        logger.debug('Writing    full    chain    to    %s.', target['fullchain'])
        f.write((cert + chain))
    readme_path = os.path.join(live_dir, README)
    with open(readme_path, 'w') as f:
        logger.debug('Writing    README    to    %s.', readme_path)
        f.write('This    directory    contains    your    keys    and    certificates.\n\n`privkey.pem`        :    the    private    key    for    your    certificate.\n`fullchain.pem`:    the    certificate    file    used    in    most    server    software.\n`chain.pem`                :    used    for    OCSP    stapling    in    Nginx    >=1.3.7.\n`cert.pem`                    :    will    break    many    server    configurations,    and    should    not    be    used\n                                                                    without    reading    further    documentation    (see    link    below).\n\nWe    recommend    not    moving    these    files.    For    more    information,    see    the    Certbot\nUser    Guide    at    https://certbot.eff.org/docs/using.html#where-are-my-certificates.\n')
    config_file.close()
    values = relevant_values(vars(cli_config.namespace))
    new_config = write_renewal_config(config_filename, config_filename, archive, target, values)
    return cls(new_config.filename, cli_config)
