def main(self): violations = [] # build list of values from configured data value_builder = ValueBuilder(self._client, 'verify') for key, value in self._data.items(): value_builder.build('', key, value) for expected_value in value_builder.values: if expected_value.state == State.PRESENT: violations.append({ 'path': expected_value.path, 'expected-value': 'present', 'value': 'absent' }) elif expected_value.state == State.ABSENT: violations.append({ 'path': expected_value.path, 'expected-value': 'absent', 'value': 'present' }) elif expected_value.state == State.SET: try: value = self._client.get_value( expected_value.path)['value'] except NsoException as ex: if ex.error.get('type', '') == 'data.not_found': value = None else: raise # handle different types properly n_value = normalize_value(expected_value.value, value, expected_value.path) if n_value != expected_value.value: # if the value comparision fails, try mapping identityref value_type = value_builder.get_type(expected_value.path) if value_type is not None and 'identityref' in value_type: n_value, t_value = self.get_prefix_name(value) if expected_value.value != n_value: violations.append({ 'path': expected_value.path, 'expected-value': expected_value.value, 'value': n_value }) else: raise ModuleFailException( 'value state {0} not supported at {1}'.format( expected_value.state, expected_value.path)) return violations
def main(self): # build list of values from configured data value_builder = ValueBuilder(self._client) for key, value in self._data.items(): value_builder.build('', key, value) self._data_write(value_builder.values) # check sync AFTER configuration is written sync_values = self._sync_check(value_builder.values) self._sync_ensure(sync_values) return self._changes, self._diffs
def main(self): # build list of values from configured data value_builder = ValueBuilder(self._client) for key, value in self._data.items(): value_builder.build('', key, value) self._data_write(value_builder.values) # check sync AFTER configuration is written sync_values = self._sync_check(value_builder.values) self._sync_ensure(sync_values) return self._changes, self._diffs