Commit a2f4cde8 by Karsa Zoltán István

sshport seri

parent 0bc65ba4
...@@ -79,6 +79,8 @@ class InstanceSerializer(serializers.ModelSerializer): ...@@ -79,6 +79,8 @@ class InstanceSerializer(serializers.ModelSerializer):
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') macaddr = serializers.SerializerMethodField('get_mac')
sshportipv4 = serializers.SerializerMethodField('get_sshportipv4')
hostipv4 = serializers.SerializerMethodField('get_hostipv4')
#interfaces = serializers.SerializerMethodField('get_interfaces') #interfaces = serializers.SerializerMethodField('get_interfaces')
def get_ipv4(self, i): def get_ipv4(self, i):
...@@ -96,12 +98,18 @@ class InstanceSerializer(serializers.ModelSerializer): ...@@ -96,12 +98,18 @@ class InstanceSerializer(serializers.ModelSerializer):
def get_interfaces(self, i): def get_interfaces(self, i):
return i.interface_set.all() return i.interface_set.all()
def get_sshportipv4(self, i):
return i.get_connect_port(use_ipv6=False)
def get_hostipv4(self, i):
return i.get_connect_host(use_ipv6=False)
class Meta: class Meta:
model = Instance model = Instance
fields = ['id', 'name', 'description', 'status', 'owner', 'access_method', 'boot_menu', 'pw', 'is_base', 'macaddr', 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', 'sshportipv4', 'hostipv4']
extra_kwargs = { extra_kwargs = {
'disks': {'required': False, 'allow_empty': True,}, 'disks': {'required': False, 'allow_empty': True,},
'req_traits': {'required': False, 'allow_empty': True,}, 'req_traits': {'required': False, 'allow_empty': True,},
...@@ -111,6 +119,8 @@ class InstanceSerializer(serializers.ModelSerializer): ...@@ -111,6 +119,8 @@ class InstanceSerializer(serializers.ModelSerializer):
'ci_user_data': {'required': False, }, 'ci_user_data': {'required': False, },
'ci_meta_data': {'required': False, }, 'ci_meta_data': {'required': False, },
'raw_data': {'required': False, }, 'raw_data': {'required': False, },
'sshportipv4': {'required': False, },
'hostipv4': {'required': False, },
} }
......
...@@ -111,8 +111,8 @@ network: ...@@ -111,8 +111,8 @@ network:
match: match:
macaddress: {{ net.mac }} macaddress: {{ net.mac }}
addresses: addresses:
- {{ net.ipv4 }}/24 - {{ net.ipv4 }}/{{ net.mask4 }}
gateway4: ipv4 gateway4: {{ net.gateway4 }}
nameservers: nameservers:
addresses: addresses:
- 8.8.8.8 - 8.8.8.8
......
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