コード例 #1
0
def network_routes_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'network_routes_all:', locals()
    
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    routes = Route.query.all()
    _routes = objects_to_list(routes)
    
    # insert domain, host, container names
    for _route in _routes:
        domain = Domain.query.get(_route['domain_id'])
        assert domain is not None
        
        host = Host.query.get(_route['host_id'])
        assert host is not None
        
        container = Container.query.get(_route['container_id'])
        assert container is not None
        
        _route['domain_domain'] = domain.domain
        _route['host_name'] = host.name
        _route['container_name'] = container.name
        _route['container_container_id'] = container.container_id
    
    data = {
        'routes': _routes,
    }
    
    return jsonify(data)
コード例 #2
0
ファイル: volume.py プロジェクト: mtasic85/dockyard
def volume_volumes_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'volume_volumes_all:', locals()
    
    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)
    
    volumes = Volume.query.all()
    _volumes = objects_to_list(volumes)
    
    # insert host_name
    # insert mount_point_name
    for _volume in _volumes:
        host = Host.query.get(_volume['host_id'])
        assert host is not None
        
        mount_point = MountPoint.query.get(_volume['mount_point_id'])
        assert mount_point is not None
        
        _volume['host_name'] = host.name
        _volume['mount_point_name'] = mount_point.name
    
    data = {
        'volumes': _volumes,
    }
    
    return jsonify(data)
コード例 #3
0
ファイル: volume.py プロジェクト: mtasic85/dockyard
def volume_volumes_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'volume_volumes_all:', locals()

    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)

    volumes = Volume.query.all()
    _volumes = objects_to_list(volumes)

    # insert host_name
    # insert mount_point_name
    for _volume in _volumes:
        host = Host.query.get(_volume['host_id'])
        assert host is not None

        mount_point = MountPoint.query.get(_volume['mount_point_id'])
        assert mount_point is not None

        _volume['host_name'] = host.name
        _volume['mount_point_name'] = mount_point.name

    data = {
        'volumes': _volumes,
    }

    return jsonify(data)
コード例 #4
0
ファイル: container.py プロジェクト: mtasic85/dockyard
def container_containers_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'container_containers_all:', locals()
    
    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)
    
    containers = Container.query.all()
    _containers = objects_to_list(containers)
    
    # insert host_name
    # insert image_name
    for _container in _containers:
        host = Host.query.get(_container['host_id'])
        # assert host is not None
        
        image = Image.query.get(_container['image_id'])
        assert image is not None
        
        _container['host_name'] = host.name if host else 'ALL'
        _container['image_name'] = image.name
    
    data = {
        'containers': _containers,
    }
    
    return jsonify(data)
コード例 #5
0
def mount_points_all():
    username = current_user.username
    usertype = current_user.usertype
    host_id = request.json.get('host_id', None)
    print 'mount_points_all:', locals()
    
    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)
    
    query = MountPoint.query
    
    if host_id is not None:
        query = query.filter_by(host_id=host_id)
    
    mounts = query.all()
    _mounts = objects_to_list(mounts)
    
    # insert host_name
    for _mount in _mounts:
        host = Host.query.get(_mount['host_id'])
        assert host is not None
        _mount['host_name'] = host.name
    
    data = {
        'mounts': _mounts,
    }
    
    return jsonify(data)
コード例 #6
0
ファイル: image.py プロジェクト: mtasic85/dockyard
def image_images_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'image_images_all:', locals()

    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)

    images = Image.query.all()
    _images = objects_to_list(images)

    # insert host_name
    for _image in _images:
        host = Host.query.get(_image['host_id'])

        if host:
            _image['host_name'] = host.name
        else:
            _image['host_name'] = 'ALL'

    data = {
        'images': _images,
    }

    return jsonify(data)
コード例 #7
0
ファイル: account.py プロジェクト: mtasic85/dockyard
def account_users_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'account_users_all locals:', dict(locals())
    
    # get all results
    user_accounts = UserAccount.query.all()
    _user_accounts = objects_to_list(user_accounts, skip=['password'])
    
    data = {
        'user_accounts': _user_accounts,
    }
    
    return jsonify(data)
コード例 #8
0
def network_domains_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'network_domains_all:', locals()
    
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    domains = Domain.query.all()
    _domains = objects_to_list(domains)
    
    data = {
        'domains': _domains,
    }
    
    return jsonify(data)
コード例 #9
0
ファイル: host.py プロジェクト: mtasic85/dockyard
def host_hosts_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'host_hosts_all:', locals()
    
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    hosts = Host.query.all()
    _hosts = objects_to_list(hosts)
    
    data = {
        'hosts': _hosts,
    }
    
    return jsonify(data)
コード例 #10
0
ファイル: host.py プロジェクト: mtasic85/dockyard
def host_hosts_all():
    username = current_user.username
    usertype = current_user.usertype
    print 'host_hosts_all:', locals()

    if usertype != 'super':
        data = {}
        return jsonify(data)

    hosts = Host.query.all()
    _hosts = objects_to_list(hosts)

    data = {
        'hosts': _hosts,
    }

    return jsonify(data)