Exemplo n.º 1
0
 def describe_apg_instances(self):
     request = DescribeAutoProvisioningGroupInstancesRequest()
     request.set_accept_format('json')
     request.set_AutoProvisioningGroupId(self.cloud_resources["apg_id"])
     request.set_PageSize(100)
     iteration = self.nchunks // 100
     instance_list = []
     for i in range(iteration + 1):
         request.set_PageNumber(i + 1)
         count = 0
         flag = 0
         err_msg = 0
         while count < 10:
             try:
                 response = self.client.do_action_with_exception(request)
                 response = json.loads(response)
                 for ins in response["Instances"]["Instance"]:
                     instance_list.append(ins["InstanceId"])
                 flag = 1
                 break
             except ServerException as e:
                 # dlog.info(e)
                 err_msg = e
                 count += 1
             except ClientException as e:
                 # dlog.info(e)
                 err_msg = e
                 count += 1
         if not flag:
             dlog.info("describe_apg_instances failed, err msg: %s" %
                       err_msg)
             sys.exit()
     return instance_list
Exemplo n.º 2
0
 def delete_apg(self):
     request = DeleteAutoProvisioningGroupRequest()
     request.set_accept_format('json')
     request.set_AutoProvisioningGroupId(self.cloud_resources["apg_id"])
     request.set_TerminateInstances(True)
     count = 0
     flag = 0
     while count < 10:
         try:
             response = self.client.do_action_with_exception(request)
             flag = 1
             break
         except ServerException as e:
             time.sleep(10)
             count += 1
     if not flag:
         dlog.info("delete apg failed, exit")
         sys.exit()
Exemplo n.º 3
0
 def change_apg_capasity(self, capasity):
     request = ModifyAutoProvisioningGroupRequest()
     request.set_accept_format('json')
     request.set_AutoProvisioningGroupId(self.cloud_resources["apg_id"])
     request.set_TotalTargetCapacity(str(capasity))
     request.set_SpotTargetCapacity(str(capasity))
     request.set_PayAsYouGoTargetCapacity("0")
     count = 0
     flag = 0
     while count < 10:
         try:
             response = self.client.do_action_with_exception(request)
             flag = 1
             break
         except:
             count += 1
             time.sleep(10)
     if not flag:
         dlog.info("change_apg_capasity failed, exit")
         sys.exit()