mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix lint error and add try except
This commit is contained in:
parent
d96981639b
commit
dd670bd18f
1 changed files with 7 additions and 2 deletions
|
@ -132,6 +132,7 @@ from salt.exceptions import SaltCloudSystemExit
|
|||
|
||||
# Import salt cloud libs
|
||||
import salt.config as config
|
||||
from salt.ext.six.moves import range
|
||||
|
||||
# Attempt to import pyVim and pyVmomi libs
|
||||
try:
|
||||
|
@ -2193,8 +2194,12 @@ def create(vm_):
|
|||
num = int(vm_['snapshot']) - 1
|
||||
snapshot = object_ref.rootSnapshot[0]
|
||||
# Drill down to the correct snapshot number
|
||||
for i in range(num):
|
||||
snapshot = snapshot.childSnapshot[0]
|
||||
for _ in range(num):
|
||||
try:
|
||||
snapshot = snapshot.childSnapshot[0]
|
||||
except IndexError:
|
||||
raise SaltCloudSystemExit('Specified snapshot'
|
||||
' does not exist.')
|
||||
else:
|
||||
clone_type = None
|
||||
object_ref = None
|
||||
|
|
Loading…
Add table
Reference in a new issue