Example #1
0
 def update(self, request, id, tenant_id, body=None):
     LOG.info("Updating IP block %(id)s for %(tenant_id)s" % locals())
     ip_block = self._find_block(id=id, tenant_id=tenant_id)
     params = self._extract_required_params(body, 'ip_block')
     ip_block.update(**utils.exclude(params, 'cidr', 'type'))
     LOG.debug("Updated IP block %(id)s parameters: %(params)s" % locals())
     return wsgi.Result(dict(ip_block=ip_block.data()), 200)
Example #2
0
 def update(self, request, id, tenant_id, body=None):
     LOG.info("Updating IP block %(id)s for %(tenant_id)s" % locals())
     ip_block = self._find_block(id=id, tenant_id=tenant_id)
     params = self._extract_required_params(body, 'ip_block')
     ip_block.update(**utils.exclude(params, 'cidr', 'type'))
     LOG.debug("Updated IP block %(id)s parameters: %(params)s" % locals())
     return wsgi.Result(dict(ip_block=ip_block.data()), 200)
Example #3
0
 def _extract_required_params(self, params, model_name):
     params = params or {}
     model_params = params.get(model_name, {})
     return utils.stringify_keys(utils.exclude(model_params,
                                               *self.exclude_attr))
Example #4
0
 def update(self, request, policy_id, id, tenant_id, body=None):
     policy = models.Policy.find_by(id=policy_id, tenant_id=tenant_id)
     ip_octet = policy.find_ip_octet(id)
     params = self._extract_required_params(body, 'ip_octet')
     ip_octet.update(**utils.exclude(params, 'policy_id'))
     return dict(ip_octet=ip_octet.data())
Example #5
0
 def update(self, **values):
     attrs = utils.exclude(values, *self._auto_generated_attrs)
     self.merge_attributes(attrs)
     result = self.save()
     self._notify_fields("update")
     return result
Example #6
0
 def update(self, **values):
     attrs = utils.exclude(values, *self._auto_generated_attrs)
     self.merge_attributes(attrs)
     result = self.save()
     self._notify_fields("update")
     return result
Example #7
0
 def _extract_required_params(self, params, model_name):
     params = params or {}
     model_params = params.get(model_name, {})
     return utils.stringify_keys(
         utils.exclude(model_params, *self.exclude_attr))
Example #8
0
 def update(self, request, policy_id, id, tenant_id, body=None):
     policy = models.Policy.find_by(id=policy_id, tenant_id=tenant_id)
     ip_octet = policy.find_ip_octet(id)
     params = self._extract_required_params(body, 'ip_octet')
     ip_octet.update(**utils.exclude(params, 'policy_id'))
     return dict(ip_octet=ip_octet.data())
Example #9
0
 def test_returns_none_if_dict_is_none(self):
     self.assertIsNone(utils.exclude(None, 'key1'))
Example #10
0
 def test_excludes_given_keys(self):
     dictionary = {'key1': "value1", 'key2': "value2", 'key3': "value3"}
     self.assertEqual(utils.exclude(dictionary, 'key2', 'key3'),
                      {'key1': "value1"})
Example #11
0
 def test_excludes_ignore_non_exsistant_keys(self):
     dictionary = {'key1': "value1", 'key2': "value2", 'key3': "value3"}
     self.assertEqual(utils.exclude(dictionary, 'key2', 'nonexistant'),
                      {'key1': "value1", 'key3': "value3"})
Example #12
0
 def update(self, request, id, tenant_id, body=None):
     ip_block = self._find_block(id=id, tenant_id=tenant_id)
     params = self._extract_required_params(body, 'ip_block')
     ip_block.update(**utils.exclude(params, 'cidr', 'type'))
     return wsgi.Result(dict(ip_block=ip_block.data()), 200)
Example #13
0
 def update(self, request, policy_id, id, tenant_id, body=None):
     policy = models.Policy.find_by(id=policy_id, tenant_id=tenant_id)
     ip_range = policy.find_ip_range(id)
     params = self._extract_required_params(body, "ip_range")
     ip_range.update(**utils.exclude(params, "policy_id"))
     return dict(ip_range=ip_range.data())
Example #14
0
 def test_returns_none_if_dict_is_none(self):
     self.assertIsNone(utils.exclude(None, 'key1'))
Example #15
0
 def test_excludes_ignore_non_exsistant_keys(self):
     dictionary = {'key1': "value1", 'key2': "value2", 'key3': "value3"}
     self.assertEqual(utils.exclude(dictionary, 'key2', 'nonexistant'), {
         'key1': "value1",
         'key3': "value3"
     })
Example #16
0
 def test_excludes_given_keys(self):
     dictionary = {'key1': "value1", 'key2': "value2", 'key3': "value3"}
     self.assertEqual(utils.exclude(dictionary, 'key2', 'key3'),
                      {'key1': "value1"})