Beispiel #1
0
    def _lb_reload(self, exclude=frozenset(), refresh_data=True):
        lb_names = self.properties.get(self.LOAD_BALANCER_NAMES) or []
        if lb_names:
            if refresh_data:
                self._outputs = None
            try:
                all_refids = self.get_output(self.OUTPUT_MEMBER_IDS)
            except (exception.NotFound,
                    exception.TemplateOutputError) as op_err:
                LOG.debug('Falling back to grouputils due to %s', op_err)
                if refresh_data:
                    self._nested = None
                instances = grouputils.get_members(self)
                all_refids = {i.name: i.FnGetRefId() for i in instances}
                names = [i.name for i in instances]
            else:
                group_data = self._group_data(refresh=refresh_data)
                names = group_data.member_names(include_failed=False)

            id_list = [
                all_refids[n] for n in names
                if n not in exclude and n in all_refids
            ]
            lbs = [self.stack[name] for name in lb_names]
            lbutils.reconfigure_loadbalancers(lbs, id_list)
Beispiel #2
0
    def test_reload_aws_lb(self):
        id_list = ['ID1', 'ID2', 'ID3']

        lb1 = self.stack['aws_lb_1']
        lb2 = self.stack['aws_lb_2']
        lb1.action = mock.Mock(return_value=lb1.CREATE)
        lb2.action = mock.Mock(return_value=lb2.CREATE)
        lb1.handle_update = mock.Mock()
        lb2.handle_update = mock.Mock()
        prop_diff = {'Instances': id_list}

        lbutils.reconfigure_loadbalancers([lb1, lb2], id_list)

        # For verification's purpose, we just check the prop_diff
        lb1.handle_update.assert_called_with(mock.ANY, mock.ANY, prop_diff)
        lb2.handle_update.assert_called_with(mock.ANY, mock.ANY, prop_diff)
Beispiel #3
0
    def test_reload_aws_lb(self):
        id_list = ['ID1', 'ID2', 'ID3']

        lb1 = self.stack['aws_lb_1']
        lb2 = self.stack['aws_lb_2']
        lb1.action = mock.Mock(return_value=lb1.CREATE)
        lb2.action = mock.Mock(return_value=lb2.CREATE)
        lb1.handle_update = mock.Mock()
        lb2.handle_update = mock.Mock()
        prop_diff = {'Instances': id_list}

        lbutils.reconfigure_loadbalancers([lb1, lb2], id_list)

        # For verification's purpose, we just check the prop_diff
        lb1.handle_update.assert_called_with(mock.ANY, mock.ANY,
                                             prop_diff)
        lb2.handle_update.assert_called_with(mock.ANY, mock.ANY,
                                             prop_diff)
Beispiel #4
0
    def _lb_reload(self, exclude=frozenset(), refresh_data=True):
        lb_names = self.properties.get(self.LOAD_BALANCER_NAMES) or []
        if lb_names:
            if refresh_data:
                self._outputs = None
            try:
                all_refids = self.get_output(self.OUTPUT_MEMBER_IDS)
            except (exception.NotFound,
                    exception.TemplateOutputError) as op_err:
                LOG.debug('Falling back to grouputils due to %s', op_err)
                if refresh_data:
                    self._nested = None
                instances = grouputils.get_members(self)
                all_refids = {i.name: i.FnGetRefId() for i in instances}
                names = [i.name for i in instances]
            else:
                group_data = self._group_data(refresh=refresh_data)
                names = group_data.member_names(include_failed=False)

            id_list = [all_refids[n] for n in names
                       if n not in exclude and n in all_refids]
            lbs = [self.stack[name] for name in lb_names]
            lbutils.reconfigure_loadbalancers(lbs, id_list)