Пример #1
0
    def createHardwareProfile(self):
        """
        Create hardware profile
        """

        response = None

        postdata = cherrypy.request.json

        hwProfileDict = postdata['hardwareProfile']

        settingsDict = postdata['settingsDict'] \
            if 'settingsDict' in postdata else {}

        if 'osInfo' in settingsDict and settingsDict['osInfo']:
            settingsDict['osInfo'] = OsInfo.getFromDict(settingsDict['osInfo'])

        hwProfile = HardwareProfile.getFromDict(hwProfileDict)

        try:
            HardwareProfileManager().createHardwareProfile(
                cherrypy.request.db, hwProfile, settingsDict=settingsDict)
        except Exception as ex:
            self.getLogger().exception(
                'hardware profile WS API createHardwareProfile() failed')

            self.getLogger().exception(ex)

            self.handleException(ex)

            response = self.errorResponse(str(ex))

        return self.formatResponse(response)
Пример #2
0
    def getFromDict(cls, dict_, ignore: Optional[Iterable[str]] = None):
        osDict = dict.get(OsInfo.ROOT_TAG)
        osInfo = OsInfo.getFromDict(osDict)

        osComponent = super(OsComponent, cls).getFromDict(dict_)

        osComponent.setOsInfo(osInfo)

        return osComponent
Пример #3
0
    def getFromDict(cls, dict_):
        osDict = dict.get(OsInfo.ROOT_TAG)
        osInfo = OsInfo.getFromDict(osDict)

        osComponent = super(OsComponent, cls).getFromDict(dict_)

        osComponent.setOsInfo(osInfo)

        return osComponent