← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:cleanup/ec2-console-as-bytes into cloud-init:master

 


Diff comments:

> diff --git a/tests/cloud_tests/platforms/ec2/platform.py b/tests/cloud_tests/platforms/ec2/platform.py
> index fdb17ba..ba246fe 100644
> --- a/tests/cloud_tests/platforms/ec2/platform.py
> +++ b/tests/cloud_tests/platforms/ec2/platform.py
> @@ -228,4 +230,28 @@ class EC2Platform(Platform):
>  
>          return self.tag
>  
> +
> +def _decode_console_output_as_bytes(parsed, **kwargs):
> +    """Provide console output as bytes in OutputBytes.
> +
> +       For this to be useful, the session has to have had the
> +       decode_console_output handler unregistered already.
> +
> +       https://github.com/boto/botocore/issues/1351 ."""
> +    if 'Output' not in parsed:
> +        return
> +    orig = parsed['Output']
> +    handlers.decode_console_output(parsed, **kwargs)
> +    parsed['OutputBytes'] = base64.b64decode(orig)
> +
> +
> +def get_ec2_client():
> +    mysess = session.get_session()

I put the comment in the _decode_console function, because I felt like it is the place where both paths would find it:
a.) get_ec2_client:  if I read this 'unregister' and 'register', especially with register being to a local method, and I'm wondering "why is this here".  I'm going to look in that method.
b.) console_log: refernces 'OutputBytes' and a 'grep -r OutputBytes' will find _decode_console_output_as_bytes.

I dont think we need to have yet another url.  I adjusted it a bit, see if you like the new version more.

> +    mysess.unregister('after-call.ec2.GetConsoleOutput',
> +                      handlers.decode_console_output)
> +    mysess.register('after-call.ec2.GetConsoleOutput',
> +                    _decode_console_output_as_bytes)
> +    return mysess.create_client('ec2')
> +
> +
>  # vi: ts=4 expandtab


-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/336366
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:cleanup/ec2-console-as-bytes into cloud-init:master.


References