Skip to content

Commit

Permalink
ce_file_copy: fix broken import (ansible#34023)
Browse files Browse the repository at this point in the history
* fix broken import

* doc: use formatting functions
  • Loading branch information
pilou- authored and gundalow committed Dec 20, 2017
1 parent 663f846 commit 4713d9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
27 changes: 19 additions & 8 deletions lib/ansible/modules/network/cloudengine/ce_file_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,32 @@
notes:
- The feature must be enabled with feature scp-server.
- If the file is already present, no transfer will take place.
requirements:
- paramiko
options:
local_file:
description:
- Path to local file. Local directory must exist.
The maximum length of local_file is 4096.
The maximum length of I(local_file) is C(4096).
required: true
remote_file:
description:
- Remote file path of the copy. Remote directories must exist.
If omitted, the name of the local file will be used.
The maximum length of remote_file is 4096.
The maximum length of I(remote_file) is C(4096).
required: false
default: null
file_system:
description:
- The remote file system of the device. If omitted,
devices that support a file_system parameter will use
devices that support a I(file_system) parameter will use
their default values.
File system indicates the storage medium and can be set to as follows,
1) 'flash:' is root directory of the flash memory on the master MPU.
2) 'slave#flash:' is root directory of the flash memory on the slave MPU.
1) C(flash) is root directory of the flash memory on the master MPU.
2) C(slave#flash) is root directory of the flash memory on the slave MPU.
If no slave MPU exists, this drive is unavailable.
3) 'chassis ID/slot number#flash:' is root directory of the flash memory on
a device in a stack. For example, 1/5#flash indicates the flash memory
3) C(chassis ID/slot number#flash) is root directory of the flash memory on
a device in a stack. For example, C(1/5#flash) indicates the flash memory
whose chassis ID is 1 and slot number is 5.
required: false
default: 'flash:'
Expand Down Expand Up @@ -111,10 +113,15 @@
import os
import time
from xml.etree import ElementTree
import paramiko
from ansible.module_utils.basic import get_exception, AnsibleModule
from ansible.module_utils.network.cloudengine.ce import ce_argument_spec, run_commands, get_nc_config

try:
import paramiko
HAS_PARAMIKO = True
except ImportError:
HAS_PARAMIKO = False

try:
from scp import SCPClient
HAS_SCP = True
Expand Down Expand Up @@ -327,6 +334,10 @@ def work(self):
self.module.fail_json(
msg="'Error: No scp package, please install it.'")

if not HAS_PARAMIKO:
self.module.fail_json(
msg="'Error: No paramiko package, please install it.'")

if self.local_file and len(self.local_file) > 4096:
self.module.fail_json(
msg="'Error: The maximum length of local_file is 4096.'")
Expand Down
1 change: 0 additions & 1 deletion test/sanity/import/skip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ lib/ansible/modules/cloud/webfaction/webfaction_db.py
lib/ansible/modules/cloud/webfaction/webfaction_domain.py
lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
lib/ansible/modules/cloud/webfaction/webfaction_site.py
lib/ansible/modules/network/cloudengine/ce_file_copy.py
lib/ansible/modules/network/ios/ios_static_route.py
lib/ansible/modules/network/lenovo/cnos_backup.py
lib/ansible/modules/network/lenovo/cnos_bgp.py
Expand Down

0 comments on commit 4713d9e

Please sign in to comment.