'Save new cert and chain as a successor of a prior version.
Returns the new version number that was created.
.. note:: this function does NOT update links to deploy this
version
:param int prior_version: the old version to which this version
is regarded as a successor (used to choose a privkey, if the
key has not changed, but otherwise this information is not
permanently recorded anywhere)
:param bytes new_cert: the new certificate, in PEM format
:param bytes new_privkey: the new private key, in PEM format,
or ``None``, if the private key has not changed
:param bytes new_chain: the new chain, in PEM format
:param .NamespaceConfig cli_config: parsed command line
arguments
:returns: the new version number that was created
:rtype: int'

def save_successor(self, prior_version, new_cert, new_privkey, new_chain, cli_config):

    self.cli_config = cli_config
    target_version = self.next_free_version()
    target = dict([(kind, os.path.join(self.archive_dir, '{0}{1}.pem'.format(kind, target_version))) for kind in ALL_FOUR])
    if (new_privkey is None):
        old_privkey = os.path.join(self.archive_dir, 'privkey{0}.pem'.format(prior_version))
        if os.path.islink(old_privkey):
            old_privkey = os.readlink(old_privkey)
        else:
            old_privkey = 'privkey{0}.pem'.format(prior_version)
        logger.debug('Writing    symlink    to    old    private    key,    %s.', old_privkey)
        os.symlink(old_privkey, target['privkey'])
    else:
        with open(target['privkey'], 'wb') as f:
            logger.debug('Writing    new    private    key    to    %s.', target['privkey'])
            f.write(new_privkey)
    with open(target['cert'], 'wb') as f:
        logger.debug('Writing    certificate    to    %s.', target['cert'])
        f.write(new_cert)
    with open(target['chain'], 'wb') as f:
        logger.debug('Writing    chain    to    %s.', target['chain'])
        f.write(new_chain)
    with open(target['fullchain'], 'wb') as f:
        logger.debug('Writing    full    chain    to    %s.', target['fullchain'])
        f.write((new_cert + new_chain))
    symlinks = dict(((kind, self.configuration[kind]) for kind in ALL_FOUR))
    self.configfile = update_configuration(self.lineagename, self.archive_dir, symlinks, cli_config)
    self.configuration = config_with_defaults(self.configfile)
    return target_version
