예제 #1
0
파일: idc_search.py 프로젝트: xutaoding/bmp
 def get(self, page, pre_page, is_fuzzy=0):
     return self.succ(Idc_host.select(
         page,
         pre_page,
         _joins=[Idc_host_disk, Idc_host_interface, Idc_host_ps],
         _filters=self.get_search_fields([Idc_host, Idc_host_ps, Idc_host_disk, Idc_host_interface], is_fuzzy))
     )
예제 #2
0
파일: idc_search.py 프로젝트: cash2one/bmp
 def get(self, page, pre_page, is_fuzzy=0):
     return self.succ(
         Idc_host.select(
             page,
             pre_page,
             _joins=[Idc_host_disk, Idc_host_interface, Idc_host_ps],
             _filters=self.get_search_fields(
                 [Idc_host, Idc_host_ps, Idc_host_disk, Idc_host_interface],
                 is_fuzzy)))
예제 #3
0
 def get(self, page=0, pre_page=None, iid=None):
     if None != iid:
         return self.succ(Idc_host.get(iid))
     return self.succ(Idc_host.select(page, pre_page))
예제 #4
0
 def delete(self, iid):
     Idc_host.delete(iid)
     return self.succ()
예제 #5
0
 def put(self, iid):
     submit = self.request()
     submit["id"] = iid
     Idc_host.edit(submit)
     return self.succ()
예제 #6
0
 def post(self):
     submit = self.request()
     return self.succ(Idc_host.add(submit))
예제 #7
0
파일: idc_search.py 프로젝트: cash2one/bmp
from bmp.apis.base import BaseApi
from bmp.models.idc import Idc_host, Idc_host_disk, Idc_host_interface, Idc_host_ps


class Idc_searchApi(BaseApi):
    route = [
        "/idc/search/<int:page>/<int:pre_page>",
        "/idc/search/<int:page>/<int:pre_page>/<int:is_fuzzy>"
    ]

    def get(self, page, pre_page, is_fuzzy=0):
        return self.succ(
            Idc_host.select(
                page,
                pre_page,
                _joins=[Idc_host_disk, Idc_host_interface, Idc_host_ps],
                _filters=self.get_search_fields(
                    [Idc_host, Idc_host_ps, Idc_host_disk, Idc_host_interface],
                    is_fuzzy)))


if __name__ == "__main__":
    from sqlalchemy import or_
    for host in Idc_host.select(
            1,
            10,
            _joins=[Idc_host_disk, Idc_host_interface, Idc_host_ps],
            _filters=or_(Idc_host_interface.ip_address.like("127.0.0.1"),
                         Idc_host.ip.like("127.0.0.1")))["items"]:
        print host
예제 #8
0
파일: idc_search.py 프로젝트: xutaoding/bmp
# coding: utf-8

from bmp.apis.base import BaseApi
from bmp.models.idc import Idc_host, Idc_host_disk, Idc_host_interface, Idc_host_ps


class Idc_searchApi(BaseApi):
    route = ["/idc/search/<int:page>/<int:pre_page>", "/idc/search/<int:page>/<int:pre_page>/<int:is_fuzzy>"]

    def get(self, page, pre_page, is_fuzzy=0):
        return self.succ(Idc_host.select(
            page,
            pre_page,
            _joins=[Idc_host_disk, Idc_host_interface, Idc_host_ps],
            _filters=self.get_search_fields([Idc_host, Idc_host_ps, Idc_host_disk, Idc_host_interface], is_fuzzy))
        )


if __name__ == "__main__":
    from sqlalchemy import or_
    for host in Idc_host.select(1, 10,
            _joins=[Idc_host_disk, Idc_host_interface, Idc_host_ps],
            _filters=or_(Idc_host_interface.ip_address.like("127.0.0.1"),Idc_host.ip.like("127.0.0.1"))
    )["items"]:
        print host