def setUp(self): access_key = 'ak' secret_key = 'sk' self.credential = Credential(access_key, secret_key) # 指定使用http方式访问vpc专用域名,超时为20s config = Config('vm.internal.cn-north-1.jdcloud-api.com', SCHEME_HTTP, 20) logger = Logger( 3 ) # FATAL = 0 ERROR = 1 WARN = 2 INFO = 3;如果不想输出日志,可将日志级别设置为0(FATAL);不设置logger,则默认为INFO self.client = VmClient(self.credential, config, logger)
def get_logger(debug): if debug: return Logger(INFO) else: return Logger(FATAL)
def getDiskClient(accessKey, secretKey): credential = Credential(accessKey, secretKey) logger = Logger(2) config = Config(timeout=1000) client = DiskClient(credential, logger=logger, config=config) return client