'configures the source IP address for sFlow packets'

def config_source(self):

    xml_str = ''
    if (not self.source_ip):
        return xml_str
    self.source_version = get_ip_version(self.source_ip)
    if (not self.source_version):
        self.module.fail_json(msg='Error:    source_ip    is    invalid.')
    src_dict = dict()
    for src in self.sflow_dict['source']:
        if (src.get('family') == self.source_version):
            src_dict = src
            break
    if (self.state == 'present'):
        if ((self.source_ip != src_dict.get('ipv4Addr')) and (self.source_ip != src_dict.get('ipv6Addr'))):
            xml_str += '<sources><source    operation="merge">'
            xml_str += ('<family>%s</family>' % self.source_version)
            if (self.source_version == 'ipv4'):
                xml_str += ('<ipv4Addr>%s</ipv4Addr>' % self.source_ip)
                self.updates_cmd.append(('sflow    source    ip    %s' % self.source_ip))
            else:
                xml_str += ('<ipv6Addr>%s</ipv6Addr>' % self.source_ip)
                self.updates_cmd.append(('sflow    source    ipv6    %s' % self.source_ip))
            xml_str += '</source    ></sources>'
    elif (self.source_ip == src_dict.get('ipv4Addr')):
        xml_str += '<sources><source    operation="delete"><family>ipv4</family></source    ></sources>'
        self.updates_cmd.append(('undo    sflow    source    ip    %s' % self.source_ip))
    elif (self.source_ip == src_dict.get('ipv6Addr')):
        xml_str += '<sources><source    operation="delete"><family>ipv6</family></source    ></sources>'
        self.updates_cmd.append(('undo    sflow    source    ipv6    %s' % self.source_ip))
    return xml_str
