pool.spawn_n(self.delete_blocking)
def get_outputs(self):
- self.resolve_static_refs(self.outputs)
- self.resolve_find_in_map(self.outputs)
+
+ for r in self.resources:
+ self.resources[r].reload()
+
self.resolve_attributes(self.outputs)
self.resolve_joins(self.outputs)
from novaclient.v1_1 import client
from novaclient.exceptions import BadRequest
+from novaclient.exceptions import NotFound
from heat.common import exception
from heat.db import api as db_api
str(self.id))
def reload(self):
- pass
+ '''
+ The point of this function is to get the Resource instance back
+ into the state that it was just after it was created. So we
+ need to retrieve things like ipaddresses and other variables
+ used by FnGetAtt and FnGetRefId. classes inheriting from Resource
+ might need to override this, but still call it.
+ This is currently used by stack.get_outputs()
+ '''
+ print 'reloading %s name:%s' % (self.t['Type'], self.name)
+ self.stack.resolve_attributes(self.t)
def FnGetRefId(self):
'''
self.instance_id_set(ips.id)
self.state_set(self.CREATE_COMPLETE)
+ def reload(self):
+ '''
+ get the ipaddress here
+ '''
+ if self.instance_id != None:
+ ips = self.nova().floating_ips.get(self.instance_id)
+ self.ipaddress = ips.ip
+
+ Resource.reload(self)
+
def delete(self):
"""De-allocate a floating IP."""
if self.state == self.DELETE_IN_PROGRESS or \
else:
self.state_set(self.CREATE_FAILED)
+ def reload(self):
+ '''
+ re-read the server's ipaddress so FnGetAtt works.
+ '''
+ print 'reloading Instance %s' % self.instance_id
+ try:
+ server = self.nova().servers.get(self.instance_id)
+ for n in server.networks:
+ self.ipaddress = server.networks[n][0]
+ except NotFound:
+ self.ipaddress = '0.0.0.0'
+
+ Resource.reload(self)
+
def delete(self):
if self.state == self.DELETE_IN_PROGRESS or \
self.state == self.DELETE_COMPLETE: