def open_firewall_for_docker_api(distribution):
 if is_centos_or_rhel(distribution):
  upload = put(path='/usr/lib/firewalld/services/docker.xml', content=dedent('                         <?xml version="1.0" encoding="utf-8"?>\n                         <service>\n                         <short>Docker API Port</short>\n                         <description>The Docker API, over TLS.</description>\n                         <port protocol="tcp" port="2376"/>\n                         </service>\n                         '))
  open_firewall = open_firewalld
 elif is_ubuntu(distribution):
  upload = put(path='/etc/ufw/applications.d/docker', content=dedent('\n                         [docker]\n                         title=Docker API\n                         description=Docker API.\n                         ports=2376/tcp\n                         '))
  open_firewall = open_ufw
 else:
  raise DistributionNotSupported(distribution=distribution)
 return sequence([upload, open_firewall('docker')])

def open_firewall_for_docker_api ( distribution ) : if is_centos_or_rhel ( distribution ) : upload = put ( path = '/usr/lib/firewalld/services/docker.xml' , content = dedent ( '                         <?xml version="1.0" encoding="utf-8"?>\n                         <service>\n                         <short>Docker API Port</short>\n                         <description>The Docker API, over TLS.</description>\n                         <port protocol="tcp" port="2376"/>\n                         </service>\n                         ' ) ) open_firewall = open_firewalld elif is_ubuntu ( distribution ) : upload = put ( path = '/etc/ufw/applications.d/docker' , content = dedent ( '\n                         [docker]\n                         title=Docker API\n                         description=Docker API.\n                         ports=2376/tcp\n                         ' ) ) open_firewall = open_ufw else : raise DistributionNotSupported ( distribution = distribution ) return sequence ( [ upload , open_firewall ( 'docker' ) ] )
open the firewall for remote access to docker api .