Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f06f423d
authored
Feb 20, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: more consistent host names
parent
cfd5ca86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
one/models.py
+5
-2
No files found.
one/models.py
View file @
f06f423d
...
@@ -476,6 +476,7 @@ class Instance(models.Model):
...
@@ -476,6 +476,7 @@ class Instance(models.Model):
out
=
""
out
=
""
inst
=
Instance
(
pw
=
pwgen
(),
template
=
template
,
owner
=
owner
,
share
=
share
)
inst
=
Instance
(
pw
=
pwgen
(),
template
=
template
,
owner
=
owner
,
share
=
share
)
inst
.
save
()
inst
.
save
()
hostname
=
u"cloud-
%
d"
%
(
inst
.
id
,
)
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
as
f
:
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
as
f
:
os
.
chmod
(
f
.
name
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
os
.
chmod
(
f
.
name
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
token
=
signing
.
dumps
(
inst
.
id
,
salt
=
'activate'
)
token
=
signing
.
dumps
(
inst
.
id
,
salt
=
'activate'
)
...
@@ -497,7 +498,7 @@ class Instance(models.Model):
...
@@ -497,7 +498,7 @@ class Instance(models.Model):
</NIC>
</NIC>
<CONTEXT>
<CONTEXT>
<SOURCE>web</SOURCE>
<SOURCE>web</SOURCE>
<HOSTNAME>
cloud-$VMID
</HOSTNAME>
<HOSTNAME>
%(hostname)
s
</HOSTNAME>
<NEPTUN>
%(neptun)
s</NEPTUN>
<NEPTUN>
%(neptun)
s</NEPTUN>
<USERPW>
%(pw)
s</USERPW>
<USERPW>
%(pw)
s</USERPW>
<SMBPW>
%(smbpw)
s</SMBPW>
<SMBPW>
%(smbpw)
s</SMBPW>
...
@@ -511,6 +512,7 @@ class Instance(models.Model):
...
@@ -511,6 +512,7 @@ class Instance(models.Model):
"disk"
:
template
.
disk
.
id
,
"disk"
:
template
.
disk
.
id
,
"net"
:
template
.
network
.
id
,
"net"
:
template
.
network
.
id
,
"pw"
:
escape
(
inst
.
pw
),
"pw"
:
escape
(
inst
.
pw
),
"hostname"
:
escape
(
hostname
),
"smbpw"
:
escape
(
details
.
smb_password
),
"smbpw"
:
escape
(
details
.
smb_password
),
"sshkey"
:
escape
(
details
.
ssh_private_key
),
"sshkey"
:
escape
(
details
.
ssh_private_key
),
"neptun"
:
escape
(
owner
.
username
),
"neptun"
:
escape
(
owner
.
username
),
...
@@ -527,6 +529,7 @@ class Instance(models.Model):
...
@@ -527,6 +529,7 @@ class Instance(models.Model):
try
:
try
:
x
=
parseString
(
out
)
x
=
parseString
(
out
)
except
:
except
:
inst
.
delete
()
raise
Exception
(
"Unable to create VM instance."
)
raise
Exception
(
"Unable to create VM instance."
)
inst
.
one_id
=
int
(
x
.
getElementsByTagName
(
"ID"
)[
0
]
.
childNodes
[
0
]
inst
.
one_id
=
int
(
x
.
getElementsByTagName
(
"ID"
)[
0
]
.
childNodes
[
0
]
.
nodeValue
)
.
nodeValue
)
...
@@ -538,7 +541,7 @@ class Instance(models.Model):
...
@@ -538,7 +541,7 @@ class Instance(models.Model):
inst
.
update_state
()
inst
.
update_state
()
host
=
Host
(
vlan
=
Vlan
.
objects
.
get
(
name
=
template
.
network
.
name
),
host
=
Host
(
vlan
=
Vlan
.
objects
.
get
(
name
=
template
.
network
.
name
),
owner
=
owner
,
shared_ip
=
True
)
owner
=
owner
,
shared_ip
=
True
)
host
.
hostname
=
u"id-
%
d_user-
%
s"
%
(
inst
.
id
,
owner
.
username
)
host
.
hostname
=
hostname
host
.
mac
=
x
.
getElementsByTagName
(
"MAC"
)[
0
]
.
childNodes
[
0
]
.
nodeValue
host
.
mac
=
x
.
getElementsByTagName
(
"MAC"
)[
0
]
.
childNodes
[
0
]
.
nodeValue
host
.
ipv4
=
inst
.
ip
host
.
ipv4
=
inst
.
ip
host
.
pub_ipv4
=
Vlan
.
objects
.
get
(
name
=
template
.
network
.
name
)
.
snat_ip
host
.
pub_ipv4
=
Vlan
.
objects
.
get
(
name
=
template
.
network
.
name
)
.
snat_ip
...
...
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