Exemple #1
0
 def create_route_table(self, params):
     """
     create_route_table: 创建一个自定义路由表
     官网API参考链接: https://help.aliyun.com/document_detail/87586.html
     """
     try:
         request = CreateRouteEntryRequest.CreateRouteEntryRequest()
         request.set_action_name("CreateRouteTable")
         # 自定义路由表所属的VPC ID
         request.add_query_param("VpcId", params['vpc_id'])
         # 路由表的名称
         request.add_query_param("RouteTableName", params['route_table_name'])
         response = self.client.do_action_with_exception(request)
         response_json = json.loads(response)
         route_table_id = response_json['RouteTableId']
         # 判断route table状态是否可用
         if CheckStatus.check_status(TIME_DEFAULT_OUT, DEFAULT_TIME * 5,
                                     self.describe_route_table_status,
                                     route_table_id, route_table_id):
             return response_json
     except ServerException as e:
         ExceptionHandler.server_exception(e)
     except ClientException as e:
         ExceptionHandler.client_exception(e)