Exemplo n.º 1
0
def do_encryption(gce_svc,
                  enc_svc_cls,
                  zone,
                  encryptor,
                  encryptor_image,
                  instance_name,
                  instance_config,
                  encrypted_image_disk,
                  network,
                  status_port=ENCRYPTOR_STATUS_PORT):
    metadata = gce_metadata_from_userdata(instance_config.make_userdata())
    log.info('Launching encryptor instance')
    gce_svc.run_instance(zone=zone,
                         name=encryptor,
                         image=encryptor_image,
                         network=network,
                         disks=[
                             gce_svc.get_disk(zone, instance_name),
                             gce_svc.get_disk(zone, encrypted_image_disk)
                         ],
                         metadata=metadata)

    try:
        enc_svc = enc_svc_cls([gce_svc.get_instance_ip(encryptor, zone)],
                              port=status_port)
        wait_for_encryptor_up(enc_svc, Deadline(600))
        wait_for_encryption(enc_svc)
    except Exception as e:
        f = gce_svc.write_serial_console_file(zone, encryptor)
        if f:
            log.info('Encryption failed. Writing console to %s' % f)
        raise e
    retry(function=gce_svc.delete_instance,
          on=[httplib.BadStatusLine, socket.error,
              errors.HttpError])(zone, encryptor)
Exemplo n.º 2
0
def do_encryption(gce_svc,
                  enc_svc_cls,
                  zone,
                  encryptor,
                  encryptor_image,
                  instance_name,
                  instance_config,
                  encrypted_image_disk,
                  network,
                  status_port=ENCRYPTOR_STATUS_PORT):
    metadata = gce_metadata_from_userdata(instance_config.make_userdata())
    log.info('Launching encryptor instance')
    gce_svc.run_instance(zone=zone,
                         name=encryptor,
                         image=encryptor_image,
                         network=network,
                         disks=[gce_svc.get_disk(zone, instance_name),
                                gce_svc.get_disk(zone, encrypted_image_disk)],
                         metadata=metadata)

    try:
        enc_svc = enc_svc_cls([gce_svc.get_instance_ip(encryptor, zone)],
                              port=status_port)
        wait_for_encryptor_up(enc_svc, Deadline(600))
        wait_for_encryption(enc_svc)
    except Exception as e:
        f = gce_svc.write_serial_console_file(zone, encryptor)
        if f:
            log.info('Encryption failed. Writing console to %s' % f)
        raise e
    retry(function=gce_svc.delete_instance,
            on=[httplib.BadStatusLine, socket.error, errors.HttpError])(zone, encryptor)
Exemplo n.º 3
0
    def connect(self):
        try:
            retry(self._s_connect,
                  exception_checker=VmodlExceptionChecker(None),
                  timeout=1000,
                  initial_sleep_seconds=15)()
        except vmodl.MethodFault as error:
            log.exception("Caught vmodl fault : %s", error.msg)
            raise

        # set datastore name
        if self.datastore_name is None:
            content = self.si.RetrieveContent()
            datastore = self.__get_obj(content, [vim.Datastore], None)
            self.datastore_name = datastore.info.name
            self.datastore_path = "[" + self.datastore_name + "] "
Exemplo n.º 4
0
def retry_boto(function, error_code_regexp=None, timeout=10.0,
               initial_sleep_seconds=0.25):
    """ Retry an AWS API call.  Handle known intermittent errors and expected
    error codes.
    """
    return util.retry(
        function,
        exception_checker=BotoRetryExceptionChecker(error_code_regexp),
        timeout=timeout,
        initial_sleep_seconds=initial_sleep_seconds
    )
Exemplo n.º 5
0
 def _get_wrapped(self, timeout=1.0, on=None, use_exception_checker=True):
     checker = None
     if use_exception_checker:
         checker = TestRetryExceptionChecker()
     return util.retry(
         self._fail_for_n_calls,
         on=on,
         exception_checker=checker,
         initial_sleep_seconds=0,
         timeout=timeout
     )
Exemplo n.º 6
0
 def _get_wrapped(self, timeout=1.0, on=None, use_exception_checker=True):
     checker = None
     if use_exception_checker:
         checker = TestRetryExceptionChecker()
     return util.retry(
         self._fail_for_n_calls,
         on=on,
         exception_checker=checker,
         initial_sleep_seconds=0,
         timeout=timeout
     )