Commit 0a84aa41 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Rename "public" to "SNF:ANY_PUBLIC"

Rename reserved work for automatically choosing a public network from
"public" to "SNF:ANY_PUBLIC". Also add the setting description to conf
files.
parent 83b300a1
...@@ -17,6 +17,13 @@ ...@@ -17,6 +17,13 @@
## Network Configuration ## Network Configuration
## ##
# #
## List of network IDs. All created instances will get a NIC connected to each
## network of this list. If the special network ID "SNF:ANY_PUBLIC" is used,
## Cyclades will automatically choose a public network and connect the server to
## it.
#DEFAULT_INSTANCE_NETWORKS=["SNF:ANY_PUBLIC"]
#
#
## Maximum allowed network size for private networks. ## Maximum allowed network size for private networks.
#MAX_CIDR_BLOCK = 22 #MAX_CIDR_BLOCK = 22
# #
......
...@@ -315,7 +315,7 @@ class ServerCreateAPITest(ComputeAPITest): ...@@ -315,7 +315,7 @@ class ServerCreateAPITest(ComputeAPITest):
request = deepcopy(self.request) request = deepcopy(self.request)
request["server"]["networks"] = [bnet3.network.id, bnet4.network.id] request["server"]["networks"] = [bnet3.network.id, bnet4.network.id]
with override_settings(settings, with override_settings(settings,
DEFAULT_INSTANCE_NETWORKS=["public", bnet1.network.id, DEFAULT_INSTANCE_NETWORKS=["SNF:ANY_PUBLIC", bnet1.network.id,
bnet2.network.id]): bnet2.network.id]):
with mocked_quotaholder(): with mocked_quotaholder():
response = self.mypost('servers', 'test_user', response = self.mypost('servers', 'test_user',
...@@ -359,14 +359,16 @@ class ServerCreateAPITest(ComputeAPITest): ...@@ -359,14 +359,16 @@ class ServerCreateAPITest(ComputeAPITest):
# test connect to public netwok # test connect to public netwok
request = deepcopy(self.request) request = deepcopy(self.request)
request["server"]["networks"] = [self.network.id] request["server"]["networks"] = [self.network.id]
with override_settings(settings, DEFAULT_INSTANCE_NETWORKS=["public"]): with override_settings(settings,
DEFAULT_INSTANCE_NETWORKS=["SNF:ANY_PUBLIC"]):
response = self.mypost('servers', 'test_user', response = self.mypost('servers', 'test_user',
json.dumps(request), 'json') json.dumps(request), 'json')
self.assertFault(response, 403, "forbidden") self.assertFault(response, 403, "forbidden")
# test wrong user # test wrong user
request = deepcopy(self.request) request = deepcopy(self.request)
request["server"]["networks"] = [bnet3.network.id] request["server"]["networks"] = [bnet3.network.id]
with override_settings(settings, DEFAULT_INSTANCE_NETWORKS=["public"]): with override_settings(settings,
DEFAULT_INSTANCE_NETWORKS=["SNF:ANY_PUBLIC"]):
with mocked_quotaholder(): with mocked_quotaholder():
response = self.mypost('servers', 'dummy_user', response = self.mypost('servers', 'dummy_user',
json.dumps(request), 'json') json.dumps(request), 'json')
......
...@@ -17,6 +17,12 @@ POLL_LIMIT = 3600 ...@@ -17,6 +17,12 @@ POLL_LIMIT = 3600
# Network Configuration # Network Configuration
# #
# List of network IDs. All created instances will get a NIC connected to each
# network of this list. If the special network ID "SNF:ANY_PUBLIC" is used,
# Cyclades will automatically choose a public network and connect the server to
# it.
DEFAULT_INSTANCE_NETWORKS=["SNF:ANY_PUBLIC"]
# Maximum allowed network size for private networks. # Maximum allowed network size for private networks.
MAX_CIDR_BLOCK = 22 MAX_CIDR_BLOCK = 22
......
...@@ -234,7 +234,7 @@ def create_instance_nics(vm, userid, private_networks=[], floating_ips=[]): ...@@ -234,7 +234,7 @@ def create_instance_nics(vm, userid, private_networks=[], floating_ips=[]):
attachments = [] attachments = []
for network_id in settings.DEFAULT_INSTANCE_NETWORKS: for network_id in settings.DEFAULT_INSTANCE_NETWORKS:
network, address = None, None network, address = None, None
if network_id == "public": if network_id == "SNF:ANY_PUBLIC":
network, address = util.allocate_public_address(backend=vm.backend) network, address = util.allocate_public_address(backend=vm.backend)
else: else:
try: try:
......
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 to comment