Commit ee30f76a by Karsa Zoltán István

instance setup network config

parent cc9b42b0
...@@ -50,7 +50,7 @@ class InstanceTemplateSerializer(serializers.ModelSerializer): ...@@ -50,7 +50,7 @@ class InstanceTemplateSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = InstanceTemplate model = InstanceTemplate
fields = [ 'id', 'name', 'description', 'parent', 'owner', 'access_method', 'boot_menu', fields = [ 'id', 'name', 'description', 'parent', 'owner', 'access_method', 'boot_menu',
'lease', 'raw_data', 'cloud_init', 'ci_meta_data', 'ci_user_data', 'system', 'lease', 'raw_data', 'cloud_init', 'ci_network_config', 'ci_meta_data', 'ci_user_data', 'system',
'has_agent', 'num_cores', 'ram_size', 'max_ram_size', 'arch', 'priority', 'disks'] 'has_agent', 'num_cores', 'ram_size', 'max_ram_size', 'arch', 'priority', 'disks']
...@@ -71,6 +71,7 @@ class InstanceSerializer(serializers.ModelSerializer): ...@@ -71,6 +71,7 @@ class InstanceSerializer(serializers.ModelSerializer):
ipv4addr = serializers.SerializerMethodField('get_ipv4') ipv4addr = serializers.SerializerMethodField('get_ipv4')
ipv6addr = serializers.SerializerMethodField('get_ipv6') ipv6addr = serializers.SerializerMethodField('get_ipv6')
vlans = serializers.SerializerMethodField('get_vlans') vlans = serializers.SerializerMethodField('get_vlans')
macaddr = serializers.SerializerMethodField('get_mac')
#interfaces = serializers.SerializerMethodField('get_interfaces') #interfaces = serializers.SerializerMethodField('get_interfaces')
def get_ipv4(self, i): def get_ipv4(self, i):
...@@ -79,6 +80,9 @@ class InstanceSerializer(serializers.ModelSerializer): ...@@ -79,6 +80,9 @@ class InstanceSerializer(serializers.ModelSerializer):
def get_ipv6(self, i): def get_ipv6(self, i):
return str(i.ipv6) return str(i.ipv6)
def get_mac(self, i):
return str(i.mac).lower()
def get_vlans(self, i): def get_vlans(self, i):
return list(net.vlan.id for net in i.interface_set.all() if net.host) return list(net.vlan.id for net in i.interface_set.all() if net.host)
...@@ -87,7 +91,7 @@ class InstanceSerializer(serializers.ModelSerializer): ...@@ -87,7 +91,7 @@ class InstanceSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Instance model = Instance
fields = ['id', 'name', 'description', 'status', 'owner', 'access_method', 'boot_menu', 'pw', 'is_base', fields = ['id', 'name', 'description', 'status', 'owner', 'access_method', 'boot_menu', 'pw', 'is_base', 'macaddr',
'lease', 'raw_data', 'cloud_init', 'ci_meta_data', 'ci_user_data', 'ci_network_config', 'system', 'req_traits', 'interface_set', 'lease', 'raw_data', 'cloud_init', 'ci_meta_data', 'ci_user_data', 'ci_network_config', 'system', 'req_traits', 'interface_set',
'has_agent', 'num_cores', 'ram_size', 'max_ram_size', 'arch', 'priority', 'disks', 'node', 'ipv4addr', 'ipv6addr', 'vlans', 'has_agent', 'num_cores', 'ram_size', 'max_ram_size', 'arch', 'priority', 'disks', 'node', 'ipv4addr', 'ipv6addr', 'vlans',
'hookurl'] 'hookurl']
......
...@@ -317,11 +317,13 @@ class NetTemplate: ...@@ -317,11 +317,13 @@ class NetTemplate:
self.ipv4 = str(net.host.ipv4) self.ipv4 = str(net.host.ipv4)
self.ipv6 = str(net.host.ipv6) self.ipv6 = str(net.host.ipv6)
self.name = str(net.vlan.name) self.name = str(net.vlan.name)
self.mac = str(net.host.mac)
def __init__(self, instance): def __init__(self, instance):
self.vlans = list(NetTemplate.Host(net) for net in instance.interface_set.all() if net.host) self.vlans = list(NetTemplate.Host(net) for net in instance.interface_set.all() if net.host)
self.ipv4 = str(instance.ipv4) self.ipv4 = str(instance.ipv4)
self.ipv6 = str(instance.ipv6) self.ipv6 = str(instance.ipv6)
self.mac = str(instance.mac).lower()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment