plugin.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:snap-plugin-lib-py 作者: intelsdi-x 项目源码 文件源码
def _generate_preamble_and_serve(self):
        if self._config.get("TLSEnabled", False) == True:
            try:
                self._tls_setup()
                credentials = self._generate_tls_credentials()
                self._port = self.server.add_secure_port('127.0.0.1:{}'.format(self._port), credentials)
                LOG.info("Configured secure port on {}.".format(self._port))
            except Exception as e:
                raise Exception("TLS setup failed. Unable to add secure port. {}".format(str(e)))
        else:
            self._port = self.server.add_insecure_port('127.0.0.1:{}'.format(self._port))
            LOG.info("Configured insecure port on {}.".format(self._port))
        self.server.start()
        return json.dumps(
            {
                "Meta": {
                    "Name": self.meta.name,
                    "Version": self.meta.version,
                    "Type": self.meta.type,
                    "RPCType": self.meta.rpc_type,
                    "RPCVersion": self.meta.rpc_version,
                    "ConcurrencyCount": self.meta.concurrency_count,
                    "Exclusive": self.meta.exclusive,
                    "CacheTTL": self.meta.cache_ttl,
                    "RoutingStrategy": self.meta.routing_strategy,
                    "RootCertPaths": self.meta.root_cert_paths,
                    "CertPath": self.meta.server_cert_path,
                    "KeyPath": self.meta.private_key_path,
                    "Ciphers": self.meta.cipher_suites,
                    "TLSEnabled": self._config.get("TLSEnabled"),
                },
                "ListenAddress": "127.0.0.1:{!s}".format(self._port),
                "Token": None,
                "PublicKey": None,
                "Type": self.meta.type,
                "ErrorMessage": None,
                "State": PluginResponseState.plugin_success,
            },
            cls=_EnumEncoder
        ) + "\n"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号