def send_resource(self, operation, object_type, data): """Send over a single resource from Neutron to OpenDaylight. Prepare a rest call and send a single resource to ODL NB """ # Convert underscores to dashes in the URL for ODL object_type_url = utils.neutronify(object_type) obj_id = data['id'] if operation == odl_const.ODL_DELETE: self.client.try_delete(object_type_url + '/' + obj_id) else: if operation == odl_const.ODL_CREATE: urlpath = object_type_url method = 'post' elif operation == odl_const.ODL_UPDATE: urlpath = object_type_url + '/' + obj_id method = 'put' policy_data = qos_utils.convert_rules_format(data) self.client.sendjson(method, urlpath, {odl_const.ODL_QOS_POLICY: policy_data})
def test_format_policy_rules(self): policy = qos_utils.convert_rules_format(FAKE_POLICY) self.assertIn("bandwidth_limit_rules", policy) self.assertIn("dscp_marking_rules", policy)
def _record_in_journal(self, context, op_const, qos_policy): data = qos_utils.convert_rules_format(qos_policy.to_dict()) journal.record(context, odl_const.ODL_QOS_POLICY, data['id'], op_const, data)
def _record_in_journal(self, context, op_const, qos_policy): data = qos_utils.convert_rules_format(qos_policy.to_dict()) journal.record(context, odl_const.ODL_QOS_POLICY, data['id'], op_const, data)
def delete_policy(self, context, qos_policy): data = qos_utils.convert_rules_format(qos_policy.to_dict()) journal.record(context, odl_const.ODL_QOS_POLICY, data['id'], odl_const.ODL_DELETE, data) self.journal.set_sync_event()