Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
0dc28e89
Commit
0dc28e89
authored
Oct 16, 2012
by
Christos Stavrakakis
Browse files
Reorder code
parent
81b6993b
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/db/models.py
View file @
0dc28e89
...
...
@@ -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'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment