def verify_value(self, bigip, tag, value): tag_def = self.valid_esd_tags.get(tag) # verify resource type resource_type = self.get_resource_type(bigip, tag_def['resource_type'], value) if not resource_type: msg = 'Unable to determine resource type for tag {0} and ' \ 'value {1}'.format(tag, value) raise f5_ex.esdJSONFileInvalidException(msg) # verify value type value_type = tag_def['value_type'] if not isinstance(value, value_type): msg = 'Invalid value {0} for tag {1}. ' \ 'Type must be {2}.'.format(value, tag, value_type) raise f5_ex.esdJSONFileInvalidException(msg) # verify value exists on BIG-IP if isinstance(value, list): is_valid = self.is_valid_value_list(bigip, value, resource_type) else: is_valid = self.is_valid_value(bigip, value, resource_type) if not is_valid: msg = ("Invalid value {0} for tag {1}".format(value, tag)) raise f5_ex.esdJSONFileInvalidException(msg)
def verify_value(self, bigip, tag, value): tag_def = self.valid_esd_tags.get(tag) # verify resource type resource_type = self.get_resource_type( bigip, tag_def['resource_type'], value) if not resource_type: msg = 'Unable to determine resource type for tag {0} and ' \ 'value {1}'.format(tag, value) raise f5_ex.esdJSONFileInvalidException(msg) # verify value type value_type = tag_def['value_type'] if not isinstance(value, value_type): msg = 'Invalid value {0} for tag {1}. ' \ 'Type must be {2}.'.format(value, tag, value_type) raise f5_ex.esdJSONFileInvalidException(msg) # verify value exists on BIG-IP if isinstance(value, list): is_valid = self.is_valid_value_list(bigip, value, resource_type) else: is_valid = self.is_valid_value(bigip, value, resource_type) if not is_valid: msg = ("Invalid value {0} for tag {1}".format(value, tag)) raise f5_ex.esdJSONFileInvalidException(msg)
def read_json(self): for fileList in self.esdJSONFileList: try: with open(fileList) as json_file: # Reading each file to a dictionary fileJSONDict = json.load(json_file) # Combine all dictionaries to one self.esdJSONDict.update(fileJSONDict) except ValueError as err: LOG.error('ESD JSON File is invalid: %s', err) raise f5_ex.esdJSONFileInvalidException() return self.esdJSONDict
def read_json(self): for fileList in self.esdJSONFileList: try: with open(fileList) as json_file: # Reading each file to a dictionary fileJSONDict = json.load(json_file) # Combine all dictionaries to one self.esdJSONDict.update(fileJSONDict) except ValueError as err: LOG.error('ESD JSON File is invalid: %s', err) raise f5_ex.esdJSONFileInvalidException() return self.esdJSONDict
def verify_tag(self, tag): if not self.is_valid_tag(tag): msg = 'Tag {0} is not valid.'.format(tag) raise f5_ex.esdJSONFileInvalidException(msg)
def verify_tag(self, tag): if not self.is_valid_tag(tag): msg = 'Tag {0} is not valid.'.format(tag) raise f5_ex.esdJSONFileInvalidException(msg)