def sanity_check_params(self, id, nvpairs, existence_only=False): ''' nvpairs is a list of <nvpair> tags. - are all required parameters defined - do all parameters exist ''' rc = 0 d = {} for nvp in nvpairs: if 'name' in nvp.attrib and 'value' in nvp.attrib: d[nvp.get('name')] = nvp.get('value') if not existence_only: for p in self.reqd_params_list(): if self.unreq_param(p): continue if p not in d: common_err("%s: required parameter %s not defined" % (id, p)) rc |= utils.get_check_rc() for p in d: if p.startswith("$"): # these are special, non-RA parameters continue if p not in self.params(): common_err("%s: parameter %s does not exist" % (id, p)) rc |= utils.get_check_rc() return rc
def sanity_check_params(self, id, pl, existence_only=False): ''' pl is a list of (attribute, value) pairs. - are all required parameters defined - do all parameters exist ''' rc = 0 d = {} for p, v in pl: d[p] = v if not existence_only: for p in self.reqd_params_list(): if self.unreq_param(p): continue if p not in d: common_err("%s: required parameter %s not defined" % (id, p)) rc |= utils.get_check_rc() for p in d: if p.startswith("$"): # these are special, non-RA parameters continue if p not in self.params(): common_err("%s: parameter %s does not exist" % (id, p)) rc |= utils.get_check_rc() return rc
def sanity_check_nvpairs(id, node, attr_list): rc = 0 for nvpair in node.iterchildren("nvpair"): n = nvpair.get("name") if n and not n in attr_list: common_err("%s: attribute %s does not exist" % (id, n)) rc |= utils.get_check_rc() return rc