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

Reorder code

parent 81b6993b
......@@ -312,36 +312,6 @@ class VirtualMachine(models.Model):
def put_client(client):
put_rapi_client(client)
# Error classes
class InvalidBackendIdError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidBackendMsgError(Exception):
def __init__(self, opcode, status):
self.opcode = opcode
self.status = status
def __str__(self):
return repr('<opcode: %s, status: %s>' % (self.opcode,
self.status))
class InvalidActionError(Exception):
def __init__(self, action):
self._action = action
def __str__(self):
return repr(str(self._action))
class DeletedError(Exception):
pass
class BuildingError(Exception):
pass
def __init__(self, *args, **kw):
"""Initialize state for just created VM instances."""
super(VirtualMachine, self).__init__(*args, **kw)
......@@ -375,6 +345,36 @@ class VirtualMachine(models.Model):
def __unicode__(self):
return str(self.id)
# Error classes
class InvalidBackendIdError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidBackendMsgError(Exception):
def __init__(self, opcode, status):
self.opcode = opcode
self.status = status
def __str__(self):
return repr('<opcode: %s, status: %s>' % (self.opcode,
self.status))
class InvalidActionError(Exception):
def __init__(self, action):
self._action = action
def __str__(self):
return repr(str(self._action))
class DeletedError(Exception):
pass
class BuildingError(Exception):
pass
class VirtualMachineMetadata(models.Model):
meta_key = models.CharField(max_length=50)
......@@ -451,32 +451,6 @@ class Network(models.Model):
def __unicode__(self):
return str(self.id)
class InvalidBackendIdError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidBackendMsgError(Exception):
def __init__(self, opcode, status):
self.opcode = opcode
self.status = status
def __str__(self):
return repr('<opcode: %s, status: %s>' % (self.opcode,
self.status))
class InvalidActionError(Exception):
def __init__(self, action):
self._action = action
def __str__(self):
return repr(str(self._action))
class DeletedError(Exception):
pass
@property
def backend_id(self):
"""Return the backend id by prepending backend-prefix."""
......@@ -504,7 +478,8 @@ class Network(models.Model):
reserved_map='',
size=0)
self.save()
return IPPoolTable.objects.select_for_update().get(id=self.pool_id).pool
return IPPoolTable.objects.select_for_update().get(id=self.pool_id)\
.pool
def reserve_address(self, address):
pool = self.get_pool()
......@@ -516,6 +491,29 @@ class Network(models.Model):
pool.put(address)
pool.save()
class InvalidBackendIdError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidBackendMsgError(Exception):
def __init__(self, opcode, status):
self.opcode = opcode
self.status = status
def __str__(self):
return repr('<opcode: %s, status: %s>' % (self.opcode,
self.status))
class InvalidActionError(Exception):
def __init__(self, action):
self._action = action
def __str__(self):
return repr(str(self._action))
class BackendNetwork(models.Model):
OPER_STATES = (
......@@ -718,4 +716,3 @@ class VirtualMachineDiagnostic(models.Model):
class Meta:
ordering = ['-created']
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