Merge "Don't manipulate LoadBalancer template in-place"

This commit is contained in:
Jenkins 2014-04-25 16:47:46 +00:00 committed by Gerrit Code Review
commit 39e06ae580
2 changed files with 7 additions and 7 deletions

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import copy
import functools import functools
import json import json
import math import math
@ -393,18 +394,16 @@ class InstanceGroup(stack_resource.StackResource):
if inst.FnGetRefId() not in exclude] if inst.FnGetRefId() not in exclude]
for lb in self.properties[self.LOAD_BALANCER_NAMES]: for lb in self.properties[self.LOAD_BALANCER_NAMES]:
lb_resource = self.stack[lb] lb_resource = self.stack[lb]
lb_defn = copy.deepcopy(lb_resource.t)
if 'Instances' in lb_resource.properties_schema: if 'Instances' in lb_resource.properties_schema:
lb_resource.json_snippet['Properties']['Instances'] = ( lb_defn['Properties']['Instances'] = id_list
id_list)
elif 'members' in lb_resource.properties_schema: elif 'members' in lb_resource.properties_schema:
lb_resource.json_snippet['Properties']['members'] = ( lb_defn['Properties']['members'] = id_list
id_list)
else: else:
raise exception.Error( raise exception.Error(
_("Unsupported resource '%s' in LoadBalancerNames") % _("Unsupported resource '%s' in LoadBalancerNames") %
(lb,)) (lb,))
resolved_snippet = self.stack.resolve_static_data( resolved_snippet = self.stack.resolve_static_data(lb_defn)
lb_resource.json_snippet)
scheduler.TaskRunner(lb_resource.update, resolved_snippet)() scheduler.TaskRunner(lb_resource.update, resolved_snippet)()
def FnGetRefId(self): def FnGetRefId(self):

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import copy
import re import re
import mock import mock
@ -190,7 +191,7 @@ class LoadBalancerTest(HeatTestCase):
s) s)
id_list.append(inst.FnGetRefId()) id_list.append(inst.FnGetRefId())
rsrc.handle_update(rsrc.json_snippet, {}, {'Instances': id_list}) rsrc.handle_update(copy.deepcopy(rsrc.t), {}, {'Instances': id_list})
self.assertEqual('4.5.6.7', rsrc.FnGetAtt('DNSName')) self.assertEqual('4.5.6.7', rsrc.FnGetAtt('DNSName'))
self.assertEqual('', rsrc.FnGetAtt('SourceSecurityGroup.GroupName')) self.assertEqual('', rsrc.FnGetAtt('SourceSecurityGroup.GroupName'))