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
1616b560
authored
Mar 07, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add default subnet pool creation on login
parent
1e204ec1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
.idea/workspace.xml
+0
-0
circle/circle/settings/base.py
+6
-0
circle/network/models.py
+15
-0
No files found.
.idea/workspace.xml
View file @
1616b560
This diff is collapsed.
Click to expand it.
circle/circle/settings/base.py
View file @
1616b560
...
...
@@ -572,3 +572,8 @@ POLICY_DIRS = {
DEFAULT_USERNET_VLAN_NAME
=
(
get_env_variable
(
"DEFAULT_USERNET_VLAN_NAME"
,
"usernet"
))
USERNET_MAX
=
2
**
12
DEFAULT_SUBNETPOOL_NAME_FOR_USER
=
"default"
DEFAULT_SUBNETPOOL_PREFIXES
=
(
"10.0.0.0/8"
,
"172.16.0.0/12"
,
"192.168.0.0/16"
)
\ No newline at end of file
circle/network/models.py
View file @
1616b560
...
...
@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
import
openstack_api
from
django.conf
import
settings
from
django.contrib.auth
import
user_logged_in
from
django.db
import
models
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.urlresolvers
import
reverse
...
...
@@ -77,3 +79,15 @@ class Vxlan(models.Model):
def
get_absolute_url
(
self
):
return
reverse
(
'network.vxlan'
,
kwargs
=
{
'vni'
:
self
.
vni
})
def
create_subnet_pool
(
sender
,
user
,
request
,
**
kwargs
):
subnet_pools
=
openstack_api
.
neutron
.
subnetpool_list
(
request
)
subnet_pools
=
[
sp
for
sp
in
subnet_pools
if
sp
.
name
==
settings
.
DEFAULT_SUBNETPOOL_NAME_FOR_USER
]
if
(
len
(
subnet_pools
)
==
0
):
openstack_api
.
neutron
.
subnetpool_create
(
request
,
settings
.
DEFAULT_SUBNETPOOL_NAME_FOR_USER
,
settings
.
DEFAULT_SUBNETPOOL_PREFIXES
,
)
user_logged_in
.
connect
(
create_subnet_pool
)
\ No newline at end of file
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