1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Cleanup per notes.

Some small changes to per notes from @mpdehann.
This commit is contained in:
Richard C Isaacson 2014-02-12 10:01:10 -06:00
parent cb7c2b7524
commit 598b9c6b7c
4 changed files with 34 additions and 22 deletions

View file

@ -63,7 +63,7 @@ class ActionModule(object):
remote_md5 = self.runner._remote_md5(conn, tmp, dest)
if remote_md5 != '3':
result = dict(failed=True, msg="dest must be an existing dir", rc=remote_md5)
result = dict(failed=True, msg="dest must be an existing dir")
return ReturnData(conn=conn, result=result)
if copy:

View file

@ -69,7 +69,7 @@ import os
# class to handle .zip files
class _zipfile(object):
class ZipFile(object):
def __init__(self, src, dest, module):
self.src = src
@ -93,7 +93,7 @@ class _zipfile(object):
# class to handle gzipped tar files
class _tgzfile(object):
class TgzFile(object):
def __init__(self, src, dest, module):
self.src = src
@ -124,7 +124,7 @@ class _tgzfile(object):
# class to handle tar files that aren't compressed
class _tarfile(_tgzfile):
class TarFile(TgzFile):
def __init__(self, src, dest, module):
self.src = src
self.dest = dest
@ -133,7 +133,7 @@ class _tarfile(_tgzfile):
# class to handle bzip2 compressed tar files
class _tarbzip(_tgzfile):
class TarBzip(TgzFile):
def __init__(self, src, dest, module):
self.src = src
self.dest = dest
@ -142,7 +142,7 @@ class _tarbzip(_tgzfile):
# class to handle xz compressed tar files
class _tarxz(_tgzfile):
class TarXz(TgzFile):
def __init__(self, src, dest, module):
self.src = src
self.dest = dest
@ -152,7 +152,7 @@ class _tarxz(_tgzfile):
# try handlers in order and return the one that works or bail if none work
def pick_handler(src, dest, module):
handlers = [_tgzfile, _zipfile, _tarfile, _tarbzip, _tarxz]
handlers = [TgzFile, ZipFile, TarFile, TarBzip, TarXz]
for handler in handlers:
obj = handler(src, dest, module)
if obj.can_handle_archive():

View file

@ -416,10 +416,10 @@ class TestPlaybook(unittest.TestCase):
expected = {
"localhost": {
"changed": 41,
"changed": 29,
"failures": 0,
"ok": 45,
"skipped": 0,
"ok": 33,
"skipped": 12,
"unreachable": 0
}
}

View file

@ -14,10 +14,12 @@
- unarchive: src={{filesdir}}/test.tar dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{filesdir}}/test.tar dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Simple tar.gz unarchive."
command: rm -rf {{testdir}}
@ -25,10 +27,12 @@
- unarchive: src={{filesdir}}/test.tar.gz dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{filesdir}}/test.tar.gz dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Simple zip unarchive."
command: rm -rf {{testdir}}
@ -36,10 +40,12 @@
- unarchive: src={{filesdir}}/test.zip dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{filesdir}}/test.zip dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- name: "Unarchive a local tar file."
command : rm -rf {{testdir}}
@ -48,10 +54,12 @@
- unarchive: src={{testdir}}/test.tar dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{testdir}}/test.tar dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Unarchive a local tar.gz file."
command : rm -rf {{testdir}}
@ -60,10 +68,12 @@
- unarchive: src={{testdir}}/test.tar.gz dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{testdir}}/test.tar.gz dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Unarchive a local zip file."
command : rm -rf {{testdir}}
@ -72,7 +82,9 @@
- unarchive: src={{testdir}}/test.zip dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{testdir}}/test.zip dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "True"
- fail: msg="Resource was expected to be changed."
when: not res|changed