コード例 #1
0
    def post():
        payload = validate_or_abort(BaseImageProps, request.get_json())
        data = payload['data']

        if payload['operation'] == 'get':
            data = validate_or_abort(ImageGetProps, data)

        if payload['operation'] == 'list':
            data = validate_or_abort(ImageListProps, data)

        if payload['operation'] == 'pull':
            data = validate_or_abort(ImagePullProps, data)

        if payload['operation'] == 'remove':
            data = validate_or_abort(ImageRemoveProps, data)
            data['force'] = True

        if payload['operation'] == 'search':
            data = validate_or_abort(ImageSearchProps, data)

        if payload['operation'] == 'prune':
            data = validate_or_abort(ImagePruneProps, data)

        response = DockerEngine().run_image_operation(
            operation=payload['operation'], data=data)

        schema = ImageObj if response else None

        if response and payload['operation'] == 'search':
            schema = DockerHubImage

        return parse_data(schema, response) if response \
            else response_by_success(False)
コード例 #2
0
ファイル: machine.py プロジェクト: harvestcore/IPManager
    def post():
        data = validate_or_abort(QuerySchema, request.get_json())
        user = Machine().find(
            criteria=data['query'],
            projection=data['filter'] if 'filter' in data.keys() else {})

        return parse_data(MachineSchema, user.data)
コード例 #3
0
ファイル: provision.py プロジェクト: harvestcore/IPManager
    def post():
        data = validate_or_abort(ProvisionRunSchema, request.get_json())
        results = AnsibleEngine().run_playbook(hosts=data['hosts'],
                                               playbook=data['playbook'],
                                               passwords=data['passwords'])

        if results:
            return parse_data(ProvisionRunResponseSchema, {'result': results})

        return response_by_success(False)
コード例 #4
0
    def post():
        user = Login().get_username(request.headers['x-access-token'])

        if user and User().is_admin(user):
            data = validate_or_abort(QuerySchema, request.get_json())
            customer = Customer().find(
                criteria=data['query'],
                projection=data['filter'] if 'filter' in data.keys() else {})

            return parse_data(CustomerSchema, customer.data)
        return response_by_success(False)
コード例 #5
0
ファイル: login.py プロジェクト: harvestcore/IPManager
    def get():
        auth = request.authorization

        if not auth or not auth.username or not auth.password:
            return make_response(
                'Could not verify.', 401,
                {'WWW-Authenticate': 'Basic realm="Login required."'})

        login = Login().login(auth)

        if not login or not login.data:
            return response_by_success(False)

        return parse_data(LoginSchema, login.data)
コード例 #6
0
    def post():
        payload = validate_or_abort(BaseSingleImageProps, request.get_json())
        image = DockerEngine().get_image_by_name(payload['name'])

        if image:
            response = DockerEngine().run_operation_in_object(
                object=image,
                operation=payload['operation'],
                data=payload['data'])

            return parse_data(None, response) if response \
                else response_by_success(False)

        return response_by_success(False)
コード例 #7
0
    def post():
        payload = validate_or_abort(BaseSingleContainerProps,
                                    request.get_json())
        container = DockerEngine().get_container_by_id(payload['container_id'])
        if container:
            response = DockerEngine().run_operation_in_object(
                object=container,
                operation=payload['operation'],
                data=payload['data'])

            if response is not False:
                return parse_data(None, response)

        return response_by_success(False)
コード例 #8
0
    def post():
        payload = validate_or_abort(BaseContainersProps, request.get_json())
        data = payload['data']

        if payload['operation'] == 'run':
            data = validate_or_abort(ContainersRunProps, data)
            data['detach'] = True

        if payload['operation'] == 'get':
            data = validate_or_abort(ContainersGetProps, data)

        if payload['operation'] == 'list':
            data = validate_or_abort(ContainersListProps, data)

        if payload['operation'] == 'prune':
            data = validate_or_abort(ContainersPruneProps, data)

        response = DockerEngine().run_container_operation(
            operation=payload['operation'], data=data)
        schema = ContainerObj if response else None
        return parse_data(schema, response) if response \
            else response_by_success(False)
コード例 #9
0
ファイル: machine.py プロジェクト: harvestcore/IPManager
 def get(name):
     user = Machine().find(criteria={'name': name})
     return parse_data(MachineSchema, user.data)
コード例 #10
0
ファイル: user.py プロジェクト: harvestcore/IPManager
 def get():
     username = Login().get_username(request.headers['x-access-token'])
     user = User().find({'username': username})
     return parse_data(UserSchema, user.data) if user and user.data \
         else response_by_success(False)
コード例 #11
0
ファイル: user.py プロジェクト: harvestcore/IPManager
 def get(username):
     user = User().find(criteria={'username': username})
     return parse_data(UserSchema, user.data)
コード例 #12
0
ファイル: provision.py プロジェクト: harvestcore/IPManager
 def post():
     data = validate_or_abort(QuerySchema, request.get_json())
     playbook = Playbook().find(
         criteria=data['query'],
         projection=data['filter'] if 'filter' in data.keys() else {})
     return parse_data(BasePlaybook, playbook.data)
コード例 #13
0
ファイル: provision.py プロジェクト: harvestcore/IPManager
 def get(name):
     user = Playbook().find(criteria={'name': name})
     return parse_data(BasePlaybook, user.data)
コード例 #14
0
ファイル: provision.py プロジェクト: harvestcore/IPManager
 def get(name):
     user = Host().find(criteria={'name': name})
     return parse_data(BaseHost, user.data)