示例#1
0
 def handle_delete(self):
     client = self.neutron()
     for member in self.properties['members']:
         member_id = db_api.resource_data_get(self, member)
         try:
             client.delete_member(member_id)
         except NeutronClientException as ex:
             if ex.status_code != 404:
                 raise ex
         db_api.resource_data_delete(self, member)
示例#2
0
    def test_resource_data_delete(self):
        create_resource_data(self.ctx, self.resource)
        res_data = db_api.resource_data_get_by_key(self.ctx, self.resource.id,
                                                   'test_resource_key')
        self.assertIsNotNone(res_data)
        self.assertEqual('test_value', res_data.value)

        db_api.resource_data_delete(self.resource, 'test_resource_key')
        self.assertRaises(exception.NotFound, db_api.resource_data_get_by_key,
                          self.ctx, self.resource.id, 'test_resource_key')
        self.assertIsNotNone(res_data)
示例#3
0
 def test_resource_data_delete(self):
     stack = self._setup_test_stack('stack', UUID1)[1]
     self._mock_create(self.m)
     self.m.ReplayAll()
     stack.create()
     rsrc = stack['WebServer']
     db_api.resource_data_set(rsrc, 'test', 'test_data')
     self.assertEqual('test_data', db_api.resource_data_get(rsrc, 'test'))
     db_api.resource_data_delete(rsrc, 'test')
     self.assertRaises(exception.NotFound,
                       db_api.resource_data_get, rsrc, 'test')
示例#4
0
 def handle_update(self, json_snippet, tmpl_diff, prop_diff):
     if 'members' in prop_diff:
         members = set(prop_diff['members'])
         old_members = set(self.t['Properties'].get('members', []))
         client = self.neutron()
         for member in old_members - members:
             member_id = db_api.resource_data_get(self, member)
             try:
                 client.delete_member(member_id)
             except NeutronClientException as ex:
                 if ex.status_code != 404:
                     raise ex
             db_api.resource_data_delete(self, member)
         pool = self.properties['pool_id']
         nova_client = self.nova()
         protocol_port = self.properties['protocol_port']
         for member in members - old_members:
             address = nova_utils.server_to_ipaddress(nova_client, member)
             lb_member = client.create_member({
                 'member': {
                     'pool_id': pool,
                     'address': address,
                     'protocol_port': protocol_port}})['member']
             db_api.resource_data_set(self, member, lb_member['id'])
示例#5
0
 def delete(cls, resource, key):
     db_api.resource_data_delete(resource.context, resource.id, key)