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
6278f2fc
authored
Sep 03, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-vm-ipv6' into 'master'
Feature Vm Ipv6
parents
af05a3bd
06519506
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
13 deletions
+67
-13
circle/firewall/models.py
+35
-6
circle/vm/operations.py
+2
-1
circle/vm/tasks/agent_tasks.py
+5
-0
circle/vm/tasks/local_agent_tasks.py
+25
-6
No files found.
circle/firewall/models.py
View file @
6278f2fc
...
...
@@ -215,7 +215,7 @@ class Rule(models.Model):
dst
=
None
if
host
:
ip
=
(
host
.
ipv4
,
host
.
ipv6_with_prefixlen
)
ip
=
(
host
.
ipv4
,
host
.
ipv6_with_
host_
prefixlen
)
if
self
.
direction
==
'in'
:
dst
=
ip
else
:
...
...
@@ -530,14 +530,30 @@ class Host(models.Model):
def
incoming_rules
(
self
):
return
self
.
rules
.
filter
(
direction
=
'in'
)
@
property
def
ipv6_with_prefixlen
(
self
):
@
staticmethod
def
create_ipnetwork
(
ip
,
prefixlen
):
try
:
net
=
IPNetwork
(
self
.
ipv6
)
net
.
prefixlen
=
self
.
vlan
.
host_ipv6_prefixlen
return
net
net
=
IPNetwork
(
ip
)
net
.
prefixlen
=
prefixlen
except
TypeError
:
return
None
else
:
return
net
@property
def
ipv4_with_vlan_prefixlen
(
self
):
return
Host
.
create_ipnetwork
(
self
.
ipv4
,
self
.
vlan
.
network4
.
prefixlen
)
@property
def
ipv6_with_vlan_prefixlen
(
self
):
return
Host
.
create_ipnetwork
(
self
.
ipv6
,
self
.
vlan
.
network6
.
prefixlen
)
@property
def
ipv6_with_host_prefixlen
(
self
):
return
Host
.
create_ipnetwork
(
self
.
ipv6
,
self
.
vlan
.
host_ipv6_prefixlen
)
def
get_external_ipv4
(
self
):
return
self
.
external_ipv4
if
self
.
external_ipv4
else
self
.
ipv4
...
...
@@ -600,6 +616,19 @@ class Host(models.Model):
description
=
'created by host.save()'
,
type
=
'AAAA'
)
.
save
()
def
get_network_config
(
self
):
interface
=
{
'addresses'
:
[]}
if
self
.
ipv4
and
self
.
vlan
.
network4
:
interface
[
'addresses'
]
.
append
(
str
(
self
.
ipv4_with_vlan_prefixlen
))
interface
[
'gw4'
]
=
str
(
self
.
vlan
.
network4
.
ip
)
if
self
.
ipv6
and
self
.
vlan
.
network6
:
interface
[
'addresses'
]
.
append
(
str
(
self
.
ipv6_with_vlan_prefixlen
))
interface
[
'gw6'
]
=
str
(
self
.
vlan
.
network6
.
ip
)
return
interface
def
enable_net
(
self
):
for
i
in
settings
.
get
(
'default_host_groups'
,
[]):
self
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
i
))
...
...
circle/vm/operations.py
View file @
6278f2fc
...
...
@@ -41,7 +41,7 @@ from .models import (
Instance
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
Node
,
NodeActivity
,
pwgen
)
from
.tasks
import
agent_tasks
from
.tasks
import
agent_tasks
,
local_agent_tasks
from
dashboard.store_api
import
Store
,
NoStoreException
...
...
@@ -153,6 +153,7 @@ class AddInterfaceOperation(InstanceOperation):
self
.
rollback
(
net
,
activity
)
raise
net
.
deploy
()
local_agent_tasks
.
send_networking_commands
(
self
.
instance
,
activity
)
def
get_activity_name
(
self
,
kwargs
):
return
create_readable
(
ugettext_noop
(
"add
%(vlan)
s interface"
),
...
...
circle/vm/tasks/agent_tasks.py
View file @
6278f2fc
...
...
@@ -76,3 +76,8 @@ def get_keys(vm):
@celery.task
(
name
=
'agent.send_expiration'
)
def
send_expiration
(
vm
,
url
):
pass
@celery.task
(
name
=
'agent.change_ip'
)
def
change_ip
(
vm
,
interfaces
,
dns
):
pass
circle/vm/tasks/local_agent_tasks.py
View file @
6278f2fc
...
...
@@ -19,7 +19,9 @@ from common.models import create_readable
from
manager.mancelery
import
celery
from
vm.tasks.agent_tasks
import
(
restart_networking
,
change_password
,
set_time
,
set_hostname
,
start_access_server
,
cleanup
,
update
)
cleanup
,
update
,
change_ip
)
from
firewall.models
import
Host
import
time
from
base64
import
encodestring
from
StringIO
import
StringIO
...
...
@@ -31,13 +33,11 @@ from celery.result import TimeoutError
from
monitor.client
import
Client
def
send_init_commands
(
instance
,
act
,
vm
):
def
send_init_commands
(
instance
,
act
):
vm
=
instance
.
vm_name
queue
=
instance
.
get_remote_queue_name
(
"agent"
)
with
act
.
sub_activity
(
'cleanup'
,
readable_name
=
ugettext_noop
(
'cleanup'
)):
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'
,
readable_name
=
ugettext_noop
(
'change password'
)):
change_password
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
instance
.
pw
))
...
...
@@ -49,6 +49,17 @@ def send_init_commands(instance, act, vm):
queue
=
queue
,
args
=
(
vm
,
instance
.
primary_host
.
hostname
))
def
send_networking_commands
(
instance
,
act
):
queue
=
instance
.
get_remote_queue_name
(
"agent"
)
with
act
.
sub_activity
(
'change_ip'
,
readable_name
=
ugettext_noop
(
'change ip'
)):
change_ip
.
apply_async
(
queue
=
queue
,
args
=
(
instance
.
vm_name
,
)
+
get_network_configs
(
instance
))
with
act
.
sub_activity
(
'restart_networking'
,
readable_name
=
ugettext_noop
(
'restart networking'
)):
restart_networking
.
apply_async
(
queue
=
queue
,
args
=
(
instance
.
vm_name
,
))
def
create_agent_tar
():
def
exclude
(
tarinfo
):
if
tarinfo
.
name
.
startswith
(
'./.git'
):
...
...
@@ -94,8 +105,9 @@ def agent_started(vm, version=None):
if
not
initialized
:
measure_boot_time
(
instance
)
send_init_commands
(
instance
,
act
,
vm
)
send_init_commands
(
instance
,
act
)
send_networking_commands
(
instance
,
act
)
with
act
.
sub_activity
(
'start_access_server'
,
readable_name
=
ugettext_noop
(
'start access server'
)
...
...
@@ -134,6 +146,13 @@ def agent_stopped(vm):
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
):
if
act
:
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