Merge pull request #245 from dw/dmw
Log masking, unlinked contributors page, resolv.conf fix, unidirectional routingpull/246/head
commit
2c309a378a
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash -ex
|
#!/bin/bash -ex
|
||||||
# Run the Mitogen tests.
|
# Run the Mitogen tests.
|
||||||
|
|
||||||
MITOGEN_TEST_DISTRO="${MITOGEN_TEST_DISTRO:-debian}"
|
MITOGEN_TEST_DISTRO="${DISTRO:-debian}"
|
||||||
MITOGEN_LOG_LEVEL=debug PYTHONPATH=. ${TRAVIS_BUILD_DIR}/run_tests
|
MITOGEN_LOG_LEVEL=debug PYTHONPATH=. ${TRAVIS_BUILD_DIR}/run_tests
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
|
||||||
|
import imp
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import mitogen.master
|
||||||
|
|
||||||
|
|
||||||
|
class Name(object):
|
||||||
|
def __str__(self):
|
||||||
|
return self.identifier
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Name(%r)' % (self.identifier,)
|
||||||
|
|
||||||
|
def __init__(self, identifier):
|
||||||
|
self.identifier = identifier
|
||||||
|
|
||||||
|
def head(self):
|
||||||
|
head, _, tail = self.identifier.partition('.')
|
||||||
|
return head
|
||||||
|
|
||||||
|
def tail(self):
|
||||||
|
head, _, tail = self.identifier.partition('.')
|
||||||
|
return tail
|
||||||
|
|
||||||
|
def pop_n(self, level):
|
||||||
|
name = self.identifier
|
||||||
|
for _ in xrange(level):
|
||||||
|
if '.' not in name:
|
||||||
|
return None
|
||||||
|
name, _, _ = self.identifier.rpartition('.')
|
||||||
|
return Name(name)
|
||||||
|
|
||||||
|
def append(self, part):
|
||||||
|
return Name('%s.%s' % (self.identifier, part))
|
||||||
|
|
||||||
|
|
||||||
|
class Module(object):
|
||||||
|
def __init__(self, name, path, kind=imp.PY_SOURCE, parent=None):
|
||||||
|
self.name = Name(name)
|
||||||
|
self.path = path
|
||||||
|
if kind == imp.PKG_DIRECTORY:
|
||||||
|
self.path = os.path.join(self.path, '__init__.py')
|
||||||
|
self.kind = kind
|
||||||
|
self.parent = parent
|
||||||
|
|
||||||
|
def fullname(self):
|
||||||
|
bits = [str(self.name)]
|
||||||
|
while self.parent:
|
||||||
|
bits.append(str(self.parent.name))
|
||||||
|
self = self.parent
|
||||||
|
return '.'.join(reversed(bits))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Module(%r, path=%r, parent=%r)' % (
|
||||||
|
self.name,
|
||||||
|
self.path,
|
||||||
|
self.parent,
|
||||||
|
)
|
||||||
|
|
||||||
|
def dirname(self):
|
||||||
|
return os.path.dirname(self.path)
|
||||||
|
|
||||||
|
def code(self):
|
||||||
|
fp = open(self.path)
|
||||||
|
try:
|
||||||
|
return compile(fp.read(), str(self.name), 'exec')
|
||||||
|
finally:
|
||||||
|
fp.close()
|
||||||
|
|
||||||
|
|
||||||
|
def find(name, path=(), parent=None):
|
||||||
|
"""
|
||||||
|
(Name, search path) -> Module instance or None.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
tup = imp.find_module(name.head(), list(path))
|
||||||
|
except ImportError:
|
||||||
|
return parent
|
||||||
|
|
||||||
|
fp, path, (suffix, mode, kind) = tup
|
||||||
|
if fp:
|
||||||
|
fp.close()
|
||||||
|
|
||||||
|
module = Module(name.head(), path, kind, parent)
|
||||||
|
if name.tail():
|
||||||
|
return find_relative(module, Name(name.tail()), path)
|
||||||
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
def find_relative(parent, name, path=()):
|
||||||
|
path = [parent.dirname()] + list(path)
|
||||||
|
return find(name, path, parent=parent)
|
||||||
|
|
||||||
|
|
||||||
|
def path_pop(s, n):
|
||||||
|
return os.pathsep.join(s.split(os.pathsep)[-n:])
|
||||||
|
|
||||||
|
|
||||||
|
def scan(module, path):
|
||||||
|
scanner = mitogen.master.scan_code_imports(module.code())
|
||||||
|
for level, modname_s, fromlist in scanner:
|
||||||
|
modname = Name(modname_s)
|
||||||
|
if level == -1:
|
||||||
|
imported = find_relative(module, modname, path)
|
||||||
|
elif level:
|
||||||
|
subpath = [path_pop(module.dirname(), level)] + list(path)
|
||||||
|
imported = find(modname.pop_n(level), subpath)
|
||||||
|
else:
|
||||||
|
imported = find(modname.pop_n(level), path)
|
||||||
|
|
||||||
|
if imported and mitogen.master.is_stdlib_path(imported.path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if imported and fromlist:
|
||||||
|
have = False
|
||||||
|
for fromname_s in fromlist:
|
||||||
|
fromname = modname.append(fromname_s)
|
||||||
|
f_imported = find_relative(imported, fromname, path)
|
||||||
|
if f_imported and f_imported.fullname() == fromname.identifier:
|
||||||
|
have = True
|
||||||
|
yield fromname, f_imported, None
|
||||||
|
if have:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if imported:
|
||||||
|
yield modname, imported
|
||||||
|
|
||||||
|
|
||||||
|
module = Module(name='ansible_module_apt', path='/Users/dmw/src/mitogen/.venv/lib/python2.7/site-packages/ansible/modules/packaging/os/apt.py')
|
||||||
|
path = tuple(sys.path)
|
||||||
|
path = ('/Users/dmw/src/ansible/lib',) + path
|
||||||
|
|
||||||
|
|
||||||
|
from pprint import pprint
|
||||||
|
for name, imported in scan(module, sys.path):
|
||||||
|
print '%s: %s' % (name, imported and (str(name) == imported.fullname()))
|
@ -0,0 +1,3 @@
|
|||||||
|
<body bgcolor=black>
|
||||||
|
|
||||||
|
<img src="cgi.svg" style="background: white">
|
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="65 4.5 302 141"><defs><style>.a{fill:#e31937;}</style></defs><title>CGI_Logo_color_v2</title><path class="a" d="M140.33,32c-27.4,0-44.2,21.4-44.2,43,0,26,21.2,43,44.4,43,15.4,0,30-6.8,42.4-17.8v32.2c-13,7.8-30.8,12.6-44.6,12.6-39.6,0-72.8-32.2-72.8-70,0-40,33.4-70,73-70,15.2,0,33,4.6,44.6,10.4V47C168.53,37.4,153.73,32,140.33,32Z"/><path class="a" d="M267.11,145c-39.8,0-73.4-31-73.4-70,0-39.4,33.4-70,75.2-70,15.2,0,34,4,45.6,9.4V45.8c-13.2-7.6-30.2-13.8-45-13.8-27.4,0-45.2,21.4-45.2,43,0,25.4,21,43.8,45.6,43.8a43.78,43.78,0,0,0,16.6-2.8V90.8h-22.4V64.2h51.2V135A116.82,116.82,0,0,1,267.11,145Z"/><path class="a" d="M337.67,142.2V7.8h28.8V142.2h-28.8Z"/></svg>
|
After Width: | Height: | Size: 714 B |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 9.4 KiB |
@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="211.087" height="55.108">
|
||||||
|
<path fill="#007CBA" d="M153.115 35.018V21.074h3.336v11.175h8.62v2.769h-11.956zm14.683-13.944h3.343v13.943h-3.343V21.074zm6.151 13.944V21.074h5.613l8.496 11.175h.461V21.074h3.334v13.943h-5.723l-8.38-11.171h-.461v11.171h-3.34zm20.44 0V21.074h3.317v5.199h1.962l6.094-5.199h5.002l-8.217 6.528 8.54 7.415h-4.907l-6.445-5.965h-2.028v5.965h-3.318z"/>
|
||||||
|
<path fill="#FF5000" d="M48.995 34.595c-.684-.284-1.173-.713-1.468-1.297-.296-.563-.438-1.323-.438-2.233h3.41c0 .347.159.652.484.922.315.263.71.4 1.17.4h5.582c.745 0 1.292-.126 1.644-.367.35-.25.528-.646.528-1.207 0-.347-.062-.647-.178-.879-.114-.233-.346-.414-.687-.532-.337-.123-.801-.187-1.405-.187h-4.948c-.992 0-1.817-.06-2.462-.17-.65-.111-1.17-.323-1.565-.617-.404-.298-.689-.72-.873-1.273-.189-.547-.281-1.26-.281-2.138 0-.711.092-1.312.295-1.809.192-.508.49-.908.903-1.229.408-.309.933-.538 1.581-.684.646-.153 1.441-.22 2.385-.22h5.673c1.114 0 2.02.138 2.722.414.703.284 1.219.713 1.549 1.296.326.584.482 1.322.482 2.224h-3.332c-.037-.468-.162-.794-.383-.999-.222-.2-.661-.305-1.325-.305h-5.601c-1.076 0-1.615.48-1.615 1.447 0 .582.135.969.405 1.157.264.182.672.269 1.21.269h6.085c.878 0 1.595.044 2.139.133.542.089 1.003.269 1.388.539.378.277.664.7.863 1.252.192.569.282 1.323.282 2.28 0 .981-.159 1.791-.484 2.414-.32.627-.832 1.081-1.519 1.379-.688.3-1.586.443-2.689.443h-6.737c-1.177 0-2.107-.136-2.79-.423m16.639.423V21.074h14.242v2.63H68.961v3.06h10.577v2.431H68.961v3.192h10.915v2.631H65.634zm35.883-1.219c-.841-.811-1.267-2.058-1.267-3.745v-8.979h3.337v8.66c0 .942.202 1.593.595 1.961.398.365 1.053.554 1.977.554h4.604c.563 0 1.027-.085 1.377-.234.356-.17.618-.43.791-.812.172-.377.258-.872.258-1.487v-8.642h3.338v8.979c0 .936-.092 1.709-.277 2.339-.178.625-.467 1.139-.863 1.526-.395.378-.908.663-1.537.836-.627.176-1.398.263-2.31.263h-6.128c-1.756 0-3.052-.411-3.895-1.219m16.983 1.219V21.074h10.584c.782 0 1.461.067 2.053.22.598.146 1.107.396 1.545.765.436.358.767.862 1.012 1.502.234.642.354 1.447.354 2.414 0 .967-.18 1.724-.545 2.264-.363.547-.854 1.006-1.482 1.368.604.24 1.027.419 1.285.55.252.132.492.354.697.669.207.314.305.752.305 1.297v2.895h-3.353v-2.166c0-.7-.206-1.201-.604-1.512-.412-.31-1.089-.461-2.047-.461h-6.445v4.139H118.5zm18.039 0V21.074h14.252v2.63h-10.913v3.06h10.572v2.431h-10.572v3.192h10.913v2.631h-14.252zm-52.474-.477c-.735-.298-1.258-.803-1.571-1.51-.312-.713-.465-1.696-.465-2.956v-3.962c.015-1.356.189-2.401.515-3.128.329-.719.874-1.231 1.634-1.517.765-.291 1.847-.436 3.255-.436h5.485c1.19 0 2.183.132 2.959.401.785.262 1.383.746 1.824 1.449.427.701.646 1.673.646 2.933h-3.46c0-.733-.199-1.253-.589-1.557-.392-.302-1.037-.457-1.949-.457h-4.272c-.795 0-1.372.056-1.742.164-.364.104-.618.326-.762.653-.136.34-.208.871-.208 1.621v3.451c0 .693.087 1.226.269 1.595.179.364.456.615.837.741.377.137.906.199 1.586.199h4.273c.672 0 1.186-.058 1.543-.16.355-.104.619-.304.78-.599.17-.284.253-.721.253-1.29h3.459c-.009 1.274-.155 2.256-.423 2.937-.269.685-.765 1.162-1.477 1.452-.716.287-1.762.437-3.147.437h-6.209c-1.296.001-2.318-.157-3.044-.461m46.214-6.932c.279-.323.424-.874.432-1.634 0-.76-.141-1.309-.413-1.641-.271-.325-.769-.488-1.499-.488h-6.962v4.265h6.962c.704-.001 1.192-.169 1.48-.502M25.134 55.108l-2.936-2.976L33.18 41.317c.661-.721 1.245-1.514 1.752-2.386 3.771-6.555 1.531-14.927-5.016-18.709-3.846-2.225-8.336-2.361-12.133-.771 4.522-2.163 9.989-2.141 14.66.558 7.522 4.34 10.104 13.962 5.763 21.474-.593 1.037-1.3 1.987-2.076 2.826L25.134 55.108zm-11.708-3.67l-2.89-2.929 15.103-14.862c.515-.513.985-1.106 1.373-1.78 2.305-4.003.936-9.118-3.067-11.422-2.113-1.221-4.546-1.406-6.704-.727a.6456.6456 0 0 1 .091-.043c2.822-1.096 6.106-.952 8.94.682 4.966 2.879 6.674 9.232 3.797 14.203-.43.756-.948 1.435-1.536 2.04L13.426 51.438z"/>
|
||||||
|
<path fill="#007CBA" d="M7.865 35.094C.349 30.758-2.234 21.136 2.106 13.616c.599-1.035 1.296-1.979 2.078-2.827L15.184 0l2.923 2.976L7.132 13.785c-.655.719-1.245 1.52-1.748 2.388-3.78 6.548-1.534 14.931 5.017 18.709 3.842 2.228 8.33 2.356 12.127.766-4.517 2.166-9.994 2.147-14.663-.554m6.179-.353c-4.967-2.869-6.674-9.23-3.81-14.194.438-.759.956-1.441 1.54-2.04L26.893 3.659l2.88 2.931-15.1 14.865c-.523.519-.988 1.107-1.378 1.781-2.304 3.997-.925 9.116 3.071 11.427 2.114 1.213 4.548 1.406 6.706.722-.037.013-.061.033-.09.049-2.824 1.092-6.106.934-8.938-.693"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.3 KiB |
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
- import_playbook: resolv_conf.yml
|
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
# This cannot run against localhost, it damages /etc
|
||||||
|
|
||||||
|
- name: integration/glibc_caches/resolv_conf.yml
|
||||||
|
gather_facts: true
|
||||||
|
become: true
|
||||||
|
hosts: test-targets
|
||||||
|
vars:
|
||||||
|
ansible_become_pass: has_sudo_pubkey_password
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- debug: msg={{hostvars}}
|
||||||
|
- mitogen_test_gethostbyname:
|
||||||
|
name: www.google.com
|
||||||
|
register: out
|
||||||
|
when: ansible_virtualization_type == "docker"
|
||||||
|
|
||||||
|
- shell: cp /etc/resolv.conf /tmp/resolv.conf
|
||||||
|
when: ansible_virtualization_type == "docker"
|
||||||
|
|
||||||
|
- shell: echo > /etc/resolv.conf
|
||||||
|
when: ansible_virtualization_type == "docker"
|
||||||
|
|
||||||
|
- mitogen_test_gethostbyname:
|
||||||
|
name: www.google.com
|
||||||
|
register: out
|
||||||
|
ignore_errors: true
|
||||||
|
when: ansible_virtualization_type == "docker"
|
||||||
|
|
||||||
|
- shell: cat /tmp/resolv.conf > /etc/resolv.conf
|
||||||
|
when: ansible_virtualization_type == "docker"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- out.failed
|
||||||
|
- '"Name or service not known" in out.msg or
|
||||||
|
"Temporary failure in name resolution" in out.msg'
|
||||||
|
when: ansible_virtualization_type == "docker"
|
@ -0,0 +1,17 @@
|
|||||||
|
# external2 is loaded from config path.
|
||||||
|
# external1 is loaded from integration/module_utils/module_utils/..
|
||||||
|
|
||||||
|
- name: integration/module_utils/adjacent_to_playbook.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- custom_python_external_module:
|
||||||
|
register: out
|
||||||
|
|
||||||
|
- debug: msg={{out}}
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- out.external1_path == "ansible/integration/module_utils/module_utils/external1.py"
|
||||||
|
- out.external2_path == "ansible/lib/module_utils/external2.py"
|
||||||
|
|
@ -0,0 +1,8 @@
|
|||||||
|
# external2 is loaded from config path.
|
||||||
|
# external1 is loaded from integration/module_utils/roles/modrole/module_utils/..
|
||||||
|
|
||||||
|
- name: integration/module_utils/adjacent_to_playbook.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
roles:
|
||||||
|
- modrole
|
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
- import_playbook: from_config_path.yml
|
||||||
|
- import_playbook: from_config_path_pkg.yml
|
||||||
|
- import_playbook: adjacent_to_playbook.yml
|
||||||
|
- import_playbook: adjacent_to_role.yml
|
||||||
|
- import_playbook: overrides_builtin.yml
|
@ -0,0 +1,15 @@
|
|||||||
|
# external1 and external2 are loaded from config path.
|
||||||
|
|
||||||
|
- name: integration/module_utils/from_config_path.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- custom_python_external_module:
|
||||||
|
register: out
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- out.external1_path == "ansible/lib/module_utils/external1.py"
|
||||||
|
- out.external2_path == "ansible/lib/module_utils/external2.py"
|
||||||
|
|
@ -0,0 +1,14 @@
|
|||||||
|
# external1 and external2 are loaded from config path.
|
||||||
|
|
||||||
|
- name: integration/module_utils/from_config_path.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- custom_python_external_pkg:
|
||||||
|
register: out
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- out.extmod_path == "ansible/lib/module_utils/externalpkg/extmod.py"
|
||||||
|
|
@ -0,0 +1,11 @@
|
|||||||
|
# I am ansible.module_utils.external1 for any module that does not have an
|
||||||
|
# adjacent module_utils directory overriding the name, since I appear in the
|
||||||
|
# 'module_utils' path in ansible.cfg.
|
||||||
|
|
||||||
|
from ansible.module_utils import external2
|
||||||
|
|
||||||
|
def path():
|
||||||
|
return "ansible/integration/module_utils/module_utils/external1.py"
|
||||||
|
|
||||||
|
def path2():
|
||||||
|
return external2.path()
|
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
- name: integration/module_utils/overrides_builtin.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
roles:
|
||||||
|
- overrides_modrole
|
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils import external3
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(argument_spec={})
|
||||||
|
module.exit_json(external2_path=external3.path2(),
|
||||||
|
external3_path=external3.path())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,12 @@
|
|||||||
|
# I am ansible.module_utils.external1 for any module that does not have an
|
||||||
|
# adjacent module_utils directory overriding the name, since I appear in the
|
||||||
|
# 'module_utils' path in ansible.cfg.
|
||||||
|
|
||||||
|
from ansible.module_utils import external2
|
||||||
|
|
||||||
|
def path():
|
||||||
|
return "ansible/integration/module_utils/roles/modroel/module_utils/external1.py"
|
||||||
|
|
||||||
|
def path2():
|
||||||
|
return external2.path()
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
def path():
|
||||||
|
return "integration/module_utils/roles/modrole/module_utils/external2.py"
|
@ -0,0 +1,12 @@
|
|||||||
|
# I am ansible.module_utils.external1 for any module that does not have an
|
||||||
|
# adjacent module_utils directory overriding the name, since I appear in the
|
||||||
|
# 'module_utils' path in ansible.cfg.
|
||||||
|
|
||||||
|
from ansible.module_utils import external2
|
||||||
|
|
||||||
|
def path():
|
||||||
|
return "integration/module_utils/roles/modrole/module_utils/external3.py"
|
||||||
|
|
||||||
|
def path2():
|
||||||
|
return external2.path()
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- uses_external3:
|
||||||
|
register: out
|
||||||
|
|
||||||
|
- debug: msg={{out}}
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- out.external3_path == "integration/module_utils/roles/modrole/module_utils/external3.py"
|
||||||
|
- out.external2_path == "integration/module_utils/roles/modrole/module_utils/external2.py"
|
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import json
|
||||||
|
from ansible.module_utils.basic import path
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print json.dumps({
|
||||||
|
'path': path()
|
||||||
|
})
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,4 @@
|
|||||||
|
# Override basic.py with our own thing.
|
||||||
|
|
||||||
|
def path():
|
||||||
|
return 'ansible/integration/module_utils/roles/override_modrole/module_utils/basic.py'
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- uses_custom_known_hosts:
|
||||||
|
register: out
|
||||||
|
|
||||||
|
- debug: msg={{out}}
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- out.path == "ansible/integration/module_utils/roles/override_modrole/module_utils/known_hosts.py"
|
@ -0,0 +1,11 @@
|
|||||||
|
# I am ansible.module_utils.external1 for any module that does not have an
|
||||||
|
# adjacent module_utils directory overriding the name, since I appear in the
|
||||||
|
# 'module_utils' path in ansible.cfg.
|
||||||
|
|
||||||
|
from ansible.module_utils import external2
|
||||||
|
|
||||||
|
def path():
|
||||||
|
return "ansible/lib/module_utils/external1.py"
|
||||||
|
|
||||||
|
def path2():
|
||||||
|
return external2.path()
|
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
def path():
|
||||||
|
return "ansible/lib/module_utils/external2.py"
|
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
def path():
|
||||||
|
return 'ansible/lib/module_utils/externalpkg/extmod.py'
|
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# I expect the quote from modules2/module_utils/joker.py.
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils import external1
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(argument_spec={})
|
||||||
|
module.exit_json(external1_path=external1.path(),
|
||||||
|
external2_path=external1.path2())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.externalpkg import extmod
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(argument_spec={})
|
||||||
|
module.exit_json(extmod_path=extmod.path())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# I am a module that indirectly depends on glibc cached /etc/resolv.conf state.
|
||||||
|
|
||||||
|
import socket
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(argument_spec={'name': {'type': 'str'}})
|
||||||
|
try:
|
||||||
|
module.exit_json(addr=socket.gethostbyname(module.params['name']))
|
||||||
|
except socket.error, e:
|
||||||
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
import cStringIO
|
||||||
|
|
||||||
|
import unittest2
|
||||||
|
|
||||||
|
import mitogen.core
|
||||||
|
|
||||||
|
|
||||||
|
class BlobTest(unittest2.TestCase):
|
||||||
|
klass = mitogen.core.Blob
|
||||||
|
|
||||||
|
def make(self):
|
||||||
|
return self.klass('x' * 128)
|
||||||
|
|
||||||
|
def test_repr(self):
|
||||||
|
blob = self.make()
|
||||||
|
self.assertEquals('[blob: 128 bytes]', repr(blob))
|
||||||
|
|
||||||
|
def test_decays_on_constructor(self):
|
||||||
|
blob = self.make()
|
||||||
|
self.assertEquals('x'*128, mitogen.core.BytesType(blob))
|
||||||
|
|
||||||
|
def test_decays_on_write(self):
|
||||||
|
blob = self.make()
|
||||||
|
io = cStringIO.StringIO()
|
||||||
|
io.write(blob)
|
||||||
|
self.assertEquals(128, io.tell())
|
||||||
|
self.assertEquals('x'*128, io.getvalue())
|
||||||
|
|
||||||
|
def test_message_roundtrip(self):
|
||||||
|
blob = self.make()
|
||||||
|
msg = mitogen.core.Message.pickled(blob)
|
||||||
|
blob2 = msg.unpickle()
|
||||||
|
self.assertEquals(type(blob), type(blob2))
|
||||||
|
self.assertEquals(repr(blob), repr(blob2))
|
||||||
|
self.assertEquals(mitogen.core.BytesType(blob),
|
||||||
|
mitogen.core.BytesType(blob2))
|
||||||
|
|
||||||
|
|
||||||
|
class SecretTest(unittest2.TestCase):
|
||||||
|
klass = mitogen.core.Secret
|
||||||
|
|
||||||
|
def make(self):
|
||||||
|
return self.klass('password')
|
||||||
|
|
||||||
|
def test_repr(self):
|
||||||
|
secret = self.make()
|
||||||
|
self.assertEquals('[secret]', repr(secret))
|
||||||
|
|
||||||
|
def test_decays_on_constructor(self):
|
||||||
|
secret = self.make()
|
||||||
|
self.assertEquals('password', mitogen.core.UnicodeType(secret))
|
||||||
|
|
||||||
|
def test_decays_on_write(self):
|
||||||
|
secret = self.make()
|
||||||
|
io = cStringIO.StringIO()
|
||||||
|
io.write(secret)
|
||||||
|
self.assertEquals(8, io.tell())
|
||||||
|
self.assertEquals('password', io.getvalue())
|
||||||
|
|
||||||
|
def test_message_roundtrip(self):
|
||||||
|
secret = self.make()
|
||||||
|
msg = mitogen.core.Message.pickled(secret)
|
||||||
|
secret2 = msg.unpickle()
|
||||||
|
self.assertEquals(type(secret), type(secret2))
|
||||||
|
self.assertEquals(repr(secret), repr(secret2))
|
||||||
|
self.assertEquals(mitogen.core.BytesType(secret),
|
||||||
|
mitogen.core.BytesType(secret2))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest2.main()
|
Loading…
Reference in New Issue