Пример #1
0
def is_monitor_item_collect(request):
    """
    获取唯一的数据库系统时间,用于判断当前监控项是否在采集时间区域
    :param request:
    :return:
    """
    # 将监控项信息转换为json格式
    monitor_item = json.loads(request.body);
    # 获取当前系统时间
    result = get_current_time()
    # 当前时间
    current_time = list(result[0])[0]
    # 开始时间
    start_time = monitor_item["start_time"]
    # 结束时间
    end_time = monitor_item["end_time"]

    # 如果当前时间在监控项的采集时间范围内,执行采集,调用一体化服务
    if (current_time >= start_time) and (current_time <= end_time):
        result = gather_base_test(request)
        # 历史数据迁移
        gather_data_migrate(monitor_item["id"])
        # print json.loads(result.content)["results"]
        info = {
            "type" : "add",
            "item_id" : monitor_item["id"],
            "measures" : json.loads(result.content)["results"]
        }
        print info
        # 采集数据入库
        gather_data_save(info)
        return result
    else :
        return render_json({"result": "1"})
Пример #2
0
def virtual_post_snapshot(virtual_source, repository, source_config):
    logger.debug("virtual_post_snapshot")
    start(virtual_source, repository, source_config)
    logger.debug("Started VDB")
    snapshot = SnapshotDefinition(validate=False)
    snapshot.snapshot_id = str(utils.get_snapshot_id())
    snapshot.snap_host = virtual_source.connection.environment.host.name
    snapshot.snap_port = virtual_source.parameters.port
    snapshot.snap_data_dir = virtual_source.mounts[0].mount_path + "/data"
    snapshot.snap_base_dir = virtual_source.parameters.base_dir
    snapshot.snap_pass = virtual_source.parameters.vdb_pass
    snapshot.snap_backup_path = ""
    snapshot.snap_time = utils.get_current_time()
    logger.debug("SnapShot Definition Created")
    logger.debug(snapshot)
    return snapshot
Пример #3
0
def linked_post_snapshot(staged_source, repository, source_config,
                         snapshot_parameters):
    logger.debug("plugin_opertions.linked_post_snapshot - Start ")
    dSourceType = staged_source.parameters.d_source_type
    start_staging(staged_source, repository, source_config)
    logger.debug(snapshot_parameters)
    mount_path = staged_source.parameters.mount_path
    snapshot = SnapshotDefinition(validate=False)
    snapshot.snapshot_id = str(utils.get_snapshot_id())
    snapshot.snap_host = staged_source.staged_connection.environment.host.name
    snapshot.snap_port = staged_source.parameters.staging_port
    snapshot.snap_data_dir = mount_path + "/data"
    snapshot.snap_base_dir = source_config.base_dir
    snapshot.snap_pass = staged_source.parameters.staging_pass
    snapshot.snap_backup_path = staged_source.parameters.backup_path
    snapshot.snap_time = utils.get_current_time()
    logger.debug(snapshot)
    logger.debug("linked_post_snapshot - End ")
    return snapshot
Пример #4
0
def query_pos_scene(request):
    '''
    场景
    :param request:
    :return:
    '''
    #res = json.loads(request.body)
    # 接收参数
    pos_id = request.POST.get('pos_id')
    start = request.POST.get('start')
    end = request.POST.get('end')
    #  scenes = []
    # 获取岗位对应的场景
    position_scenes = position_scene.objects.filter(position_id=pos_id)

    #for pos_scene in position_scenes:
    #    scenes.append(pos_scene.scene_id)

    scene_id_list = []
    for scene in position_scenes:
        # 场景
        temp_scene_dt = Scene.objects.filter(id=scene.scene_id,
                                             scene_content__isnull=False)
        if temp_scene_dt.count() == 0:
            continue
        temp_scene = temp_scene_dt.get()
        if temp_scene.scene_content == None \
            or temp_scene.scene_content.strip() == "":
            continue
        if start != None:
            if str(temp_scene.scene_startTime) <= end and str(
                    temp_scene.scene_endTime) >= start:
                scene_id_list.append(scene.scene_id)
        else:
            nowtime = get_current_time()
            # 当前时间
            current_time = list(nowtime[0])[0]
            if str(temp_scene.scene_startTime) <= current_time and str(
                    temp_scene.scene_endTime) >= current_time:
                scene_id_list.append(scene.scene_id)
            #scene_id_list.append(scene.scene_id)
    return scene_id_list
 def test06(self):
     """新增人员"""
     csurl, method, head, yamlvalue, yaml_path, mainkey = get_common_params(
         "permission_manage.yaml", "新增人员")
     n = get_current_time(4)
     data = {
         "username": "******" + n,
         "password": "******",
         "status": "正常",
         "truename": "测试cs",
         "sex": "男",
         "phone": "18005162887",
         "youxiang": "",
         "deptIds": "%s" % getattr(result, 'dept_id'),
         "identity": "普通员工",
         "roleIds": ["%s" % getattr(result, 'system_role_id')]
     }
     r = a.request(csurl, method, json=data, headers=head)
     setattr(result, 'ceshi_user_id', json.loads(r.text)['data']['_id'])
     # convert_json_to_yaml(r.text, yaml_path, mainkey)
     check_codes_msg(r, yamlvalue, mainkey)
     check_datas(r, yamlvalue)