Revision 9cec0c17
b/snf-cyclades-app/conf/20-snf-cyclades-app-api.conf | ||
---|---|---|
126 | 126 |
#CYCLADES_ASTAKOSCLIENT_POOLSIZE = 50 |
127 | 127 |
# |
128 | 128 |
## Template to use to build the FQDN of VMs. The setting will be formated with |
129 |
## the id of the VM. If set to 'None' the first public IPv4 or IPv6 address |
|
130 |
## of the VM will be used. |
|
129 |
## the id of the VM. |
|
131 | 130 |
#CYCLADES_SERVERS_FQDN = 'snf-%(id)s.vm.example.synnefo.org' |
132 | 131 |
# |
133 | 132 |
## Description of applied port forwarding rules (DNAT) for Cyclades VMs. This |
b/snf-cyclades-app/synnefo/api/servers.py | ||
---|---|---|
219 | 219 |
|
220 | 220 |
|
221 | 221 |
def get_server_fqdn(vm, vm_nics): |
222 |
public_ip = get_server_public_ip(vm_nics) |
|
223 |
if public_ip is None: |
|
224 |
return "" |
|
225 |
|
|
226 | 222 |
fqdn_setting = settings.CYCLADES_SERVERS_FQDN |
227 | 223 |
if fqdn_setting is None: |
228 |
return public_ip.address
|
|
224 |
return None
|
|
229 | 225 |
elif isinstance(fqdn_setting, basestring): |
230 | 226 |
return fqdn_setting % {"id": vm.id} |
231 | 227 |
else: |
b/snf-cyclades-app/synnefo/api/tests/servers.py | ||
---|---|---|
161 | 161 |
|
162 | 162 |
def test_server_fqdn(self): |
163 | 163 |
vm = mfactory.VirtualMachineFactory() |
164 |
# test no public ip
|
|
164 |
# Setting set to None
|
|
165 | 165 |
with override_settings(settings, |
166 |
CYCLADES_SERVERS_FQDN="vm.example.org"):
|
|
166 |
CYCLADES_SERVERS_FQDN=None):
|
|
167 | 167 |
response = self.myget("servers/%d" % vm.id, vm.userid) |
168 | 168 |
server = json.loads(response.content)['server'] |
169 |
self.assertEqual(server["SNF:fqdn"], "")
|
|
170 |
mfactory.IPv4AddressFactory(nic__machine=vm, network__public=True)
|
|
169 |
self.assertEqual(server["SNF:fqdn"], None)
|
|
170 |
# Unformated setting
|
|
171 | 171 |
with override_settings(settings, |
172 | 172 |
CYCLADES_SERVERS_FQDN="vm.example.org"): |
173 | 173 |
response = self.myget("servers/%d" % vm.id, vm.userid) |
174 | 174 |
server = json.loads(response.content)['server'] |
175 | 175 |
self.assertEqual(server["SNF:fqdn"], "vm.example.org") |
176 |
# Formatted settings |
|
176 | 177 |
with override_settings(settings, CYCLADES_SERVERS_FQDN= |
177 | 178 |
"snf-%(id)s.vm.example.org"): |
178 | 179 |
response = self.myget("servers/%d" % vm.id, vm.userid) |
... | ... | |
187 | 188 |
self.assertEqual(server["SNF:fqdn"], "snf-%d.vm-%d.example.org" % |
188 | 189 |
(vm.id, vm.id)) |
189 | 190 |
|
190 |
vm = mfactory.VirtualMachineFactory() |
|
191 |
# No setting, no NICs |
|
192 |
with override_settings(settings, |
|
193 |
CYCLADES_SERVERS_FQDN=None): |
|
194 |
response = self.myget("servers/%d" % vm.id, vm.userid) |
|
195 |
server = json.loads(response.content)['server'] |
|
196 |
self.assertEqual(server["SNF:fqdn"], "") |
|
197 |
|
|
198 |
# IPv6 NIC |
|
199 |
ipv6_address = mfactory.IPv6AddressFactory(nic__machine=vm, |
|
200 |
network__public=True) |
|
201 |
with override_settings(settings, |
|
202 |
CYCLADES_SERVERS_FQDN=None): |
|
203 |
response = self.myget("servers/%d" % vm.id, vm.userid) |
|
204 |
server = json.loads(response.content)['server'] |
|
205 |
self.assertEqual(server["SNF:fqdn"], ipv6_address.address) |
|
206 |
|
|
207 |
# IPv4 NIC |
|
208 |
ipv4_address = mfactory.IPv4AddressFactory(nic__machine=vm, |
|
209 |
network__public=True) |
|
210 |
with override_settings(settings, |
|
211 |
CYCLADES_SERVERS_FQDN=None): |
|
212 |
response = self.myget("servers/%d" % vm.id, vm.userid) |
|
213 |
server = json.loads(response.content)['server'] |
|
214 |
self.assertEqual(server["SNF:fqdn"], ipv4_address.address) |
|
215 |
|
|
216 | 191 |
def test_server_port_forwarding(self): |
217 | 192 |
vm = mfactory.VirtualMachineFactory() |
218 | 193 |
# test None if the server has no public IP |
b/snf-cyclades-app/synnefo/app_settings/default/api.py | ||
---|---|---|
123 | 123 |
CYCLADES_SERVICE_TOKEN = '' |
124 | 124 |
|
125 | 125 |
# Template to use to build the FQDN of VMs. The setting will be formated with |
126 |
# the id of the VM. If set to 'None' the first public IPv4 or IPv6 address |
|
127 |
# of the VM will be used. |
|
126 |
# the id of the VM. |
|
128 | 127 |
CYCLADES_SERVERS_FQDN = 'snf-%(id)s.vm.example.synnefo.org' |
129 | 128 |
|
130 | 129 |
# Description of applied port forwarding rules (DNAT) for Cyclades VMs. This |
Also available in: Unified diff