Esempio n. 1
0
    def wmUpdateDeploymentDetail(self):
        sDeploymentID = uiCommon.getAjaxArg("id")
        sColumn = uiCommon.getAjaxArg("column")
        sValue = uiCommon.getAjaxArg("value")

        sUserID = uiCommon.GetSessionUserID()

        if catocommon.is_guid(sDeploymentID) and catocommon.is_guid(sUserID):
            d = deployment.Deployment()
            d.FromID(sDeploymentID)

            # we encoded this in javascript before the ajax call.
            # the safest way to unencode it is to use the same javascript lib.
            # (sometimes the javascript and .net libs don't translate exactly, google it.)
            sValue = uiCommon.unpackJSON(sValue)

            #  check for existing name
            if sColumn == "Name":
                if d.Name == sValue:
                    return sValue + " exists, please choose another name."

            # cool, update the class attribute by name, using getattr!
            # python is so cool.. I don't even need to check if the attribute I wanna set exists.
            # just set it
            setattr(d, sColumn, sValue)

            d.DBUpdate()
            uiCommon.WriteObjectChangeLog(catocommon.CatoObjectTypes.Deployment, sDeploymentID, sColumn, sValue)

        return json.dumps({"result": "success"})
Esempio n. 2
0
    def wmDeleteDeploymentGroup(self):
        sDeploymentID = uiCommon.getAjaxArg("id")
        sGroupName = uiCommon.getAjaxArg("group_name")

        sUserID = uiCommon.GetSessionUserID()

        if catocommon.is_guid(sDeploymentID) and catocommon.is_guid(sUserID):
            d = deployment.Deployment()
            d.FromID(sDeploymentID)

            d.DeleteGroup(sGroupName)
            uiCommon.WriteObjectChangeLog(catocommon.CatoObjectTypes.Deployment, sDeploymentID, d.Name, "Removed Group [%s]" % (sGroupName))

        return json.dumps({"result": "success"})