Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
05b07694
authored
Sep 01, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add change_ip task
parent
824c85f5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
circle/firewall/models.py
+17
-0
circle/vm/tasks/agent_tasks.py
+5
-0
circle/vm/tasks/local_agent_tasks.py
+18
-4
No files found.
circle/firewall/models.py
View file @
05b07694
...
@@ -600,6 +600,23 @@ class Host(models.Model):
...
@@ -600,6 +600,23 @@ class Host(models.Model):
description
=
'created by host.save()'
,
description
=
'created by host.save()'
,
type
=
'AAAA'
)
.
save
()
type
=
'AAAA'
)
.
save
()
def
get_network_config
(
self
):
interface
=
{
'addresses'
:
[]}
if
self
.
ipv4
and
self
.
vlan
.
network4
:
ipv4
=
IPNetwork
(
self
.
ipv4
)
ipv4
.
prefixlen
=
self
.
vlan
.
network4
.
prefixlen
interface
[
'addresses'
]
.
append
(
str
(
ipv4
))
interface
[
'gw4'
]
=
str
(
self
.
vlan
.
network4
.
ip
)
if
self
.
ipv6
and
self
.
vlan
.
network6
:
ipv6
=
IPNetwork
(
self
.
ipv6
)
ipv6
.
prefixlen
=
self
.
vlan
.
network6
.
prefixlen
interface
[
'addresses'
]
.
append
(
str
(
ipv6
))
interface
[
'gw6'
]
=
str
(
self
.
vlan
.
network6
.
ip
)
return
interface
def
enable_net
(
self
):
def
enable_net
(
self
):
for
i
in
settings
.
get
(
'default_host_groups'
,
[]):
for
i
in
settings
.
get
(
'default_host_groups'
,
[]):
self
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
i
))
self
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
i
))
...
...
circle/vm/tasks/agent_tasks.py
View file @
05b07694
...
@@ -76,3 +76,8 @@ def get_keys(vm):
...
@@ -76,3 +76,8 @@ def get_keys(vm):
@celery.task
(
name
=
'agent.send_expiration'
)
@celery.task
(
name
=
'agent.send_expiration'
)
def
send_expiration
(
vm
,
url
):
def
send_expiration
(
vm
,
url
):
pass
pass
@celery.task
(
name
=
'agent.change_ip'
)
def
change_ip
(
vm
,
interfaces
,
dns
):
pass
circle/vm/tasks/local_agent_tasks.py
View file @
05b07694
...
@@ -19,7 +19,9 @@ from common.models import create_readable
...
@@ -19,7 +19,9 @@ from common.models import create_readable
from
manager.mancelery
import
celery
from
manager.mancelery
import
celery
from
vm.tasks.agent_tasks
import
(
restart_networking
,
change_password
,
from
vm.tasks.agent_tasks
import
(
restart_networking
,
change_password
,
set_time
,
set_hostname
,
start_access_server
,
set_time
,
set_hostname
,
start_access_server
,
cleanup
,
update
)
cleanup
,
update
,
change_ip
)
from
firewall.models
import
Host
import
time
import
time
from
base64
import
encodestring
from
base64
import
encodestring
from
StringIO
import
StringIO
from
StringIO
import
StringIO
...
@@ -35,9 +37,6 @@ def send_init_commands(instance, act, vm):
...
@@ -35,9 +37,6 @@ def send_init_commands(instance, act, vm):
queue
=
instance
.
get_remote_queue_name
(
"agent"
)
queue
=
instance
.
get_remote_queue_name
(
"agent"
)
with
act
.
sub_activity
(
'cleanup'
,
readable_name
=
ugettext_noop
(
'cleanup'
)):
with
act
.
sub_activity
(
'cleanup'
,
readable_name
=
ugettext_noop
(
'cleanup'
)):
cleanup
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
))
cleanup
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
))
with
act
.
sub_activity
(
'restart_networking'
,
readable_name
=
ugettext_noop
(
'restart networking'
)):
restart_networking
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
))
with
act
.
sub_activity
(
'change_password'
,
with
act
.
sub_activity
(
'change_password'
,
readable_name
=
ugettext_noop
(
'change password'
)):
readable_name
=
ugettext_noop
(
'change password'
)):
change_password
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
instance
.
pw
))
change_password
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
instance
.
pw
))
...
@@ -96,6 +95,14 @@ def agent_started(vm, version=None):
...
@@ -96,6 +95,14 @@ def agent_started(vm, version=None):
measure_boot_time
(
instance
)
measure_boot_time
(
instance
)
send_init_commands
(
instance
,
act
,
vm
)
send_init_commands
(
instance
,
act
,
vm
)
with
act
.
sub_activity
(
'change_ip'
,
readable_name
=
ugettext_noop
(
'change ip'
)):
change_ip
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
)
+
get_network_configs
(
instance
))
with
act
.
sub_activity
(
'restart_networking'
,
readable_name
=
ugettext_noop
(
'restart networking'
)):
restart_networking
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
))
with
act
.
sub_activity
(
with
act
.
sub_activity
(
'start_access_server'
,
'start_access_server'
,
readable_name
=
ugettext_noop
(
'start access server'
)
readable_name
=
ugettext_noop
(
'start access server'
)
...
@@ -134,6 +141,13 @@ def agent_stopped(vm):
...
@@ -134,6 +141,13 @@ def agent_stopped(vm):
pass
pass
def
get_network_configs
(
instance
):
interfaces
=
{}
for
host
in
Host
.
objects
.
filter
(
interface__instance
=
instance
):
interfaces
[
str
(
host
.
mac
)]
=
host
.
get_network_config
()
return
(
interfaces
,
settings
.
FIREWALL_SETTINGS
[
'rdns_ip'
])
def
update_agent
(
instance
,
act
=
None
):
def
update_agent
(
instance
,
act
=
None
):
if
act
:
if
act
:
act
=
act
.
sub_activity
(
act
=
act
.
sub_activity
(
...
...
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