예제 #1
0
파일: idc.py 프로젝트: seerjk/reboot_devops
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    # for field in kwargs.keys():
    #     # 2.1 验证参数是否在idc表中
    #     if not hasattr(Idc, field):
    #         # logging
    #         current_app.logger.warning(
    #             "参数错误,{} 不在Idc这张表中".format(field)
    #         )
    #         raise Exception("params error: {}".format(field))
    #     # 2.2 不能为空
    #     if not kwargs.get(field, None):
    #         # logging
    #         current_app.logger.warning(
    #             "参数错误,{} 不能为空".format(field)
    #         )
    #         raise Exception("{} 不能为空".format(field))
    check_field_exists(Idc, kwargs)

    # 3 插入到数据库
    idc = Idc(**kwargs)
    db.session.add(idc)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning(
            "commit error: {}".format(e.message)
        )
        raise Exception("commit error")
예제 #2
0
파일: idc.py 프로젝트: reblue520/devops2
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    # for field in kwargs.keys():
    #     # 2.1 验证参数是否在idc表中
    #     if not hasattr(Idc, field):
    #         # logging
    #         current_app.logger.warning(
    #             "参数错误,{} 不在Idc这张表中".format(field)
    #         )
    #         raise Exception("params error: {}".format(field))
    #     # 2.2 不能为空
    #     if not kwargs.get(field, None):
    #         # logging
    #         current_app.logger.warning(
    #             "参数错误,{} 不能为空".format(field)
    #         )
    #         raise Exception("{} 不能为空".format(field))
    check_field_exists(Idc, kwargs)

    # 3 插入到数据库
    idc = Idc(**kwargs)
    db.session.add(idc)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #3
0
def create(**kwargs):
    check_field_exists(Manufacturers, kwargs)
    record = Manufacturers(**kwargs)
    db.session.add(record)
    try:
        db.session.commit()
    except Exception,e:
        raise Exception(e.message.split(") ")[1])
예제 #4
0
파일: idc.py 프로젝트: Frank-liang/51dev
def create(**kwargs):
    check_field_exists(Idc, kwargs)
    idc = Idc(**kwargs)
    db.session.add(idc)
    try:
        db.session.commit()
    except Exception,e:
        raise Exception(e.message.split(") ")[1])
예제 #5
0
파일: power.py 프로젝트: Frank-liang/51dev
def create(**kwargs):
    check_field_exists(Power, kwargs)
    power = Power(**kwargs)
    db.session.add(power)
    try:
        db.session.commit()
    except Exception,e:
        raise Exception(e.message.split(") ")[1])
예제 #6
0
def create(**kwargs):
    check_field_exists(Supplier, kwargs)
    record = Supplier(**kwargs)
    db.session.add(record)
    try:
        db.session.commit()
    except Exception,e:
        raise Exception(e.message.split(") ")[1])
예제 #7
0
def create(**kwargs):
    #1.获取参数信息
    check_field_exists(Power, kwargs)
    #2.传参个数验证
    obj = Power(**kwargs)
    #3.插入数据库
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #8
0
파일: idc.py 프로젝트: Star2One/cmdb-1
def create(**kwargs):
    #1.获取参数信息
    check_field_exists(Idc, kwargs)
    #2.传参个数验证
    obj = Idc(**kwargs)

    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #9
0
def create(**kwargs):
    #1.获取参数信息
    check_field_exists(IpInfo, kwargs)
    #2.传参个数验证
    check_value_exists(Server, "id", kwargs.get("server_id", None))
    check_value_exists(Switch, "id", kwargs.get("switch_id", None))

    obj = IpInfo(**kwargs)
    #3.插入数据库
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #10
0
def create(**params):
    # 1. 获取参数信息
    check_field_exists(Cabinet, params)

    print inspect.getmembers(Cabinet, predicate=inspect.ismethod(id))

    # 传参的个数需要验证
    obj = Cabinet(**params)

    # 插入到数据库
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #11
0
def create(**params):
    # 1. 获取参数信息
    check_field_exists(Raidtype, params)

    print inspect.getmembers(Raidtype,predicate=inspect.ismethod(id))

    # 传参的个数需要验证
    obj = Raidtype(**params)

    # 插入到数据库
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #12
0
def create(**kwargs):
    # 1  获取用户传入参数
    print kwargs
    # 2  验证参数的合法性
    check_field_exists(Supplier, kwargs)
    # 3  插入到数据库
    manufacturers = Supplier(**kwargs)
    db.session.add(manufacturers)

    try:
        db.session.commit()
    except Exception, e:
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #13
0
def create(**kwargs):
	# 1.获取参数信息
	# return kwargs
	check_field_exists(Status,kwargs)
	# 传参的可个数验证
	# 2.处理
	# 3.通过数据实例化Status
	status = Status(**kwargs)
	# 4.插入到数据库
	db.session.add(status)
	try:
		db.session.commit()
	except Exception, e:
		raise Exception(e.message.split(")")[1])
예제 #14
0
def create(**kwargs):
    # 1. 获取参数
    # 2. 验证参数是否合法
    check_field_exists(ServerType, kwargs)
    servertype = ServerType(**kwargs)
    db.session.add(servertype)
    try:
        db.session.commit()
    except Exception as e:
        current_app.logger.warning("插入错误: {} ".format(e.message))
        raise Exception("commit error")
    # 3. 插入到数据库
    # 4. 返回插入的状态
    return servertype.id
예제 #15
0
def create(**kwargs):
    # 1. 获取参数
    # 2. 验证参数是否合法
    check_field_exists(ManagementCard, kwargs)
    managementcard = ManagementCard(**kwargs)
    db.session.add(managementcard)
    try:
        db.session.commit()
    except Exception as e:
        current_app.logger.warning("插入错误: {} ".format(e.message))
        raise Exception("commit error")
    # 3. 插入到数据库
    # 4. 返回插入的状态
    return managementcard.id
예제 #16
0
파일: power.py 프로젝트: unixomg/Hydra
def create(**kwargs):
    # 1. 获取参数
    # 2. 验证参数是否合法
    check_field_exists(Power, kwargs)
    power = Power(**kwargs)
    db.session.add(power)
    try:
        db.session.commit()
    except Exception as e:
        current_app.logger.warning("插入错误: {} ".format(e.message))
        raise Exception("commit error")
    # 3. 插入到数据库
    # 4. 返回插入的状态
    return power.id
예제 #17
0
파일: idc.py 프로젝트: songkane/zhongjing
def create(**kwargs):
	# 1.获取参数信息
	# return kwargs
	check_field_exists(Idc,kwargs)
	# 传参的可个数验证
	# 2.处理
	# 3.通过数据实例化Idc
	idc = Idc(**kwargs)
	# 4.插入到数据库
	db.session.add(idc)
	try:
		db.session.commit()
	except Exception, e:
		raise Exception(e.message.split(")")[1])
예제 #18
0
def create(**kwargs):
    # 1  获取用户传入参数
    print kwargs
    # 2  验证参数的合法性
    check_field_exists(Supplier, kwargs)
    # 3  插入到数据库
    manufacturers = Supplier(**kwargs)
    db.session.add(manufacturers)

    try:
        db.session.commit()
    except Exception, e:
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #19
0
def create(**kwargs):
    # 1  获取用户传入参数
    print kwargs
    # 2  验证参数的合法性
    check_field_exists(Cabinet, kwargs)
    # 3  插入到数据库
    idc = Cabinet(**kwargs)
    db.session.add(idc)

    try:
        db.session.commit()
    except Exception, e:
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #20
0
파일: product.py 프로젝트: MissRoven/opsdev
def create(**kwargs):
    # 1  获取用户传入参数
    print kwargs
    # 2  验证参数的合法性
    check_field_exists(Product, kwargs)
    # 3  插入到数据库
    idc = Product(**kwargs)
    db.session.add(idc)

    try:
        db.session.commit()
    except Exception, e:
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #21
0
 def create(self, **kwargs):
     # 1. 获取参数
     # 2. 验证参数是否合法
     check_field_exists(self.Module, kwargs)
     idc = self.Module(**kwargs)
     db.session.add(idc)
     try:
         db.session.commit()
     except Exception as e:
         current_app.logger.warning("插入错误: {} ".format(e.message))
         raise Exception("commit error")
     # 3. 插入到数据库
     # 4. 返回插入的状态
     return idc.id
예제 #22
0
def create(**kwargs):
    #1获取参数
    check_field_exists(Server, kwargs)

    #2处理数据
    #print inspect.getmembers(Server, predicate=inspect.is)
    #return 1
    print kwargs
    #3实例化record
    record = Server(**kwargs)
    #4插入到数据库
    db.session.add(record)
    try:
        db.session.commit()
    except Exception,e:
        raise Exception(e.message.split(") ")[1])
예제 #23
0
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    check_field_exists(RaidType, kwargs)

    # 3 插入到数据库
    raidtype = RaidType(**kwargs)
    db.session.add(raidtype)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #24
0
def create(**kwargs):
    #1获取参数
    check_field_exists(Raid, kwargs)

    #2处理数据
    #print inspect.getmembers(Raid, predicate=inspect.is)
    #return 1
    print kwargs
    #3实例化record
    record = Raid(**kwargs)
    #4插入到数据库
    db.session.add(record)
    try:
        db.session.commit()
    except Exception, e:
        raise Exception(e.message.split(") ")[1])
예제 #25
0
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    check_field_exists(ManagementCard, kwargs)

    # 3 插入到数据库
    managementcard = ManagementCard(**kwargs)
    db.session.add(managementcard)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning("commit error: {}".format(e.message))
        raise Exception("commit error")
예제 #26
0
def create(**kwargs):
    #1获取参数
    check_field_exists(Idc, kwargs)

    #2处理数据
    #print inspect.getmembers(Idc, predicate=inspect.is)
    #return 1
    print kwargs
    #3实例化idc
    idc = Idc(**kwargs)
    #4插入到数据库
    db.session.add(idc)
    try:
        db.session.commit()
    except Exception,e:
        raise Exception(e.message.split(") ")[1])
예제 #27
0
def create(**params):
    # 1. 获取参数信息
    check_field_exists(Idc, params)

    print inspect.getmembers(Idc,predicate=inspect.ismethod(id))

    # 传参的个数需要验证
    obj = Idc(**params)

    # 插入到数据库
    db.session.add(obj)

    try:
        db.session.commit()
    except Exception,e:
        print e.message.split()[1]
        raise Exception(e.message.split(") ")[1])
예제 #28
0
def create(**params):
    # 1. 获取参数信息
    check_field_exists(Status, params)

    print inspect.getmembers(Status,predicate=inspect.ismethod(id))

    # 传参的个数需要验证
    obj = Status(**params)

    # 插入到数据库
    db.session.add(obj)

    try:
        db.session.commit()
    except Exception,e:
        print e.message.split()[1]
        raise Exception(e.message.split(") ")[1])
예제 #29
0
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    check_field_exists(Manufacturers, kwargs)

    # 3 插入到数据库
    manufacturers = Manufacturers(**kwargs)
    db.session.add(manufacturers)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning(
            "commit error: {}".format(e.message)
        )
        raise Exception("commit error")
예제 #30
0
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    check_field_exists(Product, kwargs)

    # 3 插入到数据库
    product = Product(**kwargs)
    db.session.add(product)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning(
            "commit error: {}".format(e.message)
        )
        raise Exception("commit error")
예제 #31
0
def create(**kwargs):
    # 1 获取参数
    # print kwargs

    # 2 检查参数
    check_field_exists(ServerType, kwargs)

    # 3 插入到数据库
    servertype = ServerType(**kwargs)
    db.session.add(servertype)
    try:
        db.session.commit()
    except Exception, e:
        # logging
        current_app.logger.warning(
            "commit error: {}".format(e.message)
        )
        raise Exception("commit error")
예제 #32
0
def create(**params):
    # 1. 获取参数信息
    check_field_exists(Cabinet, params)
    check_value_exists(Idc,"id",params.get("idc_id",None))
    check_value_exists(Power,"server_power",params.get("power",None))

    print inspect.getmembers(Cabinet,predicate=inspect.ismethod(id))

    # 传参的个数需要验证
    obj = Cabinet(**params)

    # 插入到数据库
    db.session.add(obj)

    try:
        db.session.commit()
    except Exception,e:
        print e.message.split()[1]
        raise Exception(e.message.split(") ")[1])
예제 #33
0
def create(**kwargs):
    check_field_exists(Status,kwargs)
    obj = Status(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #34
0
def create(**kwargs):
    check_field_exists(Power, kwargs)
    obj = Power(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #35
0
def create(**kwargs):
    check_field_exists(ServerType, kwargs)
    obj = ServerType(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #36
0
def create(**kwargs):
    check_field_exists(Idc,kwargs)
    obj = Idc(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #37
0
def create(**kwargs):
    check_field_exists(Ip_Info, kwargs)
    obj = Ip_Info(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #38
0
def create(**kwargs):
    check_field_exists(ServerType,kwargs)
    obj = ServerType(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #39
0
def create(**kwargs):
    check_field_exists(Manufacturers, kwargs)
    obj = Manufacturers(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #40
0
def create(**kwargs):
    check_field_exists(Status, kwargs)
    obj = Status(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #41
0
def create(**kwargs):
    check_field_exists(Cabinet,kwargs)
    obj = Cabinet(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #42
0
def create(**kwargs):
    check_field_exists(Raid,kwargs)
    obj = Raid(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id
예제 #43
0
def create(**kwargs):
    check_field_exists(Supplier,kwargs)
    obj = Supplier(**kwargs)
    db.session.add(obj)
    db.session.commit()
    return obj.id