def execute_managers(self, managers): results = dict(changed=False) for manager in managers: result = manager.exec_module() for k, v in iteritems(result): if k == 'changed': if v is True: results['changed'] = True else: results[k] = v return results
def execute_managers(self, managers): results = dict(changed=False) for manager in managers: result = manager.exec_module() for k, v in iteritems(result): if k == 'changed': if v is True: results['changed'] = True else: results[k] = v return results
def install_command(self): cmd = 'tmsh load sys ucs /var/local/ucs/{0}'.format(self.basename) # Append any options that might be specified options = OrderedDict(sorted(self.options.items(), key=lambda t: t[0])) print(options) for k, v in iteritems(options): if v is False or v is None: continue elif k == 'passphrase': cmd += ' %s %s' % (k, v) else: cmd += ' %s' % (k) return cmd
def install_command(self): cmd = 'tmsh load sys ucs /var/local/ucs/{0}'.format(self.basename) # Append any options that might be specified options = OrderedDict(sorted(self.options.items(), key=lambda t: t[0])) print(options) for k, v in iteritems(options): if v is False or v is None: continue elif k == 'passphrase': cmd += ' %s %s' % (k, v) else: cmd += ' %s' % (k) return cmd
def variables(self): result = [] if not self._values['variables']: return None variables = self._values['variables'] for variable in variables: tmp = dict((str(k), str(v)) for k, v in iteritems(variable)) if 'encrypted' not in tmp: # BIG-IP will inject an 'encrypted' key if you don't provide one. # If you don't provide one, then we give you the default 'no', by # default. tmp['encrypted'] = 'no' if 'value' not in tmp: tmp['value'] = '' result.append(tmp) result = sorted(result, key=lambda k: k['name']) return result
def lists(self): result = [] if not self._values['lists']: return None lists = self._values['lists'] for list in lists: tmp = dict((str(k), str(v)) for k, v in iteritems(list) if k != 'value') if 'encrypted' not in list: # BIG-IP will inject an 'encrypted' key if you don't provide one. # If you don't provide one, then we give you the default 'no', by # default. tmp['encrypted'] = 'no' if 'value' in list: if len(list['value']) > 0: # BIG-IP removes empty values entries, so mimic this behavior # for user-supplied values. tmp['value'] = [str(x) for x in list['value']] result.append(tmp) result = sorted(result, key=lambda k: k['name']) return result
def update(self, params=None): if params: for k, v in iteritems(params): if self.api_map is not None and k in self.api_map: map_key = self.api_map[k] else: map_key = k # Handle weird API parameters like `dns.proxy.__iter__` by # using a map provided by the module developer class_attr = getattr(type(self), map_key, None) if isinstance(class_attr, property): # There is a mapped value for the api_map key if class_attr.fset is None: # If the mapped value does not have an associated setter self._values[map_key] = v else: # The mapped value has a setter setattr(self, map_key, v) else: # If the mapped value is not a @property self._values[map_key] = v
def update(self, params=None): if params: for k, v in iteritems(params): if self.api_map is not None and k in self.api_map: map_key = self.api_map[k] else: map_key = k # Handle weird API parameters like `dns.proxy.__iter__` by # using a map provided by the module developer class_attr = getattr(type(self), map_key, None) if isinstance(class_attr, property): # There is a mapped value for the api_map key if class_attr.fset is None: # If the mapped value does not have an associated setter self._values[map_key] = v else: # The mapped value has a setter setattr(self, map_key, v) else: # If the mapped value is not a @property self._values[map_key] = v