Skip to content
Snippets Groups Projects
Select Git revision
  • c55c2a4c469a03fd808f3be58170216f06ca151c
  • master default
  • v0.52.5
  • v0.52.4
  • v0.52.3
  • v0.52.2
  • v0.52.1
  • v0.52.0
  • v0.51.0
  • v0.50.0
  • v0.49.0
11 results

import_users.py

Blame
    • root's avatar
      c55c2a4c
      Add support table param for mysql.user state (by default table is *) · c55c2a4c
      root authored
      Add support of changing/adding any attribute in my.cnf. NB!!! It breaks backward compatibility for mysql.server state.
      Delete mysql_size param support (now you can customiza all my.cnf parameters in pillar)
      Add script import_users.py that create user pillar for existent server
      Add support root@localhost mysql user without password (root_password = False)
      Add support of grant_option
      c55c2a4c
      History
      Add support table param for mysql.user state (by default table is *)
      root authored
      Add support of changing/adding any attribute in my.cnf. NB!!! It breaks backward compatibility for mysql.server state.
      Delete mysql_size param support (now you can customiza all my.cnf parameters in pillar)
      Add script import_users.py that create user pillar for existent server
      Add support root@localhost mysql user without password (root_password = False)
      Add support of grant_option
    dns.py 1.97 KiB
    # provide a higher level interface to pydns
    
    import DNS
    from DNS import DNSError
    
    MAX_CNAME = 10
    
    def DNSLookup(name, qtype):
        try:
            req = DNS.DnsRequest(name, qtype=qtype)
            resp = req.req()
            #resp.show()
            # key k: ('wayforward.net', 'A'), value v
            # FIXME: pydns returns AAAA RR as 16 byte binary string, but
            # A RR as dotted quad.  For consistency, this driver should
            # return both as binary string.
            return [((a['name'], a['typename']), a['data']) for a in resp.answers]
        except IOError, x:
            raise DNSError, str(x)
    
    class Session(object):
      """A Session object has a simple cache with no TTL that is valid
       for a single "session", for example an SMTP conversation."""
      def __init__(self):
        self.cache = {}
    
      def dns(self, name, qtype, cnames=None):
        """DNS query.
    
        If the result is in cache, return that.  Otherwise pull the
        result from DNS, and cache ALL answers, so additional info
        is available for further queries later.
    
        CNAMEs are followed.
    
        If there is no data, [] is returned.
    
        pre: qtype in ['A', 'AAAA', 'MX', 'PTR', 'TXT', 'SPF']
        post: isinstance(__return__, types.ListType)
        """
        result = self.cache.get( (name, qtype) )
        cname = None
    
        if not result:
            safe2cache = query.SAFE2CACHE
            for k, v in DNSLookup(name, qtype, self.strict):
                if k == (name, 'CNAME'):
                    cname = v
                if (qtype,k[1]) in safe2cache:
                    self.cache.setdefault(k, []).append(v)
            result = self.cache.get( (name, qtype), [])
        if not result and cname:
            if not cnames:
                cnames = {}
            elif len(cnames) >= MAX_CNAME:
                #return result    # if too many == NX_DOMAIN
                raise DNSError('Length of CNAME chain exceeds %d' % MAX_CNAME)
            cnames[name] = cname
            if cname in cnames:
                raise DNSError, 'CNAME loop'
            result = self.dns(cname, qtype, cnames=cnames)
        return result