20
20
description:
21
21
- Manage DCS Instance-Backups on Open Telekom Cloud
22
22
options:
23
- instance_id :
23
+ instance :
24
24
description:
25
25
- Specifies the name or ID of the instance
26
26
type: str
78
78
EXAMPLES = '''
79
79
# Create a Backup
80
80
- opentelekomcloud.cloud.dcs_instance_backup:
81
- instance_id : 12345678-20fb-441b-a0cd-46369a9f7db0
81
+ instance : 12345678-20fb-441b-a0cd-46369a9f7db0
82
82
description: "This is a test"
83
83
84
84
# Restore a backup
85
85
- opentelekomcloud.cloud.dcs_instance_backup:
86
- instance_id : 12345678-20fb-441b-a0cd-46369a9f7db0
86
+ instance : 12345678-20fb-441b-a0cd-46369a9f7db0
87
87
backup_id: 12345678-f021-417f-b019-dc02182926a9
88
88
89
89
# Delete a backup
90
90
- opentelekomcloud.cloud.dcs_instance_backup:
91
- instance_id : 12345678-20fb-441b-a0cd-46369a9f7db0
91
+ instance : 12345678-20fb-441b-a0cd-46369a9f7db0
92
92
backup_id: 12345678-f021-417f-b019-dc02182926a9
93
93
state: absent
94
94
'''
98
98
99
99
class DcsInstanceModule (OTCModule ):
100
100
argument_spec = dict (
101
- instance_id = dict (required = True ),
101
+ instance = dict (required = True ),
102
102
description = dict (required = False ),
103
103
backup_id = dict (required = False ),
104
104
state = dict (type = 'str' , choices = ['present' , 'absent' ], default = 'present' )
105
105
)
106
106
module_kwargs = dict (
107
- supports_check_mode = True
107
+ supports_check_mode = True ,
108
+ required_if = [
109
+ ('state' , 'absent' ,
110
+ ['backup_id' ])
111
+ ]
108
112
)
109
113
110
114
def run (self ):
111
115
changed = False
112
116
attrs = {}
113
117
114
118
instance = self .conn .dcs .find_instance (
115
- name_or_id = self .params ['instance_id ' ],
119
+ name_or_id = self .params ['instance ' ],
116
120
ignore_missing = True
117
121
)
118
122
if instance :
@@ -135,22 +139,15 @@ def run(self):
135
139
self .exit_json (True )
136
140
137
141
elif self .params ['state' ] == 'absent' :
138
- if self .params ['backup_id' ]:
139
- if not self .ansible .check_mode :
140
- dcs_instance = self .conn .dcs .delete_instance_backup (self .params ['backup_id' ], instance .id )
141
- self .exit (changed = True , dcs_instance = dcs_instance )
142
- self .exit_json (True )
143
- else :
144
- self .exit (
145
- changed = False ,
146
- message = ('No backup_id %s provided but required for deletion!' ),
147
- failed = True
148
- )
142
+ if not self .ansible .check_mode :
143
+ dcs_instance = self .conn .dcs .delete_instance_backup (self .params ['backup_id' ], instance .id )
144
+ self .exit (changed = True , dcs_instance = dcs_instance )
145
+ self .exit_json (True )
149
146
150
147
else :
151
148
self .exit (
152
149
changed = False ,
153
- message = ('No Instance with name or id %s found!' , self .params ['id ' ]),
150
+ message = ('No Instance with name or id %s found!' , self .params ['instance ' ]),
154
151
failed = True
155
152
)
156
153
0 commit comments