コード例 #1
0
def add_update_tool(tooldata, tool_id, logo_path, directory_to_import_from, full_logo_path):
    """Add Update a Tool"""
    # CHECK TOOL NAME
#     if tooldata.get("status"):
#         if (tool_id):
#             if(tooldata.get("status")=="3"):
#                 validate_tool(tool_id)
#                 
    if not tooldata.get("name"):
        raise ValueError("Invalid Tool Name")
    HelperServices.validate_name(tooldata.get("name"),"tool name")
    Tool = {}
    Tool["name"] = tooldata["name"]
    # CHECK TAG
    if not tooldata.get("tag"):
        Tool["tag"] = []
    else:
        Tool["tag"] = tagDB.get_tag_ids_from_given_ids_list(tooldata["tag"])

    if tooldata.get("support_details"):
        Tool["support_details"] = tooldata["support_details"]
    if tooldata.get("logo"):
        Tool["logo"] = tooldata["logo"]
    if tooldata.get("description"):
        Tool["description"] = tooldata["description"]
    if tooldata.get("tool_creation_source"):
        Tool["tool_creation_source"] = tooldata.get("tool_creation_source")
    if tooldata.get("allow_build_download"):
        Tool["allow_build_download"] = str(
            tooldata.get("allow_build_download"))
    else:
        Tool["allow_build_download"] = 'False'
    if tooldata.get("is_tool_cloneable"):
        Tool["is_tool_cloneable"] = str(
            tooldata.get("is_tool_cloneable"))
    if tooldata.get("artifacts_only"):
        Tool["artifacts_only"] = str(
            tooldata.get("artifacts_only"))
    
    Tool["status"]=tooldata.get("status","1")   

    Tool = HelperServices.add_update_logo(Tool, logo_path, full_logo_path, directory_to_import_from)
    # ADD UPDATE DATA
    if tool_id:
        Tool["_id"] = {}
        Tool["_id"]["oid"] = tool_id        
        result = toolDB.update_tool(Tool)
    else:        
        result = toolDB.add_tool(Tool)
    if result is None:
        raise Exception("Unable to create/update tool " + Tool["name"])
    else:
        # RELOAD TEAM PERMISSIONS
        teamService.generate_details()
    return str(result)
コード例 #2
0
def add_update_du_set(deploymentUnitSetData, deployment_unit_set_id=None, logo_path=None, logo_full_path=None,directory_to_import_from=None):
    """Add update DeploymentUnitSet data"""
    
    # Mandatory Keys
    keys_to_validate=["name","du_set"]
    for key in keys_to_validate:
        if not deploymentUnitSetData.get(key): raise Exception ("mandatory key: "+ key+" is missing in DU details")
    if (deploymentUnitSetData.get("name")):
        HelperServices.validate_name(deploymentUnitSetData.get("name"),"deploymentunit package name")
    verify_du_set_data(deploymentUnitSetData)
    verify_du_and_du_set_data(deploymentUnitSetData)
   
    #ADD LOGO
    deploymentUnitSetData = HelperServices.add_update_logo(
            deploymentUnitSetData, logo_path, logo_full_path, directory_to_import_from)
    
    #TRIM NOT REQUIRED DATA
    deploymentUnitSetData = trim_du_duset_data(deploymentUnitSetData)
        
    #VALIDATION    
    if deployment_unit_set_id:
        existing_du_set_details = deploymentunitsetdb.GetDeploymentUnitSetById(
                                 deployment_unit_set_id, False)
        if not existing_du_set_details:
            raise Exception("No such DeploymentUnit Set was found with _id: ")  
    else:
        #TRY TO SEARCH WITH NAME
        existing_du_set=deploymentunitsetdb.GetDeploymentUnitSetByName(deploymentUnitSetData.get("name"),False)
        if  existing_du_set:
            deployment_unit_set_id=str(existing_du_set["_id"])
                    
    if deployment_unit_set_id:    
        deploymentUnitSetData["_id"] = {}
        deploymentUnitSetData["_id"]["oid"] = deployment_unit_set_id
        result = deploymentunitsetdb.UpdateDeploymentUnitSet(
            deploymentUnitSetData)
    else:
        add_missing_attributes_for_duset(deploymentUnitSetData)
        result = deploymentunitsetdb.AddNewDeploymentUnitSet(
            deploymentUnitSetData)
    if result is None:
        raise Exception("Unable to create/update DeploymentUnit Set")
    else:
        # RELOAD TEAM PERMISSIONS
        teamService.generate_details()
    return str(result)
コード例 #3
0
def add_update_tool_set(toolSetData, tool_set_id=None, logo_path=None, logo_full_path=None):
    """Add ToolSetData"""
    toolSetData = verify_tool_set_data(toolSetData)
    if logo_path and logo_full_path:
        toolSetData = HelperServices.add_update_logo(toolSetData, logo_path, logo_full_path, None)
    if tool_set_id:
        toolSetData["_id"] = {}
        toolSetData["_id"]["oid"] = tool_set_id
        result = toolsetdb.update_tool_set(toolSetData)
    else:
        result = toolsetdb.add_new_tool_set(toolSetData)
    if result is None:
        raise Exception("Unable to create/update ToolSet ")
    else:
        # RELOAD TEAM PERMISSIONS
        teamService.generate_details()
    return str(result)