Ejemplo n.º 1
0
    def get_archive(self, service_id):
        res = callmanager(service_id, 'list_code_versions', False, {})
        if 'error' in res:
            return ''

        version = ''
        filename = ''
        for row in res['codeVersions']:
            if 'current' in row:
                version = row['codeVersionId']
                filename = row['filename']
                break

        if version == '' or filename == '':
            return ''

        params = { 'codeVersionId': version }

        res = callmanager(service_id, "download_code_version", False, params)
        if 'error' in res:
            return ''

        _, temp_path = mkstemp(suffix=filename, dir=get_userdata_dir())
        open(temp_path, 'w').write(res)

        return '%s/download_data/%s' % (get_director_url(), basename(temp_path))
Ejemplo n.º 2
0
    def get_archive(self, service_id):
        res = callmanager(service_id, 'list_code_versions', False, {})
        if 'error' in res:
            return ''

        version = ''
        filename = ''
        for row in res['codeVersions']:
            if 'current' in row:
                version = row['codeVersionId']
                filename = row['filename']
                break

        if version == '' or filename == '':
            return ''

        params = {'codeVersionId': version}

        res = callmanager(service_id, "download_code_version", False, params)
        if 'error' in res:
            return ''

        _, temp_path = mkstemp(suffix=filename, dir=get_userdata_dir())
        open(temp_path, 'w').write(res)

        return '%s/download_data/%s' % (get_director_url(),
                                        basename(temp_path))
Ejemplo n.º 3
0
    def save_dump(self, service_id):
        res = callmanager(service_id, 'sqldump', False, {})
        if type(res) is dict and 'error' in res:
            log('Error getting SQL dump: %s' % res['error'])
            return ''

        _, temp_path = mkstemp(dir=get_userdata_dir())
        open(temp_path, 'w').write(res)

        return '%s/download_data/%s' % (get_director_url(), basename(temp_path))
Ejemplo n.º 4
0
def get_startup_script(sid):
    script = create_startup_script(sid)
    
    if not script:
        return ''

    _, temp_path = mkstemp(prefix='startup', dir=get_userdata_dir())
    open(temp_path, 'w').write(script)

    return '%s/download_data/%s' % (get_director_url(), basename(temp_path))
Ejemplo n.º 5
0
def get_startup_script(sid):
    script = create_startup_script(sid)

    if not script:
        return ''

    _, temp_path = mkstemp(prefix='startup', dir=get_userdata_dir())
    open(temp_path, 'w').write(script)

    return '%s/download_data/%s' % (get_director_url(), basename(temp_path))
Ejemplo n.º 6
0
    def save_dump(self, service_id):
        res = callmanager(service_id, 'sqldump', False, {})
        if type(res) is dict and 'error' in res:
            log('Error getting SQL dump: %s' % res['error'])
            return ''

        _, temp_path = mkstemp(dir=get_userdata_dir())
        open(temp_path, 'w').write(res)

        return '%s/download_data/%s' % (get_director_url(),
                                        basename(temp_path))
Ejemplo n.º 7
0
 def __get_node_archive_filename(self, node):
     node_id = "%s_%s_%s" % (node['osd_uuid'], node['dir_uuid'],
             node['mrc_uuid'])
     return os.path.join(get_userdata_dir(), node_id + '.tar.gz')
Ejemplo n.º 8
0
def download_data(fileid):
    if not exists('%s/%s' % (get_userdata_dir(), fileid)):
        return ''

    return helpers.send_from_directory(get_userdata_dir(), fileid)
Ejemplo n.º 9
0
 def __get_node_archive_filename(self, node):
     node_id = "%s_%s_%s" % (node['osd_uuid'], node['dir_uuid'],
                             node['mrc_uuid'])
     return os.path.join(get_userdata_dir(), node_id + '.tar.gz')
Ejemplo n.º 10
0
def download_data(fileid):
    if not exists('%s/%s' % (get_userdata_dir(), fileid)):
        return ''

    return helpers.send_from_directory(get_userdata_dir(), fileid)