Skip to content

Commit

Permalink
pending changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shrsr committed Jul 18, 2020
1 parent 0442bd1 commit f3f78f2
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 181 deletions.
23 changes: 10 additions & 13 deletions plugins/modules/mso_backup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

Expand All @@ -20,20 +19,21 @@
- Manage backups on Cisco ACI Multi-Site.
author:
- Shreyas Srish (@shrsr)
version_added: '2.8'
options:
location_type:
description:
- The location of the backup to be stored
type: str
choices: [ local, remote]
default: local
backup:
description:
- The name given to the backup
type: str
aliases: [ name ]
description:
description:
- Brief information about backup
- Brief information about the backup
type: str
state:
description:
Expand Down Expand Up @@ -87,13 +87,13 @@
'''

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, issubset
from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec


def main():
argument_spec = mso_argument_spec()
argument_spec.update(
location_type=dict(type='str'),
location_type=dict(type='str', default='local', choices=['local', 'remote']),
description=dict(type='str'),
backup=dict(type='str', aliases=['name']),
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
Expand All @@ -113,23 +113,20 @@ def main():

backup_id = None
path = 'backups'
count_backups = 0
mso.existing = mso.query_objs('backups')
if backup:
if mso.existing:
data = mso.existing
mso.existing = []
for index_of_name in range(0, len(data)):
backup_id = data[index_of_name]['id']
if (str(backup) + '_' + backup_id == data[index_of_name]['metadata']['name']):
for backup_info in data:
backup_id = backup_info.get('id')
if backup_info.get('metadata')['name'] == '{0}_{1}'.format(backup, backup_id):
path = 'backups/{id}'.format(id=backup_id)
count_backups += 1
mso.existing.append(data[index_of_name])
if count_backups < 1:
mso.existing.append(backup_info)
if len(mso.existing) < 1:
mso.existing = mso.get_obj(path, name=backup)

if state == 'query':
pass
mso.exit_json()

if state == 'absent':
Expand Down
Loading

0 comments on commit f3f78f2

Please sign in to comment.