docstr: Changes status of the AWS machine depending on the target status and permissions.
docstr_tok: ["Changes","status","of","the","AWS","machine","depending","on","the","target","status","and","permissions","."]
code: def change_status(cls, hostnames, target="start"):
      """
      Changes status of the AWS machine depending on the target status and permissions.
      """
      if target == "start":
          action = cls.ec2_client.start_instances
      else:
          action = cls.ec2_client.stop_instances
      try:
          action(InstanceIds=hostnames, DryRun=True)
      except ClientError as e:
          if "DryRunOperation" in str(e):
              logger.debug(
                  "Permission to start/stop EC2 instance granted"
              )
          else:
              logger.fatal("You don't have permissions")
              raise e
      try:
          response = action(InstanceIds=hostnames, DryRun=False)
          logger.debug(response)
      except ClientError as e:
          logger.debug(e)
          if e.response["Error"]["Code"] in ("IncorrectInstanceState"):
              retry_counter = 0
              while retry_counter < retry:
                  try:
                      response = action(
                          InstanceIds=hostnames, DryRun=False
                      )
                      break
                  except ClientError:
                      retry_counter += 1
                      logger.warning(
                          "Instance not yet ready for starting, retry in 30 sec (%d/%d)",
                          retry_counter,
                          retry,
                      )
                      time.sleep(30)
              if retry_counter == retry:
                  logger.fatal(
                      "cannot start instance, there might be some issues"
                  )
                  raise EnvironmentError(
                      "Failed to start AWS instance with in %d retries",
                      retry,
                  )
  
file_path: auptimizer/src/aup/EE/Resource/AWSResourceManager.py
imports: import logging
  import time
  import boto3
  import paramiko
  from botocore.exceptions import ClientError
  from .SSHResourceManager import SSHResourceManager, Remote, parse_hostname
label_desc: Use image node_id 1 for calling the AWSRemote obj's underlying member method code with example usage: obj.change_status(cls, hostnames, target) without return types