Ejemplo n.º 1
0
def _IsStateReached(client, group_ref, desired_igm_state):
    """Checks if the desired state is reached."""
    responses, errors = _GetResources(client, group_ref)
    if errors:
        utils.RaiseToolException(errors)
    if desired_igm_state == IgmState.STABLE:
        is_stable = responses[0].status.isStable
        if not is_stable:
            log.out.Print(wait_info.CreateWaitText(responses[0]))
        return is_stable
    elif desired_igm_state == IgmState.VERSION_TARGET_REACHED:
        is_version_target_reached = responses[0].status.versionTarget.isReached
        if not is_version_target_reached:
            log.out.Print('Waiting for group to reach version target')
        return is_version_target_reached
    else:
        raise Exception('Incorrect desired_igm_state')
Ejemplo n.º 2
0
  def Run(self, args):
    start = time_utils.CurrentTimeSec()
    group_ref = self.CreateGroupReference(args)

    while True:
      responses, errors = self._GetResources(group_ref)
      if errors:
        utils.RaiseToolException(errors)
      if wait_info.IsGroupStable(responses[0]):
        break
      log.out.Print(wait_info.CreateWaitText(responses[0]))
      time_utils.Sleep(WaitUntilStable._TIME_BETWEEN_POLLS_SEC)

      if args.timeout and time_utils.CurrentTimeSec() - start > args.timeout:
        raise utils.TimeoutError('Timeout while waiting for group to become '
                                 'stable.')
    log.out.Print('Group is stable')
  def Run(self, args):
    """Issues requests necessary to wait until stable on a MIG."""
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    client = holder.client
    start = time_util.CurrentTimeSec()
    group_ref = self.CreateGroupReference(client, holder.resources, args)

    while True:
      responses, errors = self._GetResources(client, group_ref)
      if errors:
        utils.RaiseToolException(errors)
      if wait_info.IsGroupStable(responses[0]):
        break
      log.out.Print(wait_info.CreateWaitText(responses[0]))
      time_util.Sleep(WaitUntilStable._TIME_BETWEEN_POLLS_SEC)

      if args.timeout and time_util.CurrentTimeSec() - start > args.timeout:
        raise utils.TimeoutError('Timeout while waiting for group to become '
                                 'stable.')
    log.out.Print('Group is stable')
Ejemplo n.º 4
0
 def testAlphaCreateWaitTextWithOneCurrentActions(self):
   igm = self._CreateInstanceGroupManager('alpha', current_operations=1)
   self.assertEqual(
       wait_info.CreateWaitText(igm),
       'Waiting for group to become stable, current operations: creating: 1')
Ejemplo n.º 5
0
 def testAlphaCreateWaitText(self):
   igm = self._CreateInstanceGroupManager('alpha')
   self.assertEqual(
       wait_info.CreateWaitText(igm),
       'Waiting for group to become stable')