diff --git a/app/models.py b/app/models.py index 2dce67c34fea0432be66f23b8531238e9b3f2316..2e52834c2b8aaba957cec6c66d1fc5fbca53ea7c 100644 --- a/app/models.py +++ b/app/models.py @@ -645,6 +645,10 @@ class Interface(CreatedMixin, db.Model): 'domain': str(self.network.domain), 'tags': [str(tag) for tag in self.tags], }) + if self.host: + d['machine_type'] = str(self.host.machine_type) + else: + d['machine_type'] = None return d diff --git a/tests/functional/test_api.py b/tests/functional/test_api.py index 50646c9a249a0e1c91651bcc178999ad9188d601..6ee8513c211ea65f5a8f7609ed8ff48ea818401c 100644 --- a/tests/functional/test_api.py +++ b/tests/functional/test_api.py @@ -642,7 +642,7 @@ def test_create_interface(client, network_factory, user_token): response = post(client, f'{API_URL}/network/interfaces', data=data, token=user_token) assert response.status_code == 201 assert {'id', 'network', 'ip', 'name', 'mac', 'domain', - 'host', 'cnames', 'tags', 'created_at', + 'host', 'machine_type', 'cnames', 'tags', 'created_at', 'updated_at', 'user'} == set(response.json.keys()) assert response.json['network'] == network.vlan_name assert response.json['ip'] == '192.168.1.20'