Ejemplo n.º 1
0
    def post(self):
        """
        @api {post} /api/image/upload 上传镜像Dockerfile
        @apiName ImageUploadDockerfileHandler
        @apiGroup Application

        @apiUse cidHeader

        @apiParam {String} name 应用名称
        @apiParam {String} description 描述
        @apiParam {String} repos_name 仓库名称
        @apiParam {String} repos_ssh_url 应用在github的ssh地址
        @apiParam {String} repos_https_url 应用在github的https地址
        @apiParam {String} logo_url LOGO的url地址
        @apiParam {Number} image_id 镜像ID
        @apiParam {[]Number} labels 标签ID(传递时注意保证ID是从小到大的顺序)

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": {
                    "id": int,
                    "name": str,
                    "description": str
                }
            }
        """
        with catch(self):
            pass
Ejemplo n.º 2
0
    def prepare(self):
        ''' 获取用户信息 && 获取请求的参数

            Usage:
                >>> self.current_user['id']
                >>> self.params['x']
        '''
        with catch(self):
            self.params = {}

            user_id, token = self._with_token()

            if user_id:
                self.current_user = self.get_session(user_id)

            if self.request.headers.get('Content-Type', '').startswith(
                    'application/json') and self.request.body != '':
                self.params = json_loads(self.request.body.decode('utf-8'))
            else:
                self.params = self.request.arguments.copy()
                self._decode_params()

            # 从这开始,才对self.params修改
            if self.request.headers.get('Cid'):
                self.params['cid'] = int(self.request.headers['Cid'])

            self.params['token'] = token
Ejemplo n.º 3
0
    def post(self):
        """
        @api {post} /api/clouds/credentials 公有云厂商认证
        @apiName CloudCredentialHandler
        @apiGroup Cloud

        @apiParam {Number} cloud_type 厂商内部id
        @apiParam {Object} content 凭证内容

        @apiSuccessExample {json} Success-Response:
        HTTP/1.1 200 OK
        {
            "status": 0,
            "msg": "success",
            "data": [
                {
                    "is_add": int 0:未添加 1:已经添加,
                    "instance_id": string,
                    "public_ip": string,
                    "inner_ip": string,
                    "net_type": string,
                    "region_id": string
                }
            ]
        }
        """
        with catch(self):
            self.params.update(self.get_lord())
            provider = TENCLOUD_PROVIDER_NAME[self.params['cloud_type']]

            data = yield self.server_service.search_fc_instance(
                {'provider': provider})

            self.success(data)
Ejemplo n.º 4
0
    def get(self):
        """
        @api {get} /api/server/threshold 服务器临界值标准
        @apiName ServerThresholdHandler
        @apiGroup Server

        @apiSuccessExample {json} Success-Response:
        HTTP/1.1 200 OK
        {
            "status": 0,
            "msg": "success",
            "data": {
                // 各项阀值
                "cpu_threshold": int,
                "memory_threshold": int,
                "disk_threshold": int,
                "net_threshold": int,
                "block_threshold": int, // 磁盘io
            }
        }
        """
        with catch(self):
            data = {
                "cpu_threshold": THRESHOLD['CPU_THRESHOLD'],
                "memory_threshold": THRESHOLD['MEM_THRESHOLD'],
                "disk_threshold": THRESHOLD['DISK_THRESHOLD'],
                "net_threshold": THRESHOLD['NET_THRESHOLD'],
                "block_threshold": THRESHOLD['BLOCK_THRESHOLD']
            }
            self.success(data)
Ejemplo n.º 5
0
    def post(self):
        """
        @api {post} /api/server/container/del 删除容器
        @apiName ServerContainerDelHandler
        @apiGroup Server

        @apiUse cidHeader

        @apiParam {Number} id 主机id
        @apiParam {String} container_id 容器id

        @apiUse Success
        """
        with catch(self):
            data = yield self.server_operation_service.add(
                params={
                    'user_id': self.current_user['id'],
                    'object_id': self.params['container_id'],
                    'object_type': OPERATION_OBJECT_STYPE['container'],
                    'operation': CONTAINER_OPERATE_STATUS['delete'],
                    'operation_status': OPERATE_STATUS['fail'],
                })

            yield self.server_service.del_container(self.params)

            yield self.server_operation_service.update(
                sets={'operation_status': OPERATE_STATUS['success']},
                conds={'id': data['id']})
            self.success()
Ejemplo n.º 6
0
    def post(self):
        """
        @api {post} /api/company/application/waiting 待加入公司
        @apiName CompanyApplicationWaitingHandler
        @apiGroup Company

        @apiParam {String} code
        """
        with catch(self):
            data = yield self.company_entry_setting_service.select(fields='cid', conds={'code': self.params['code']}, one=True)

            if not data:
                self.error('邀请码已失效')
                return

            conds = {'cid': data['cid'], 'uid': self.current_user['id']}
            sets  = {'status': APPLICATION_STATUS['waiting']}

            is_exist = yield self.company_employee_service.select(conds=conds, one=True)

            if not is_exist:
                sets.update(conds)
                yield self.company_employee_service.add(sets)
            elif is_exist['status'] == APPLICATION_STATUS['reject']:
                yield self.company_employee_service.update(sets=sets, conds=conds)
            elif is_exist['status'] != APPLICATION_STATUS['waiting']:
                self.error('请勿重复提交加入公司申请')
                return

            self.success()
Ejemplo n.º 7
0
    def get(self):
        """
        @api {get} /api/cluster/summary 服务器总览
        @apiName ClusterSummaryHandler
        @apiGroup Cluster

        @apiUse cidHeader

        @apiSuccessExample {json} Success-Response:
         HTTP/1.1 200 OK
         {
             "status": 0,
             "message": "success",
             "data": {
                 "server_num": 3,
                 "warn_num": 0,
                 "payment_num": 0
             }
         }
        """
        with catch(self):

            server = yield self.server_service.select(conds=self.get_lord())
            server = yield self.filter(server)

            data = {'server_num': len(server), 'warn_num': 0, 'payment_num': 0}
            self.success(data)
Ejemplo n.º 8
0
    def get(self, cid):
        """
        @api {get} /api/permission/resource/(\d+) 获取所有模版资源

        @apiName PermissionResourcesHandler
        @apiGroup Permission

        @apiParam {Number} cid 公司id

        @apiSuccessExample {json} Success-Response
            HTTP/1.1 200 OK
            {
                "status": 0,
                "message": 成功,
                "data": {
                    "access_projects": [
                        {"id": int, "name": str},
                        ...
                    ],
                    "access_files": [
                        {"id": int, "name": str, "type": 0表示文件, 1表示文件夹},
                        ...
                    ],
                    "access_servers": [
                        {"id": int, "name": str},
                        ..
                    ],
                }
            }
        """
        with catch(self):
            cid = int(cid)
            data = yield self.permission_template_service.get_resources(cid)
            self.success(data)
Ejemplo n.º 9
0
    def post(self, pt_id):
        """
        @api {post} /api/permission/template/(\d+)/del 删除权限模版
        @apiName PermissionTemplateDelHandler

        @apiGroup Permission
        @apiUse cidHeader

        @apiParam {Number} pt_id 权限模版id
        @apiParam {Number} cid 公司id

        @apiUse Success
        """
        with catch(self):
            args = ['cid']
            self.guarantee(*args)
            pt_id = int(pt_id)

            pt_info = yield self.permission_template_service.select(
                {'id': pt_id}, one=True)
            if pt_info['type'] == PERMISSIONS_TEMPLATE_TYPE['default']:
                err_key = 'permission_template_cannot_operate'
                self.error(status=ERR_TIP[err_key]['sts'],
                           message=ERR_TIP[err_key]['msg'])
                return

            yield self.permission_template_service.delete({'id': pt_id})

            self.success()
Ejemplo n.º 10
0
    def get(self):
        """
        @api {get} /api/server/list 服务器列表
        @apiName ServerListHandler
        @apiGroup Server

        @apiUse cidHeader

        @apiSuccessExample {json} Success-Response:
        HTTP/1.1 200 OK
        {
            "status": 0,
            "msg": "success",
            "data": [
                {
                    "id": int,
                    "name": string,
                    "public_ip": string,
                    "cluster_id": int,
                    "instance_id": string
                },
                ...
            ]
        }
        """
        with catch(self):
            data = yield self.server_service.select(conds=self.get_lord())
            self.success(data)
Ejemplo n.º 11
0
    def post(self):
        """
        @api {post} /api/permission/template/add 增加权限模版
        @apiName PermissionTemplateAddHandler

        @apiGroup Permission

        @apiUse cidHeader

        @apiParam {String} name 名字
        @apiParam {Number} cid 公司id
        @apiParam {String} permissions 权限列表 如: "1,2,3"
        @apiParam {String} access_servers 服务器列表 如上
        @apiParam {String} access_projects 项目列表 如上
        @apiParam {String} access_filehub 文件列表  如上

        @apiUse Success
        """

        with catch(self):
            args = ['cid', 'name']
            self.guarantee(*args)

            sets = {
                'cid': self.params['cid'],
                'name': self.params['name'],
                'permissions': self.params['permissions'],
                'access_projects': self.params['access_projects'],
                'access_servers': self.params['access_servers'],
                'access_filehub': self.params['access_filehub']
            }
            yield self.permission_template_service.add(sets)

            self.success()
Ejemplo n.º 12
0
    def post(self):
        """
        @api {post} /api/service/delete 删除服务
        @apiName ServiceDeleteHandler
        @apiGroup Service

        @apiUse cidHeader

        @apiParam {Number} service_id 服务ID
        @apiParam {Number} app_id 应用ID

        @apiUse Success
        """
        with catch(self):
            self.guarantee('service_id')

            param = self.get_lord()
            param['id'] = self.params['service_id']
            service_info = yield self.service_service.select(conds=param, one=True)
            service_name = service_info.get('name', '') if service_info else None
            param['id'] = self.params['app_id']
            app_info = yield self.application_service.select(conds=param, one=True)

            if service_name and app_info:
                ssh_info = yield self.application_service.fetch_ssh_login_info({'server_id': app_info['server_id']})

                ssh_info['cmd'] = 'kubectl delete service ' + service_name
                yield self.service_service.remote_ssh(ssh_info)
                yield self.service_service.delete({'id': self.params['service_id']})
                self.success()
            else:
                self.error()
Ejemplo n.º 13
0
    def get(self, prj_name):
        """
        @api {get} /api/project/([\w\W]+)/image 获取某一项目的所有镜像信息
        @apiName ProjectImageFindHandler
        @apiGroup Project

        @apiParam {String} prj_name 项目名称

        @apiSuccessExample Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": [
                    ["{Tag}", "{CreatedAt}"],
                    ...
                ]
            }
        """
        with catch(self):
            self.params.update({"prj_name": prj_name})
            login_info = yield self.server_service.fetch_ssh_login_info(
                {'public_ip': settings['ip_for_image_creation']})
            self.params.update(login_info)
            data, err = yield self.project_service.find_image(self.params)
            if err:
                self.error(err)
                return
            self.success(data)
Ejemplo n.º 14
0
    def get(self, id):
        """
        @api {get} /api/file/([\w\W]+) 文件详细信息
        @apiName FileInfo
        @apiGroup File

        @apiUse cidHeader
        @apiParam {Number} id 文件id

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "message": "success",
                "data": {
                    "id": int,
                    "filename": str,
                    "size": str,
                    "qiniu_id": str,
                    "owner": str,
                    "mime": str,
                    "hash": str,
                    "type": int, 0为文件,1为文件夹, 当为1时,部分字段为空
                    "pid": int,
                    "url": str
                    "create_time": str,
                    "update_time": str,
                }
            }
        """
        with catch(self):
            data = yield self.file_service.select({'id': int(id)}, one=True)
            self.success(data)
Ejemplo n.º 15
0
    def get(self):
        """
        @api {get} /api/company/application 员工申请加入的初始条件
        @apiName CompanyApplicationGetHandler
        @apiGroup Company

        @apiParam {String} code

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": {
                    "cid": 1,
                    "company_name": "十全",
                    "contact": "13900000000",
                    "setting": "mobile,name"
                }
            }
        """
        with catch(self):
            if not self.params['code']:
                self.error('缺少code')
                return

            info = yield self.company_service.fetch_with_code(self.params['code'])

            self.success(info)
Ejemplo n.º 16
0
    def get(self, cid):
        """
        @api {get} /api/permission/template/list/(\d+) 获取权限模版列表
        @apiName PermissionTemplateListHandler
        @apiGroup Permission

        @apiParam {Number} cid 公司id

        @apiSuccessExample {json} Success-Response
            HTTP/1.1 200 OK
            {
                "status": 0,
                "message": 成功,
                "data": [
                    ...
                ]
            }
        """
        with catch(self):
            cid = int(cid)
            data = yield self.permission_template_service.select({'cid': cid})
            data = yield self.permission_template_service.check_pt_exist(data)
            preset = yield self.permission_template_service.get_admin(cid)
            res = [preset]
            if data:
                if isinstance(data, list):
                    res.extend(data)
                else:
                    res = [preset, data]
            self.success(res)
Ejemplo n.º 17
0
    def post(self):
        """
        @api {post} /api/company/admin/transfer 转移管理员
        @apiName CompanyAdminTransferHandler
        @apiGroup Company

        @apiUse cidHeader

        @apiParam {Number} uid 新管理人员id
        @apiParam {Number} cid 公司id

        @apiUse Success
        """
        with catch(self):
            # 检查参数是否完整合法
            self.guarantee('uid', 'cid')

            self.params['admin_id'] = self.current_user['id']

            yield self.company_employee_service.transfer_adimin(self.params)

            # 管理员变更之后需要刷新用户权限变更标记
            company_user_src = USER_PERMISSION.format(cid=self.params.get('cid'), uid=self.current_user['id'])
            self.redis.hset(ADMIN_CHANGED, company_user_src, ADMIN_TO_EMPLOYEE)
            company_user_dst = USER_PERMISSION.format(cid=self.params.get('cid'), uid=self.params.get('uid'))
            self.redis.hset(ADMIN_CHANGED, company_user_dst, EMPLOYEE_TO_ADMIN)

            self.success()
Ejemplo n.º 18
0
    def get(self):
        """
        @api {get} /api/label/list 标签列表
        @apiName LabelListHandler
        @apiGroup Label

        @apiUse cidHeader

        @apiParam {Number} type 标签类型(1.应用,2.镜像)

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": [
                    {
                        "id": 1,
                        "name": "Label_One"
                    },
                    ...
                ]
            }
        """
        with catch(self):
            param = self.get_lord()
            param['type'] = self.params.get('type')
            result = yield self.label_service.select(conds=param,
                                                     fields='id,name',
                                                     ct=False,
                                                     ut=False)

            self.success(result)
Ejemplo n.º 19
0
    def get(self):
        """
        @api {get} /api/company/employee/status 查询员工状态
        @apiName CompanyEmployeeStatusHandler
        @apiGroup Company

        @apiParam {Number} id 公司ID

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": {
                    "status": 1,
                    "is_admin": 0
                }
            }
        """
        with catch(self):
            data = yield self.company_employee_service.select(
                        fields='status, is_admin', conds={'uid': self.current_user['id'], 'cid': self.params.get('id')},
                        ct=False, ut=False, one=True
            )

            self.success(data)
Ejemplo n.º 20
0
    def post(self):
        """
        @api {post} /api/label/new 创建标签
        @apiName LabelAddHandler
        @apiGroup Label

        @apiUse cidHeader

        @apiParam {String} name 标签名称
        @apiParam {Number} type 标签类型(1.应用,2.镜像)

        @apiUse Success
        """
        with catch(self):
            self.guarantee('name')

            param = self.get_lord()
            param['type'] = LABEL_TYPE['application']
            param['name'] = self.params.get('name')

            label = yield self.label_service.select(conds=param)
            if label:
                self.log.info('The label exists, name: %s, type: %d' %
                              (param['name'], param['type']))
                self.error('添加的标签【%s】已经存在' % param['name'])
            else:
                result = yield self.label_service.add(param)
                self.log.info('Succeed in add the label, name: %s, type: %d' %
                              (param['name'], param['type']))
                self.success(result)
Ejemplo n.º 21
0
    def get(self):
        """
        @api {get} /api/cluster/node 集群Node列表数据
        @apiName ClusterNodeListHandler
        @apiGroup Cluster

        @apiParam {Number} cluster_id 集群ID,不传代表获取所有集群列表

        @apiUse cidHeader

        @apiSuccessExample {json} Success-Response:
         HTTP/1.1 200 OK
         {
             "status": 0,
             "message": "success",
             "data": {[
                 "id": 37,
                 "type": 1,     # 集群类型(1.Kubernetes集群 2.超级计算能力 2.高可用)
                 "description": "test",
                 "master_server_id": 193,
                 "public_ip": "1.1.1.1",
                 "k8s_node": "apiVersion: v1..."    # K8s Node信息,YAML格式
             }],
             ...
         }
        """
        with catch(self):
            cluster_id = self.params.get('id', None)
            data = yield self.cluster_service.get_node_list(cluster_id)

            self.success(data)
Ejemplo n.º 22
0
    def get(self, is_pass):
        """
        @api {get} /api/companies/list/(-?\d+) 公司列表
        @apiName CompanyHandler
        @apiGroup Company

        @apiParam {Number} is_pass 1拒绝, 2审核中, 3通过, 4创始人, 5待加入,6获取通过的,以及作为创始人的公司列表, 7获取所有和该用户相关的公司列表

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": [
                    {"cid": 1, "company_name": "十全", "create_time": "申请时间", "update_time": "审核时间", "status": "1拒绝, 2审核中, 3通过"}
                ]
            }        """
        with catch(self):
            is_pass = int(is_pass)
            if is_pass < 1 or is_pass > 8:
                self.error("arg error, check again")
                return

            params = {
                'uid': self.current_user['id'],
                'is_pass': is_pass
            }
            data = yield self.company_service.get_companies(params)

            self.success(data)
Ejemplo n.º 23
0
    def get(self, id):
        """
        @api {get} /api/server/reboot/(\d+) 重启主机
        @apiName ServerRebootHandler
        @apiGroup Server

        @apiUse cidHeader

        @apiParam {Number} id 主机id

        @apiUse Success
        """
        with catch(self):
            data = yield self.server_operation_service.add(
                params={
                    'user_id': self.current_user['id'],
                    'object_id': id,
                    'object_type': OPERATION_OBJECT_STYPE['server'],
                    'operation': SERVER_OPERATE_STATUS['reboot'],
                    'operation_status': OPERATE_STATUS['fail'],
                })
            yield self.server_service.reboot_server(id)
            yield self.server_operation_service.update(
                sets={'operation_status': OPERATE_STATUS['success']},
                conds={'id': data['id']})
            self.success()
Ejemplo n.º 24
0
    def get(self, cid):
        """
        @api {get} /api/company/(\d+)/entry/setting 获取员工加入条件
        @apiName CompanyEntrySettingGetHandler
        @apiGroup Company

        @apiParam {Number} cid     公司id

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": {
                    "url": "https://c.10.com/#/invite?code=65d4a0f"
                }
            }

        @apiErrorExample {json} Error-Response:
        HTTP/1.1 400
            {
                "status": 1,
                "msg": "需要管理员权限",
                "data": {}
            }
        """
        with catch(self):
            cid = int(cid)
            data = yield self.company_entry_setting_service.get_setting(cid)

            self.success(data)
Ejemplo n.º 25
0
    def post(self):
        """
        @api {post} /api/log/operation 操作记录
        @apiName OperationHandler
        @apiGroup Server

        @apiParam {Number} object_type 对象类型
        @apiParam {Number} object_id 对象id

        @apiSuccessExample {json} Success-Response:
         HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": [
                    {
                        "created_time": str,
                        "operation" : int 0:开机, 1:关机, 2:重启
                        "operation_status": int 0:成功, 1:失败
                        "user": str
                    }
                    ...
                ]
            }
        """
        with catch(self):
            data = yield self.server_operation_service.get_server_operation(
                self.params)
            self.success(data)
Ejemplo n.º 26
0
    def post(self, cid):
        """
        @api {post} /api/company/(\d+)/entry/setting 设置员工加入条件
        @apiName CompanyEntrySettingPostHandler
        @apiGroup Company

        @apiUse cidHeader

        @apiParam {String} setting 配置mobile,name, 暂时移除id_card

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": {
                    "url": "https://c.10.com/#/invite?code=65d4a0f"
                }
            }

        @apiErrorExample {json} Error-Response:
        HTTP/1.1 400
            {
                "status": 1,
                "msg": "需要管理员权限",
                "data": {}
            }
        """
        with catch(self):
            cid = int(cid)
            self.params['cid'] = cid
            url = yield self.company_entry_setting_service.save_setting(self.params)

            self.success({'url': url})
Ejemplo n.º 27
0
 def get(self):
     """
     @api {get} /api/clouds/support 支持的公有云列表
     @apiName CloudsHandler
     @apiGroup Cloud
     @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
         "status": 0,
         "msg": "success",
         "data": [
             {
                 "name": string,
                 "id": int, 厂商的内部id
             }
             ...
         ]
     }
     """
     with catch(self):
         data = [{
             'name': k,
             'id': v
         } for k, v in TENCLOUD_PROVIDER_LIST.items()]
         self.success(data)
Ejemplo n.º 28
0
    def get(self, cid):
        """
        @api {get} /api/company/(\d+)/entry/url 获取员工加入URL
        @apiName CompanyEntryUrlHandler
        @apiGroup Company

        @apiParam {String} cid     公司id

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": {
                    "url": "https://c.10.com/#/invite?code=65d4a0f"
                }
            }

        @apiErrorExample {json} Error-Response:
        HTTP/1.1 400
            {
                "status": 1,
                "msg": "需要管理员权限",
                "data": {}
            }
        """
        with catch(self):
            cid = int(cid)

            data = yield self.company_entry_setting_service.select(fields='code', conds={'cid': cid}, one=True)

            self.success({'url': self.company_entry_setting_service.produce_url(data['code'])})
Ejemplo n.º 29
0
    def put(self):
        """
        @api {put} /api/cloud/credential 公有云机器添加
        @apiName CloudCredentialHandler
        @apiGroup Cloud

        @apiParam {Number} cloud_type 厂商内部id
        @apiParam {String} provider
        @apiParam {String} public_ip
        @apiParam {String} instance_id

        @apiUse Success
        """
        with catch(self):
            self.params.update(self.get_lord())

            for data in self.params['data']:
                yield self.server_service.add({
                    'name':
                    '{}演示{}'.format(data['provider'], random.randint(1, 100)),
                    'public_ip':
                    data['public_ip'],
                    'cluster_id':
                    data['cloud_type'],
                    'instance_id':
                    data['instance_id'],
                    'lord':
                    self.params['lord'],
                    'form':
                    self.params['form']
                })

            self.success()
Ejemplo n.º 30
0
    def get(self):
        """
        @api {get} /api/deployment/pods 部署的Pod信息
        @apiName DeploymentPodSourceHandler
        @apiGroup Deployment

        @apiUse cidHeader

        @apiParam {Number} deployment_id 部署ID
        @apiParam {Number} show_verbose 显示具体yaml内容

        @apiSuccessExample {json} Success-Response:
            HTTP/1.1 200 OK
            {
                "status": 0,
                "msg": "success",
                "data": [
                    {
                        "id": int,
                        "name": str,
                        "deployment_id": str,
                        "readyStatus": str,        //就绪情况
                        "podStatus": str,           //pod状态
                        "restartStatus": int,       //重启次数
                        "labels": [],               //标签
                        "verbose": str,
                        "create_time": time,
                        "update_time": time
                    },
                    ...
                ]
            }
        """
        with catch(self):
            self.guarantee('deployment_id')
            show_yaml = int(self.params.get('show_yaml', 0))

            pods = yield self.pod_service.select(
                {'deployment_id': self.params['deployment_id']})
            for i in pods:
                verbose = i.get('verbose', None) if show_yaml else i.pop(
                    'verbose', None)
                if verbose:
                    verbose = yaml.load(verbose)

                    ready = 0
                    total = 0
                    restart = 0
                    for container in verbose['status'].get(
                            'containerStatuses', []):
                        ready += 1 if container.get('ready', False) else 0
                        total += 1
                        restart += int(container.get('restartCount', 0))

                    i['readyStatus'] = str(ready) + '/' + str(total)
                    i['podStatus'] = verbose['status'].get('phase', '')
                    i['restartStatus'] = restart
                    i['labels'] = verbose['metadata'].get('labels', [])

            self.success(pods)