예제 #1
0
    def test_update_subport_change(self):
        t = template_format.parse(update_template)
        stack = utils.parse_stack(t)

        rsrc_defn = stack.t.resource_definitions(stack)['trunk']
        rsrc = trunk.Trunk('trunk', rsrc_defn, stack)
        scheduler.TaskRunner(rsrc.create)()
        self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)

        props = copy.deepcopy(t['resources']['trunk']['properties'])
        props['sub_ports'][1]['segmentation_id'] = 103
        rsrc_defn = rsrc_defn.freeze(properties=props)
        scheduler.TaskRunner(rsrc.update, rsrc_defn)()
        self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)

        self.update_trunk_mock.assert_not_called()
        self.trunk_remove_subports_mock.assert_called_once_with(
            'trunk id', {'sub_ports': [{
                'port_id': u'subport_2_id'
            }]})
        self.trunk_add_subports_mock.assert_called_once_with(
            'trunk id', {
                'sub_ports': [{
                    'port_id': 'subport_2_id',
                    'segmentation_id': 103,
                    'segmentation_type': 'vlan'
                }]
            })
예제 #2
0
    def test_update_basic_properties(self):
        t = template_format.parse(update_template)
        stack = utils.parse_stack(t)

        rsrc_defn = stack.t.resource_definitions(stack)['trunk']
        rsrc = trunk.Trunk('trunk', rsrc_defn, stack)
        scheduler.TaskRunner(rsrc.create)()
        self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)

        props = copy.deepcopy(t['resources']['trunk']['properties'])
        props['name'] = 'new trunk name'
        rsrc_defn = rsrc_defn.freeze(properties=props)
        scheduler.TaskRunner(rsrc.update, rsrc_defn)()
        self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)

        self.update_trunk_mock.assert_called_once_with(
            'trunk id', {'trunk': {
                'name': 'new trunk name'
            }})
        self.trunk_remove_subports_mock.assert_not_called()
        self.trunk_add_subports_mock.assert_not_called()