Ejemplo n.º 1
0
 def _archive_from_url(self, archive, auth_config):
     tf = tempfile.TemporaryFile()
     opts = util.req_opts({'auth': auth_config.get_auth(None)})
     util.EtagCheckedResponse(requests.get(archive, **opts)).write_to(tf)
     tf.flush()
     tf.seek(0, os.SEEK_SET)
     return tf
Ejemplo n.º 2
0
 def _archive_from_url(self, archive, auth_config):
     tf = tempfile.TemporaryFile()
     opts = util.req_opts({'auth': auth_config.get_auth(None)})
     util.EtagCheckedResponse(requests.get(archive, **opts)).write_to(tf)
     tf.flush()
     tf.seek(0, os.SEEK_SET)
     return tf
Ejemplo n.º 3
0
    def _msi_from_url(self, archive, auth_config):
        tf = tempfile.mkstemp(suffix='.msi', prefix='cfn-init-tmp')

        with os.fdopen(tf[0], 'wb') as temp_dest:
            opts = util.req_opts({'auth': auth_config.get_auth(None)})
            util.EtagCheckedResponse(requests.get(archive, **opts)).write_to(temp_dest)

        return tf[1]
Ejemplo n.º 4
0
    def _write_remote_file(self, source, auth, dest, context):
        opts = util.req_opts({'auth': auth})
        remote_contents = util.EtagCheckedResponse(requests.get(source, **opts))

        if context is None:
            remote_contents.write_to(dest)
        else:
            dest.write(self._render_template(remote_contents.contents(), context))
Ejemplo n.º 5
0
 def _make_request(self, verb, base_url, params, headers, timeout=None):
     headers = dict(headers) if headers else {}
     headers['User-Agent'] = 'CloudFormation Tools'
     return util.check_status(api.request(verb, base_url,
                        **util.req_opts({
                         'data' : params if verb=='POST' else dict(),
                         'params' : params if verb!='POST' else dict(),
                         'headers' : headers,
                         'proxies' : self._proxyinfo,
                         'timeout' : timeout
                        })))
Ejemplo n.º 6
0
 def _make_request(self, verb, base_url, params, headers, timeout=None):
     headers = dict(headers) if headers else {}
     headers['User-Agent'] = 'CloudFormation Tools'
     return util.check_status(
         api.request(
             verb, base_url,
             **util.req_opts({
                 'data': params if verb == 'POST' else dict(),
                 'params': params if verb != 'POST' else dict(),
                 'headers': headers,
                 'proxies': self._proxyinfo,
                 'timeout': timeout
             })))
Ejemplo n.º 7
0
    def _make_request(self, verb, base_url, params, headers, timeout=None):
        headers = dict(headers) if headers else {}
        headers['User-Agent'] = self._construct_user_agent()

        return util.check_status(
            api.request(
                verb, base_url,
                **util.req_opts({
                    'data':
                    Client.construct_query(params)
                    if verb == 'POST' else dict(),
                    'params':
                    params if verb != 'POST' else dict(),
                    'headers':
                    headers,
                    'proxies':
                    self._proxyinfo,
                    'timeout':
                    timeout
                })))