示例#1
0
def validateJson(newJsonObj):
    ''' Validate input json against defined schema
    '''
    try:
        theSchema = getPlanSchema(newJsonObj['platform']['name'])
        loadDocumentFromDict(convertToDotDictRecurse(newJsonObj), theSchema.schema)
        return True
    except Exception, e:
        return "Invalid JSON: " + str(e)
示例#2
0
def validateJson(newJsonObj):
    ''' Validate input json against defined schema
    '''
    try:
        theSchema = getPlanSchema(newJsonObj['platform']['name'])
        loadDocumentFromDict(convertToDotDictRecurse(newJsonObj), theSchema.schema)
        return True
    except Exception, e:
        return "Invalid JSON: " + str(e)
示例#3
0
 def toXpjson(self):
     platform = self.jsonPlan['platform']
     if platform:
         planSchema = getPlanSchema(platform[u'name'])
         return xpjson.loadDocumentFromDict(self.jsonPlan,
                                            schema=planSchema.getSchema())
     logging.warning('toXpjson: could not convert to xpjson, probably no schema %s',
                     self.uuid)
     raise  # FIX
示例#4
0
 def toXpjson(self):
     platform = self.jsonPlan['platform']
     if platform:
         planSchema = getPlanSchema(platform[u'name'])
         return xpjson.loadDocumentFromDict(self.jsonPlan,
                                            schema=planSchema.getSchema())
     logging.warning(
         'toXpjson: could not convert to xpjson, probably no schema %s',
         self.uuid)
     raise  # FIX
示例#5
0
def planDocFromPlanDict(planDict, schema):
    # downstream processing tools assume plan is a DotDict
    planDict = convertToDotDictRecurse(planDict)

    planDoc = (xpjson.loadDocumentFromDict(
        planDict,
        schema=schema,
        parseOpts=xpjson.ParseOpts(fillInDefaults=True)))

    # fill in ids
    fillIds = FillIdsPlanExporter()
    return fillIds.exportPlan(planDoc, schema)
示例#6
0
def planDocFromPlanDict(planDict, schema):
    # downstream processing tools assume plan is a DotDict
    planDict = convertToDotDictRecurse(planDict)

    planDoc = (xpjson.loadDocumentFromDict
               (planDict,
                schema=schema,
                parseOpts=xpjson.ParseOpts(fillInDefaults=True)))

    # fill in ids
    fillIds = FillIdsPlanExporter()
    return fillIds.exportPlan(planDoc, schema)