def setUp(self): HOST = 'bmr.bce-api.baidu.com' AK = 'ak' SK = 'sk' config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST) self.bmr_client = bmr.BmrClient(config)
time.sleep(CONF.check_cluster_interval_sec) except ex.BceHttpClientError as e: if isinstance(e.last_error, ex.BceServerError): LOG.error('get_cluster failed. Response %s, code: %s, msg: %s' % (e.last_error.status_code, e.last_error.code, e.last_error.message)) else: LOG.error('get_cluster failed. Unknown exception: %s' % e) if retry_time > CONF.check_cluster_max_retry_time or status is None: LOG.error('check cluster status failed. Skip following requests.') sys.exit(1) if __name__ == '__main__': bmr_client = bmr.BmrClient(CONF.config) try: # list clusters LOG.debug('\n\n\nSample 1: LIST CLUSTERS\n\n\n') response = bmr_client.list_clusters(max_keys=5) print response.is_truncated, response.next_marker LOG.debug('list total %s clusters' % len(response.clusters)) for cluster in response.clusters: LOG.debug('cluster: %s' % cluster) page = 1 next_marker = None max_keys = 5 is_truncated = True while is_truncated: response = bmr_client.list_clusters(marker=next_marker,