code: def modify_access(src, dst='any', port=None, proto=None, action='allow',
                    index=None):
      
      if not is_enabled():
          hookenv.log('ufw is disabled, skipping modify_access()', level='WARN')
          return
  
      if action == 'delete':
          cmd = ['ufw', 'delete', 'allow']
      elif index is not None:
          cmd = ['ufw', 'insert', str(index), action]
      else:
          cmd = ['ufw', action]
  
      if src is not None:
          cmd += ['from', src]
  
      if dst is not None:
          cmd += ['to', dst]
  
      if port is not None:
          cmd += ['port', str(port)]
  
      if proto is not None:
          cmd += ['proto', proto]
  
      hookenv.log('ufw {}: {}'.format(action, ' '.join(cmd)), level='DEBUG')
      p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
      (stdout, stderr) = p.communicate()
  
      hookenv.log(stdout, level='INFO')
  
      if p.returncode != 0:
          hookenv.log(stderr, level='ERROR')
          hookenv.log('Error running: {}, exit code: {}'.format(' '.join(cmd),
                                                                p.returncode),
                      level='ERROR')
docs: Grant access to an address or subnet
  
      :param src: address (e.g. 192.168.1.234) or subnet
                  (e.g. 192.168.1.0/24).
      :param dst: destiny of the connection, if the machine has multiple IPs and
                  connections to only one of those have to accepted this is the
                  field has to be set.
      :param port: destiny port
      :param proto: protocol (tcp or udp)
      :param action: `allow` or `delete`
      :param index: if different from None the rule is inserted at the given
                    `index`.