Commit 2ba950f7 authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Make index field of NIC optional

Change 'index' field of NIC model to be optional, because the index of
building NICs is unknown. Also, change all API responses to return only
the active NICs.
parent 42338e7b
...@@ -489,7 +489,7 @@ def list_addresses(request, server_id): ...@@ -489,7 +489,7 @@ def list_addresses(request, server_id):
log.debug('list_addresses %s', server_id) log.debug('list_addresses %s', server_id)
vm = util.get_vm(server_id, request.user_uniq) vm = util.get_vm(server_id, request.user_uniq)
attachments = [nic_to_dict(nic) for nic in vm.nics.all()] attachments = [nic_to_dict(nic) for nic in vm.nics.filter(state="ACTIVE")]
addresses = attachments_to_addresses(attachments) addresses = attachments_to_addresses(attachments)
if request.serialization == 'xml': if request.serialization == 'xml':
...@@ -513,7 +513,7 @@ def list_addresses_by_network(request, server_id, network_id): ...@@ -513,7 +513,7 @@ def list_addresses_by_network(request, server_id, network_id):
log.debug('list_addresses_by_network %s %s', server_id, network_id) log.debug('list_addresses_by_network %s %s', server_id, network_id)
machine = util.get_vm(server_id, request.user_uniq) machine = util.get_vm(server_id, request.user_uniq)
network = util.get_network(network_id, request.user_uniq) network = util.get_network(network_id, request.user_uniq)
nics = machine.nics.filter(network=network).all() nics = machine.nics.filter(network=network, state="ACTIVE").all()
addresses = attachments_to_addresses(map(nic_to_dict, nics)) addresses = attachments_to_addresses(map(nic_to_dict, nics))
if request.serialization == 'xml': if request.serialization == 'xml':
......
...@@ -698,7 +698,7 @@ class NetworkInterface(models.Model): ...@@ -698,7 +698,7 @@ class NetworkInterface(models.Model):
network = models.ForeignKey(Network, related_name='nics') network = models.ForeignKey(Network, related_name='nics')
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)
index = models.IntegerField(null=False) index = models.IntegerField(null=True)
mac = models.CharField(max_length=32, null=True, unique=True) mac = models.CharField(max_length=32, null=True, unique=True)
ipv4 = models.CharField(max_length=15, null=True) ipv4 = models.CharField(max_length=15, null=True)
ipv6 = models.CharField(max_length=100, null=True) ipv6 = models.CharField(max_length=100, null=True)
......
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