Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)