fixing issue from mitaka to newton and then to ocata upgrade
Change-Id: I571009d3bf4d0d6db1c29ae7e5fe2d3703957f73
diff --git a/_states/novang.py b/_states/novang.py
index cf52512..224757c 100644
--- a/_states/novang.py
+++ b/_states/novang.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
'''
-Nova state that ensures that defined flavor is present
+Custom Nova state
'''
import logging
import collections
@@ -12,7 +12,7 @@
'''
Only load if the nova module is in __salt__
'''
- return 'novang' if 'novang.flavor_list' in __salt__ else False
+ return 'novang'
def flavor_present(name, flavor_id=0, ram=0, disk=0, vcpus=1, profile=None):
@@ -35,6 +35,28 @@
return ret
+def map_instances(name='cell1'):
+ '''
+ Ensures that the nova instances are mapped to cell
+ '''
+ ret = {'name': name,
+ 'changes': {},
+ 'result': False,
+ 'comment': 'Cell "{0}" does not exists'.format(name)}
+ cell_uuid = __salt__['cmd.shell']('nova-manage cell_v2 list_cells 2>&- | grep ' + name + ' | tr -d \"\n\" | awk \'{print $4}\'')
+ if not cell_uuid:
+ try:
+ __salt__['cmd.shell']('nova-manage cell_v2 map_instances --cell_uuid ' + cell_uuid)
+ ret['result'] = True
+ ret['comment'] = 'Instances were mapped to cell named {0}'.format(name)
+ ret['changes']['Instances'] = 'Mapped to cell named {0}'.format(name)
+ except:
+ ret['result'] = False
+ ret['comment'] = 'Error while mapping instances to cell named {0}'.format(name)
+ ret['changes']['Instances'] = 'Failed to map to cell named {0}'.format(name)
+ return ret
+
+
def quota_present(tenant_name, profile, name=None, **kwargs):
'''
Ensures that the nova quota exists