proxmox_template | deleted state=list and changed default timeout to 30
This commit is contained in:
parent
af7463e46e
commit
51f9225754
1 changed files with 5 additions and 18 deletions
|
@ -19,7 +19,7 @@ DOCUMENTATION = '''
|
||||||
module: proxmox_template
|
module: proxmox_template
|
||||||
short_description: management of OS templates in Proxmox VE cluster
|
short_description: management of OS templates in Proxmox VE cluster
|
||||||
description:
|
description:
|
||||||
- allows you to list/upload/delete templates in Proxmox VE cluster
|
- allows you to upload/delete templates in Proxmox VE cluster
|
||||||
version_added: "2.0"
|
version_added: "2.0"
|
||||||
options:
|
options:
|
||||||
api_host:
|
api_host:
|
||||||
|
@ -76,7 +76,7 @@ options:
|
||||||
timeout:
|
timeout:
|
||||||
description:
|
description:
|
||||||
- timeout for operations
|
- timeout for operations
|
||||||
default: 300
|
default: 30
|
||||||
required: false
|
required: false
|
||||||
type: integer
|
type: integer
|
||||||
force:
|
force:
|
||||||
|
@ -88,7 +88,7 @@ options:
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Indicate desired state of the template
|
- Indicate desired state of the template
|
||||||
choices: ['present', 'absent', 'list']
|
choices: ['present', 'absent']
|
||||||
default: present
|
default: present
|
||||||
notes:
|
notes:
|
||||||
- Requires proxmoxer and requests modules on host. This modules can be installed with pip.
|
- Requires proxmoxer and requests modules on host. This modules can be installed with pip.
|
||||||
|
@ -108,9 +108,6 @@ EXAMPLES = '''
|
||||||
|
|
||||||
# Delete template with minimal options
|
# Delete template with minimal options
|
||||||
- proxmox_template: node='uk-mc02' api_user='root@pam' api_password='1q2w3e' api_host='node1' template='ubuntu-14.04-x86_64.tar.gz' state=absent
|
- proxmox_template: node='uk-mc02' api_user='root@pam' api_password='1q2w3e' api_host='node1' template='ubuntu-14.04-x86_64.tar.gz' state=absent
|
||||||
|
|
||||||
# List content of storage(it returns list of dicts)
|
|
||||||
- proxmox_template: node='uk-mc02' api_user='root@pam' api_password='1q2w3e' api_host='node1' storage='local' state=list
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -126,9 +123,6 @@ def get_template(proxmox, node, storage, content_type, template):
|
||||||
return [ True for tmpl in proxmox.nodes(node).storage(storage).content.get()
|
return [ True for tmpl in proxmox.nodes(node).storage(storage).content.get()
|
||||||
if tmpl['volid'] == '%s:%s/%s' % (storage, content_type, template) ]
|
if tmpl['volid'] == '%s:%s/%s' % (storage, content_type, template) ]
|
||||||
|
|
||||||
def get_content(proxmox, node, storage):
|
|
||||||
return proxmox.nodes(node).storage(storage).content.get()
|
|
||||||
|
|
||||||
def upload_template(module, proxmox, api_host, node, storage, content_type, realpath, timeout):
|
def upload_template(module, proxmox, api_host, node, storage, content_type, realpath, timeout):
|
||||||
taskid = proxmox.nodes(node).storage(storage).upload.post(content=content_type, filename=open(realpath))
|
taskid = proxmox.nodes(node).storage(storage).upload.post(content=content_type, filename=open(realpath))
|
||||||
while timeout:
|
while timeout:
|
||||||
|
@ -168,9 +162,9 @@ def main():
|
||||||
template = dict(),
|
template = dict(),
|
||||||
content_type = dict(default='vztmpl', choices=['vztmpl','iso']),
|
content_type = dict(default='vztmpl', choices=['vztmpl','iso']),
|
||||||
storage = dict(default='local'),
|
storage = dict(default='local'),
|
||||||
timeout = dict(type='int', default=300),
|
timeout = dict(type='int', default=30),
|
||||||
force = dict(type='bool', choices=BOOLEANS, default='no'),
|
force = dict(type='bool', choices=BOOLEANS, default='no'),
|
||||||
state = dict(default='present', choices=['present', 'absent', 'list']),
|
state = dict(default='present', choices=['present', 'absent']),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -233,13 +227,6 @@ def main():
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module.fail_json(msg="deleting of template %s failed with exception: %s" % ( template, e ))
|
module.fail_json(msg="deleting of template %s failed with exception: %s" % ( template, e ))
|
||||||
|
|
||||||
elif state == 'list':
|
|
||||||
try:
|
|
||||||
|
|
||||||
module.exit_json(changed=False, templates=get_content(proxmox, node, storage))
|
|
||||||
except Exception, e:
|
|
||||||
module.fail_json(msg="listing of templates %s failed with exception: %s" % ( template, e ))
|
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue