def _render_interface_del_commands(self, want, have): """ The command generator for delete commands w.r.t member interfaces :rtype: A list :returns: the commands necessary to update member interfaces """ commands = [] if not want: want = {} have_members = have.get('members') if have_members: have_members = param_list_to_dict(deepcopy(have_members), unique_key='member') want_members = param_list_to_dict(deepcopy(want).get( 'members', []), unique_key='member') for key in have_members: if key not in want_members: member_cmd = ['no bundle id'] pad_commands(member_cmd, key) commands.extend(member_cmd) return commands
def _purge_attribs(self, intf): """ The command generator for purging attributes :rtype: A list :returns: the commands necessary to purge attributes """ commands = [] have_copy = deepcopy(intf) members = have_copy.pop('members', []) to_delete = dict_delete(have_copy, remove_empties({'name': have_copy['name']})) if to_delete: for key, value in iteritems(flatten_dict( remove_empties(to_delete))): commands.append( self._compute_commands(key=key, value=value, remove=True)) if commands: pad_commands(commands, intf['name']) if members: members = param_list_to_dict(deepcopy(members), unique_key='member') for key in members: member_cmd = ['no bundle id'] pad_commands(member_cmd, key) commands.extend(member_cmd) return commands
def set_state(self, want, have): """ Select the appropriate function based on the state provided :param want: the desired configuration as a dictionary :param have: the current configuration as a dictionary :rtype: A list :returns: the commands necessary to migrate the current configuration to the desired configuration """ state = self._module.params['state'] want = param_list_to_dict(want, "vlan_id", remove_key=False) have = param_list_to_dict(have, "vlan_id", remove_key=False) if state == 'overridden': commands = self._state_overridden(want, have) elif state == 'deleted': commands = self._state_deleted(want, have) elif state == 'merged': commands = self._state_merged(want, have) elif state == 'replaced': commands = self._state_replaced(want, have) return commands