コード例 #1
0
ファイル: agent.py プロジェクト: mentalsmash/uno
 def load(registry_dir, keep=False, roaming=False, daemon=False, interfaces=[]):
     from .agent_cell import CellAgent
     from .agent_root import RootAgent
     
     registry_dir = pathlib.Path(registry_dir)
     identity_db = UvnIdentityDatabase.load(basedir=registry_dir)
     registry = UvnRegistry.load(identity_db)
     
     if registry.packaged:
         return CellAgent(registry, keep=keep, roaming=roaming, daemon=daemon, interfaces=interfaces)
     else:
         if roaming:
             raise UvnException("roaming mode not supported for root agent")
         return RootAgent(registry, keep=keep, daemon=daemon, interfaces=interfaces)
コード例 #2
0
ファイル: reg.py プロジェクト: mentalsmash/uno
 def reload(self):
     logger.info("reloading uvn registry from {}", self.paths.basedir)
     identity_db = UvnIdentityDatabase.load(self.paths.basedir)
     return UvnRegistry.load(identity_db)
コード例 #3
0
ファイル: install.py プロジェクト: mentalsmash/uno
    def bootstrap(package, install_prefix, keep=False):
        package = pathlib.Path(package)
        install_prefix = pathlib.Path(install_prefix).resolve()

        logger.activity("installing cell package: {}", package.name)
        # Create a temporary directory to extract the installer and bootstrap
        # the gpg database
        tmp_dir = tempfile.mkdtemp(prefix="{}-".format(package.stem))
        tmp_dir = pathlib.Path(tmp_dir)

        try:
            logger.debug("extracting {} to {}", package, tmp_dir)

            shutil.unpack_archive(str(package), extract_dir=str(tmp_dir),
                format=UvnDefaults["cell"]["pkg"]["clear_format"])

            # Load installer manifest
            manifest = UvnCellInstaller._manifest_file(tmp_dir)
            installer = yml_obj(UvnCellInstaller, manifest, from_file=True)
            
            logger.debug("loaded installer for cell {} of UVN {} [{}]",
                installer.cell_name, installer.uvn_address, installer.uvn_deployment)

            installer_files = UvnCellInstaller._installer_files(
                tmp_dir, bootstrap=installer._bootstrap)

            # Check that all files are there as expected
            missing_files = [str(f) for f in installer_files.values()
                                        if not f.exists()]
            if missing_files:
                raise UvnException("missing uvn installer files: [{}]".format(
                    ",".join(missing_files)))

            installer_dir = tmp_dir / UvnDefaults["cell"]["pkg"]["export_name"]

            if installer._bootstrap:
                logger.activity("bootstrap: {} -> {}", package.stem, install_prefix)
                bootstrap_dir = installer_dir
                registry = None
            else:
                # extract deployment package into target cell's dir
                logger.activity("deployment: {} -> {}", package.stem, install_prefix)
                bootstrap_dir = install_prefix
                identity_db = UvnIdentityDatabase.load(basedir=bootstrap_dir)
                from libuno.reg import UvnRegistry
                registry = UvnRegistry.load(identity_db)

            
            # Decrypt cell package and extract it
            UvnIdentityDatabase.bootstrap_cell(
                bootstrap_dir=bootstrap_dir,
                registry=registry,
                uvn_address=installer.uvn_address,
                uvn_admin=installer.uvn_admin,
                cell_name=installer.cell_name,
                cell_admin=installer.cell_admin,
                cell_pkg=installer_files["cell_pkg"],
                cell_sig=installer_files["cell_sig"],
                uvn_public_key=installer_files.get("uvn_public_key"),
                cell_public_key=installer_files.get("cell_public_key"),
                cell_private_key=installer_files.get("cell_private_key"),
                cell_secret=installer_files.get("cell_secret"),
                keep=keep)
            
            if installer._bootstrap:
                shutil.copytree(str(installer_dir), str(install_prefix))

        finally:
            if not keep:
                # Delete temporary directory
                shutil.rmtree(str(tmp_dir))
            else:
                logger.warning("[tmp] not deleted: {}", tmp_dir)

        logger.activity("installed package: {} -> {}", package.name, install_prefix)
コード例 #4
0
ファイル: uvn_fn.py プロジェクト: mentalsmash/uno
 def _registry_load(basedir):
     logger.debug("loading UVN from {}", basedir)
     identity_db = UvnIdentityDatabase.load(basedir)
     registry = UvnRegistry.load(identity_db)
     logger.debug("loaded UVN {}", registry.address)
     return registry