def initialize(self):
        """
        Initialize this prefix, this includes creating the destination path,
        and creating the uuid for the prefix, for any other actions see
        :func:`Prefix.virt_conf`

        Will safely roll back if any of those steps fail

        Returns:
            None

        Raises:
            RuntimeError: If it fails to create the prefix dir
        """
        prefix = self.paths.prefix_path()
        os.environ['LAGO_PREFIX_PATH'] = prefix
        os.environ['LAGO_WORKDIR_PATH'] = os.path.dirname(prefix)

        with utils.RollbackContext() as rollback:
            with LogTask('Create prefix dirs'):
                try:
                    os.mkdir(prefix)
                except OSError as error:
                    raise RuntimeError(
                        'Could not create prefix at %s:\n%s' % (prefix, error)
                    )
            rollback.prependDefer(shutil.rmtree, prefix)

            with open(self.paths.uuid(), 'w') as f, \
                    LogTask('Generate prefix uuid'):
                f.write(uuid.uuid1().hex)

            with LogTask('Create ssh keys'):
                self._create_ssh_keys()

            with LogTask('Tag prefix as initialized'):
                with open(self.paths.prefix_lagofile(), 'w') as fd:
                    fd.write('')

            rollback.clear()
def initialize ( self ) : prefix = self . paths . prefix_path ( ) os . environ [ 'LAGO_PREFIX_PATH' ] = prefix os . environ [ 'LAGO_WORKDIR_PATH' ] = os . path . dirname ( prefix ) with utils . RollbackContext ( ) as rollback : with LogTask ( 'Create prefix dirs' ) : try : os . mkdir ( prefix ) except OSError as error : raise RuntimeError ( 'Could not create prefix at %s:\n%s' % ( prefix , error ) ) rollback . prependDefer ( shutil . rmtree , prefix ) with open ( self . paths . uuid ( ) , 'w' ) as f , LogTask ( 'Generate prefix uuid' ) : f . write ( uuid . uuid1 ( ) . hex ) with LogTask ( 'Create ssh keys' ) : self . _create_ssh_keys ( ) with LogTask ( 'Tag prefix as initialized' ) : with open ( self . paths . prefix_lagofile ( ) , 'w' ) as fd : fd . write ( '' ) rollback . clear ( )
Initialize this prefix, this includes creating the destination path,
        and creating the uuid for the prefix, for any other actions see
        :func:`Prefix.virt_conf`

        Will safely roll back if any of those steps fail

        Returns:
            None

        Raises:
            RuntimeError: If it fails to create the prefix dir