Ejemplo n.º 1
0
    def updateHardwareProfile(self, hardwareProfileId):
        """
        Handle PUT to "hardwareprofiles/:(hardwareProfileId)"

        """
        response = None

        try:
            postdata = cherrypy.request.json
            hw_profile = HardwareProfile.getFromDict(postdata)
            hw_profile.setId(hardwareProfileId)
            hp_mgr = HardwareProfileManager()
            hp_mgr.updateHardwareProfile(cherrypy.request.db, hw_profile)

        except HardwareProfileNotFound as ex:
            self.handleException(ex)
            code = self.getTortugaStatusCode(ex)
            response = self.notFoundErrorResponse(str(ex), code)

        except Exception as ex:
            self._logger.exception(
                'hardware profile WS API updateHardwareProfile() failed')
            self.handleException(ex)
            response = self.errorResponse(str(ex))

        return self.formatResponse(response)
Ejemplo n.º 2
0
    def updateHardwareProfile(self, hardwareProfileId):
        '''
        Handle PUT to "hardwareprofiles/:(hardwareProfileId)"
        '''

        response = None

        try:
            postdata = cherrypy.request.json

            hwProfile = HardwareProfile.getFromDict(postdata)

            # Make sure the id is synced
            hwProfile.setId(hardwareProfileId)

            hpMgr = HardwareProfileManager()

            hpMgr.updateHardwareProfile(hwProfile)
        except HardwareProfileNotFound as ex:
            self.handleException(ex)
            code = self.getTortugaStatusCode(ex)
            response = self.notFoundErrorResponse(str(ex), code)
        except Exception as ex:
            self.getLogger().exception(
                'hardware profile WS API updateHardwareProfile() failed')

            self.handleException(ex)

            response = self.errorResponse(str(ex))

        return self.formatResponse(response)