Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
79a46294
authored
Jul 05, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into feature-fix-acls
Conflicts: circle/dashboard/views.py
parents
0c7119c8
cce7935c
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
464 additions
and
45 deletions
+464
-45
circle/dashboard/migrations/0010_auto__add_futuremember__add_unique_futuremember_org_id_group.py
+273
-0
circle/dashboard/models.py
+16
-0
circle/dashboard/templates/dashboard/confirm/base-remove.html
+14
-0
circle/dashboard/templates/dashboard/group-detail.html
+16
-2
circle/dashboard/templates/dashboard/vm-detail.html
+2
-2
circle/dashboard/templates/dashboard/vm-detail/_operations.html
+13
-3
circle/dashboard/templates/dashboard/vm-detail/network.html
+2
-2
circle/dashboard/templatetags/network_tags.py
+12
-4
circle/dashboard/urls.py
+4
-0
circle/dashboard/views.py
+71
-21
circle/firewall/fields.py
+12
-0
circle/firewall/models.py
+5
-7
circle/vm/models/instance.py
+3
-4
circle/vm/operations.py
+21
-0
No files found.
circle/dashboard/migrations/0010_auto__add_futuremember__add_unique_futuremember_org_id_group.py
0 → 100644
View file @
79a46294
# -*- coding: utf-8 -*-
from
south.utils
import
datetime_utils
as
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding model 'FutureMember'
db
.
create_table
(
u'dashboard_futuremember'
,
(
(
u'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'org_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
64
)),
(
'group'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'auth.Group'
])),
))
db
.
send_create_signal
(
u'dashboard'
,
[
'FutureMember'
])
# Adding unique constraint on 'FutureMember', fields ['org_id', 'group']
db
.
create_unique
(
u'dashboard_futuremember'
,
[
'org_id'
,
'group_id'
])
def
backwards
(
self
,
orm
):
# Removing unique constraint on 'FutureMember', fields ['org_id', 'group']
db
.
delete_unique
(
u'dashboard_futuremember'
,
[
'org_id'
,
'group_id'
])
# Deleting model 'FutureMember'
db
.
delete_table
(
u'dashboard_futuremember'
)
models
=
{
u'auth.group'
:
{
'Meta'
:
{
'object_name'
:
'Group'
},
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'80'
}),
'permissions'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
u"orm['auth.Permission']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
})
},
u'auth.permission'
:
{
'Meta'
:
{
'ordering'
:
"(u'content_type__app_label', u'content_type__model', u'codename')"
,
'unique_together'
:
"((u'content_type', u'codename'),)"
,
'object_name'
:
'Permission'
},
'codename'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'content_type'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['contenttypes.ContentType']"
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'50'
})
},
u'auth.user'
:
{
'Meta'
:
{
'object_name'
:
'User'
},
'date_joined'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'email'
:
(
'django.db.models.fields.EmailField'
,
[],
{
'max_length'
:
'75'
,
'blank'
:
'True'
}),
'first_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'30'
,
'blank'
:
'True'
}),
'groups'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'symmetrical'
:
'False'
,
'related_name'
:
"u'user_set'"
,
'blank'
:
'True'
,
'to'
:
u"orm['auth.Group']"
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'is_active'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'True'
}),
'is_staff'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'is_superuser'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'last_login'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'last_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'30'
,
'blank'
:
'True'
}),
'password'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'128'
}),
'user_permissions'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'symmetrical'
:
'False'
,
'related_name'
:
"u'user_set'"
,
'blank'
:
'True'
,
'to'
:
u"orm['auth.Permission']"
}),
'username'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'30'
})
},
u'contenttypes.contenttype'
:
{
'Meta'
:
{
'ordering'
:
"('name',)"
,
'unique_together'
:
"(('app_label', 'model'),)"
,
'object_name'
:
'ContentType'
,
'db_table'
:
"'django_content_type'"
},
'app_label'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'model'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
})
},
u'dashboard.favourite'
:
{
'Meta'
:
{
'object_name'
:
'Favourite'
},
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'instance'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['vm.Instance']"
}),
'user'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
})
},
u'dashboard.futuremember'
:
{
'Meta'
:
{
'unique_together'
:
"(('org_id', 'group'),)"
,
'object_name'
:
'FutureMember'
},
'group'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.Group']"
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'org_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'64'
})
},
u'dashboard.groupprofile'
:
{
'Meta'
:
{
'object_name'
:
'GroupProfile'
},
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'group'
:
(
'django.db.models.fields.related.OneToOneField'
,
[],
{
'to'
:
u"orm['auth.Group']"
,
'unique'
:
'True'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'org_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'64'
,
'unique'
:
'True'
,
'null'
:
'True'
,
'blank'
:
'True'
})
},
u'dashboard.notification'
:
{
'Meta'
:
{
'ordering'
:
"['-created']"
,
'object_name'
:
'Notification'
},
'created'
:
(
'model_utils.fields.AutoCreatedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'message'
:
(
'django.db.models.fields.TextField'
,
[],
{}),
'modified'
:
(
'model_utils.fields.AutoLastModifiedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'status'
:
(
'model_utils.fields.StatusField'
,
[],
{
'default'
:
"'new'"
,
'max_length'
:
'100'
,
u'no_check_for_status'
:
'True'
}),
'subject'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'128'
}),
'to'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
}),
'valid_until'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'None'
,
'null'
:
'True'
})
},
u'dashboard.profile'
:
{
'Meta'
:
{
'object_name'
:
'Profile'
},
'email_notifications'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'True'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'instance_limit'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'5'
}),
'org_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'64'
,
'unique'
:
'True'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'preferred_language'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'en'"
,
'max_length'
:
'32'
}),
'use_gravatar'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'True'
}),
'user'
:
(
'django.db.models.fields.related.OneToOneField'
,
[],
{
'to'
:
u"orm['auth.User']"
,
'unique'
:
'True'
})
},
u'firewall.domain'
:
{
'Meta'
:
{
'object_name'
:
'Domain'
},
'created_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'modified_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now'
:
'True'
,
'blank'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'40'
}),
'owner'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
}),
'ttl'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'600'
})
},
u'firewall.group'
:
{
'Meta'
:
{
'object_name'
:
'Group'
},
'created_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'modified_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now'
:
'True'
,
'blank'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'20'
}),
'owner'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
,
'null'
:
'True'
,
'blank'
:
'True'
})
},
u'firewall.host'
:
{
'Meta'
:
{
'ordering'
:
"('normalized_hostname', 'vlan')"
,
'unique_together'
:
"(('hostname', 'vlan'),)"
,
'object_name'
:
'Host'
},
'comment'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'created_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'external_ipv4'
:
(
'firewall.fields.IPAddressField'
,
[],
{
'max_length'
:
'100'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'groups'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'symmetrical'
:
'False'
,
'to'
:
u"orm['firewall.Group']"
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'hostname'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'40'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'ipv4'
:
(
'firewall.fields.IPAddressField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'100'
}),
'ipv6'
:
(
'firewall.fields.IPAddressField'
,
[],
{
'max_length'
:
'100'
,
'unique'
:
'True'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'location'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'mac'
:
(
'firewall.fields.MACAddressField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'17'
}),
'modified_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now'
:
'True'
,
'blank'
:
'True'
}),
'normalized_hostname'
:
(
'common.models.HumanSortField'
,
[],
{
'default'
:
"''"
,
'maximum_number_length'
:
'4'
,
'max_length'
:
'80'
,
'monitor'
:
"'hostname'"
,
'blank'
:
'True'
}),
'owner'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
}),
'reverse'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'40'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'shared_ip'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'vlan'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['firewall.Vlan']"
})
},
u'firewall.vlan'
:
{
'Meta'
:
{
'object_name'
:
'Vlan'
},
'comment'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'created_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'dhcp_pool'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'domain'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['firewall.Domain']"
}),
'host_ipv6_prefixlen'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'112'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'ipv6_template'
:
(
'django.db.models.fields.TextField'
,
[],
{
'default'
:
"'2001:738:2001:4031:
%(b)
d:
%(c)
d:
%(d)
d:0'"
}),
'managed'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'True'
}),
'modified_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now'
:
'True'
,
'blank'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'20'
}),
'network4'
:
(
'firewall.fields.IPNetworkField'
,
[],
{
'max_length'
:
'100'
}),
'network6'
:
(
'firewall.fields.IPNetworkField'
,
[],
{
'max_length'
:
'100'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'network_type'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'portforward'"
,
'max_length'
:
'20'
}),
'owner'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'reverse_domain'
:
(
'django.db.models.fields.TextField'
,
[],
{
'default'
:
"'
%(d)
d.
%(c)
d.
%(b)
d.
%(a)
d.in-addr.arpa'"
}),
'snat_ip'
:
(
'django.db.models.fields.GenericIPAddressField'
,
[],
{
'max_length'
:
'39'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'snat_to'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'symmetrical'
:
'False'
,
'to'
:
u"orm['firewall.Vlan']"
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'vid'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'unique'
:
'True'
})
},
u'storage.datastore'
:
{
'Meta'
:
{
'ordering'
:
"[u'name']"
,
'object_name'
:
'DataStore'
},
'hostname'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'40'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'100'
}),
'path'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'200'
})
},
u'storage.disk'
:
{
'Meta'
:
{
'ordering'
:
"[u'name']"
,
'object_name'
:
'Disk'
},
'base'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'blank'
:
'True'
,
'related_name'
:
"u'derivatives'"
,
'null'
:
'True'
,
'to'
:
u"orm['storage.Disk']"
}),
'created'
:
(
'model_utils.fields.AutoCreatedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'datastore'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['storage.DataStore']"
}),
'destroyed'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'None'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'dev_num'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"u'a'"
,
'max_length'
:
'1'
}),
'filename'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'256'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'is_ready'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'modified'
:
(
'model_utils.fields.AutoLastModifiedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
,
'blank'
:
'True'
}),
'size'
:
(
'sizefield.models.FileSizeField'
,
[],
{
'default'
:
'None'
,
'null'
:
'True'
}),
'type'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'10'
})
},
u'vm.instance'
:
{
'Meta'
:
{
'ordering'
:
"(u'pk',)"
,
'object_name'
:
'Instance'
},
'access_method'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'10'
}),
'active_since'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
'arch'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'10'
}),
'boot_menu'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'created'
:
(
'model_utils.fields.AutoCreatedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'destroyed_at'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
'disks'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'related_name'
:
"u'instance_set'"
,
'symmetrical'
:
'False'
,
'to'
:
u"orm['storage.Disk']"
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'is_base'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'lease'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['vm.Lease']"
}),
'max_ram_size'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'modified'
:
(
'model_utils.fields.AutoLastModifiedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
,
'blank'
:
'True'
}),
'node'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'blank'
:
'True'
,
'related_name'
:
"u'instance_set'"
,
'null'
:
'True'
,
'to'
:
u"orm['vm.Node']"
}),
'num_cores'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'owner'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
}),
'priority'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'pw'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'20'
}),
'ram_size'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'raw_data'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'req_traits'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
u"orm['vm.Trait']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
}),
'status'
:
(
'model_utils.fields.StatusField'
,
[],
{
'default'
:
"u'NOSTATE'"
,
'max_length'
:
'100'
,
u'no_check_for_status'
:
'True'
}),
'status_changed'
:
(
'model_utils.fields.MonitorField'
,
[],
{
'default'
:
'datetime.datetime.now'
,
u'monitor'
:
"u'status'"
}),
'system'
:
(
'django.db.models.fields.TextField'
,
[],
{}),
'template'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'blank'
:
'True'
,
'related_name'
:
"u'instance_set'"
,
'null'
:
'True'
,
'on_delete'
:
'models.SET_NULL'
,
'to'
:
u"orm['vm.InstanceTemplate']"
}),
'time_of_delete'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'None'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'time_of_suspend'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'None'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'vnc_port'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'None'
,
'unique'
:
'True'
,
'null'
:
'True'
,
'blank'
:
'True'
})
},
u'vm.instancetemplate'
:
{
'Meta'
:
{
'ordering'
:
"(u'name',)"
,
'object_name'
:
'InstanceTemplate'
},
'access_method'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'10'
}),
'arch'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'10'
}),
'boot_menu'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'created'
:
(
'model_utils.fields.AutoCreatedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'description'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'disks'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'related_name'
:
"u'template_set'"
,
'symmetrical'
:
'False'
,
'to'
:
u"orm['storage.Disk']"
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'lease'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['vm.Lease']"
}),
'max_ram_size'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'modified'
:
(
'model_utils.fields.AutoLastModifiedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'num_cores'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'owner'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['auth.User']"
}),
'parent'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['vm.InstanceTemplate']"
,
'null'
:
'True'
,
'on_delete'
:
'models.SET_NULL'
,
'blank'
:
'True'
}),
'priority'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'ram_size'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'raw_data'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'req_traits'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
u"orm['vm.Trait']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
}),
'system'
:
(
'django.db.models.fields.TextField'
,
[],
{})
},
u'vm.lease'
:
{
'Meta'
:
{
'ordering'
:
"[u'name']"
,
'object_name'
:
'Lease'
},
'delete_interval_seconds'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'100'
}),
'suspend_interval_seconds'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
})
},
u'vm.node'
:
{
'Meta'
:
{
'ordering'
:
"(u'-enabled', u'normalized_name')"
,
'object_name'
:
'Node'
},
'created'
:
(
'model_utils.fields.AutoCreatedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'enabled'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'host'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
u"orm['firewall.Host']"
}),
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'modified'
:
(
'model_utils.fields.AutoLastModifiedField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'50'
}),
'normalized_name'
:
(
'common.models.HumanSortField'
,
[],
{
'default'
:
"''"
,
'maximum_number_length'
:
'4'
,
'max_length'
:
'100'
,
'monitor'
:
"u'name'"
,
'blank'
:
'True'
}),
'overcommit'
:
(
'django.db.models.fields.FloatField'
,
[],
{
'default'
:
'1.0'
}),
'priority'
:
(
'django.db.models.fields.IntegerField'
,
[],
{}),
'traits'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
u"orm['vm.Trait']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
})
},
u'vm.trait'
:
{
'Meta'
:
{
'object_name'
:
'Trait'
},
u'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'50'
})
}
}
complete_apps
=
[
'dashboard'
]
\ No newline at end of file
circle/dashboard/models.py
View file @
79a46294
...
@@ -126,6 +126,18 @@ class Profile(Model):
...
@@ -126,6 +126,18 @@ class Profile(Model):
return
self
.
get_display_name
()
return
self
.
get_display_name
()
class
FutureMember
(
Model
):
org_id
=
CharField
(
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
group
=
ForeignKey
(
Group
)
class
Meta
:
unique_together
=
(
'org_id'
,
'group'
)
def
__unicode__
(
self
):
return
u"
%
s (
%
s)"
%
(
self
.
org_id
,
self
.
group
)
class
GroupProfile
(
AclBase
):
class
GroupProfile
(
AclBase
):
ACL_LEVELS
=
(
ACL_LEVELS
=
(
(
'operator'
,
_
(
'operator'
)),
(
'operator'
,
_
(
'operator'
)),
...
@@ -210,6 +222,10 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
...
@@ -210,6 +222,10 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
group
,
unicode
(
g
))
group
,
unicode
(
g
))
g
.
user_set
.
add
(
sender
)
g
.
user_set
.
add
(
sender
)
for
i
in
FutureMember
.
objects
.
filter
(
org_id
=
value
):
i
.
group
.
user_set
.
add
(
sender
)
i
.
delete
()
owneratrs
=
getattr
(
settings
,
'SAML_GROUP_OWNER_ATTRIBUTES'
,
[])
owneratrs
=
getattr
(
settings
,
'SAML_GROUP_OWNER_ATTRIBUTES'
,
[])
for
group
in
chain
(
*
[
attributes
[
i
]
for
group
in
chain
(
*
[
attributes
[
i
]
for
i
in
owneratrs
if
i
in
attributes
]):
for
i
in
owneratrs
if
i
in
attributes
]):
...
...
circle/dashboard/templates/dashboard/confirm/base-remove.html
0 → 100644
View file @
79a46294
{% extends "base.html" %}
{% load i18n %}
{% block title-site %}Dashboard | CIRCLE{% endblock %}
{% block content %}
{% blocktrans with group=object member=member %}
Do you really want to remove {{member}} from {{group}}?
{% endblocktrans %}
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<input
type=
"submit"
value=
"{% trans "
Remove
"
%}"
/>
</form>
{% endblock %}
circle/dashboard/templates/dashboard/group-detail.html
View file @
79a46294
...
@@ -71,16 +71,30 @@
...
@@ -71,16 +71,30 @@
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
{% for i in future_users %}
<tr>
<td>
<i
class=
"icon-user text-muted"
></i>
</td>
<td>
{{ i.org_id }}
</td>
<td>
<a
href=
"{% url "
dashboard
.
views
.
remove-future-user
"
member_org_id=
i.org_id
group_pk=
group.pk
%}"
class=
"real-link btn-link btn-xs"
>
<i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a>
</td>
</tr>
{% endfor %}
<tr>
<tr>
<td><i
class=
"icon-plus"
></i></td>
<td><i
class=
"icon-plus"
></i></td>
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<input
type=
"text"
class=
"form-control"
name=
"list-new-name"
placeholder=
"{% trans "
Name
of
user
"
%}"
>
<input
type=
"text"
class=
"form-control"
name=
"list-new-name"
placeholder=
"{% trans "
Name
of
user
"
%}"
>
</td>
</td>
</tr>
</tr>
</tbody>
</tbody>
</table>
</table>
<textarea
name=
"list-new-namelist"
class=
"form-control"
<textarea
name=
"list-new-namelist"
class=
"form-control"
placeholder=
"{% trans "
List
of
usernames
(
one
per
line
)."
%}"
></textarea>
placeholder=
"{% trans "
Add
multiple
users
at
once
(
one
identifier
per
line
)."
%}"
></textarea>
<div
class=
"form-actions"
>
<div
class=
"form-actions"
>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/vm-detail.html
View file @
79a46294
...
@@ -80,9 +80,9 @@
...
@@ -80,9 +80,9 @@
{% endif %}
{% endif %}
</dd>
</dd>
{% if instance.ipv6 %}
{% if instance.ipv6
and instance.get_connect_port
%}
<dt>
{% trans "Host (IPv6)" %}
</dt>
<dt>
{% trans "Host (IPv6)" %}
</dt>
<dd>
{{ ipv6_host }}:
<strong>
{{ i
nstance.i
pv6_port }}
</strong></dd>
<dd>
{{ ipv6_host }}:
<strong>
{{ ipv6_port }}
</strong></dd>
{% endif %}
{% endif %}
<dt>
{% trans "Username" %}
</dt>
<dt>
{% trans "Username" %}
</dt>
...
...
circle/dashboard/templates/dashboard/vm-detail/_operations.html
View file @
79a46294
...
@@ -2,10 +2,20 @@
...
@@ -2,10 +2,20 @@
{% for op in ops %}
{% for op in ops %}
{% if op.show_in_toolbar %}
{% if op.show_in_toolbar %}
<a
href=
"{{op.get_url}}"
class=
"operation operation-{{op.op}} btn btn-default btn-xs"
title=
"{{op.name}}: {{op.description}}"
>
{% if op.disabled %}
<span
class=
"operation operation-{{op.op}} btn btn-{{op.effect}} disabled btn-xs"
>
{% else %}
<a
href=
"{{op.get_url}}"
class=
"operation operation-{{op.op}} btn
btn-{{op.effect}} btn-xs"
title=
"{{op.name}}: {{op.description}}"
>
{% endif %}
<i
class=
"icon-{{op.icon}}"
></i>
<i
class=
"icon-{{op.icon}}"
></i>
<span
class=
"sr-only"
>
{{op.name}}
</span>
<span
{%
if
not
op
.
is_preferred
%}
class=
"sr-only"
{%
endif
%}
>
{{op.name}}
</span>
{% if op.disabled %}
</span>
{% else %}
</a>
</a>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
79a46294
...
@@ -92,7 +92,7 @@
...
@@ -92,7 +92,7 @@
{% if l.ipv4 %}
{% if l.ipv4 %}
<tr>
<tr>
<td>
<td>
{% display_portforward l %}
{% display_portforward
4
l %}
</td>
</td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td>
<td>
...
@@ -124,7 +124,7 @@
...
@@ -124,7 +124,7 @@
{% if l.ipv6 %}
{% if l.ipv6 %}
<tr>
<tr>
<td>
<td>
{% display_portforward l %}
{% display_portforward
6
l %}
</td>
</td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td>
<td>
...
...
circle/dashboard/templatetags/network_tags.py
View file @
79a46294
...
@@ -6,10 +6,18 @@ register = template.Library()
...
@@ -6,10 +6,18 @@ register = template.Library()
LINKABLE_PORTS
=
{
80
:
"http"
,
8080
:
"http"
,
443
:
"https"
,
21
:
"ftp"
}
LINKABLE_PORTS
=
{
80
:
"http"
,
8080
:
"http"
,
443
:
"https"
,
21
:
"ftp"
}
@register.simple_tag
(
name
=
"display_portforward"
)
@register.simple_tag
(
name
=
"display_portforward4"
)
def
display_pf
(
ports
):
def
display_pf4
(
ports
):
is_ipv6
=
"ipv6"
in
ports
return
display_pf
(
ports
,
'ipv4'
)
data
=
ports
[
"ipv6"
if
is_ipv6
else
"ipv4"
]
@register.simple_tag
(
name
=
"display_portforward6"
)
def
display_pf6
(
ports
):
return
display_pf
(
ports
,
'ipv6'
)
def
display_pf
(
ports
,
proto
):
data
=
ports
[
proto
]
if
ports
[
'private'
]
in
LINKABLE_PORTS
.
keys
():
if
ports
[
'private'
]
in
LINKABLE_PORTS
.
keys
():
href
=
"
%
s:
%
d"
%
(
data
[
'host'
],
data
[
'port'
])
href
=
"
%
s:
%
d"
%
(
data
[
'host'
],
data
[
'port'
])
...
...
circle/dashboard/urls.py
View file @
79a46294
...
@@ -31,6 +31,7 @@ from .views import (
...
@@ -31,6 +31,7 @@ from .views import (
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
GroupRemoveAclUserView
,
GroupRemoveAclGroupView
,
GroupRemoveUserView
,
GroupRemoveAclUserView
,
GroupRemoveAclGroupView
,
GroupRemoveUserView
,
GroupRemoveFutureUserView
,
GroupCreate
,
GroupProfileUpdate
,
GroupCreate
,
GroupProfileUpdate
,
TemplateChoose
,
TemplateChoose
,
UserCreationView
,
UserCreationView
,
...
@@ -157,6 +158,9 @@ urlpatterns = patterns(
...
@@ -157,6 +158,9 @@ urlpatterns = patterns(
url
(
r'^group/(?P<group_pk>\d+)/remove/user/(?P<member_pk>\d+)/$'
,
url
(
r'^group/(?P<group_pk>\d+)/remove/user/(?P<member_pk>\d+)/$'
,
GroupRemoveUserView
.
as_view
(),
GroupRemoveUserView
.
as_view
(),
name
=
"dashboard.views.remove-user"
),
name
=
"dashboard.views.remove-user"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/futureuser/(?P<member_org_id>.+)/$'
,
GroupRemoveFutureUserView
.
as_view
(),
name
=
"dashboard.views.remove-future-user"
),
url
(
r'^group/create/$'
,
GroupCreate
.
as_view
(),
url
(
r'^group/create/$'
,
GroupCreate
.
as_view
(),
name
=
'dashboard.views.group-create'
),
name
=
'dashboard.views.group-create'
),
url
(
r'^group/(?P<group_pk>\d+)/create/$'
,
url
(
r'^group/(?P<group_pk>\d+)/create/$'
,
...
...
circle/dashboard/views.py
View file @
79a46294
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
from
__future__
import
unicode_literals
,
absolute_import
from
__future__
import
unicode_literals
,
absolute_import
from
collections
import
OrderedDict
from
itertools
import
chain
from
itertools
import
chain
from
os
import
getenv
from
os
import
getenv
import
json
import
json
...
@@ -74,7 +75,7 @@ from vm.models import (
...
@@ -74,7 +75,7 @@ from vm.models import (
)
)
from
storage.models
import
Disk
from
storage.models
import
Disk
from
firewall.models
import
Vlan
,
Host
,
Rule
from
firewall.models
import
Vlan
,
Host
,
Rule
from
.models
import
Favourite
,
Profile
,
GroupProfile
from
.models
import
Favourite
,
Profile
,
GroupProfile
,
FutureMember
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
@@ -501,6 +502,7 @@ class OperationView(DetailView):
...
@@ -501,6 +502,7 @@ class OperationView(DetailView):
template_name
=
'dashboard/operate.html'
template_name
=
'dashboard/operate.html'
show_in_toolbar
=
True
show_in_toolbar
=
True
effect
=
None
@property
@property
def
name
(
self
):
def
name
(
self
):
...
@@ -510,6 +512,9 @@ class OperationView(DetailView):
...
@@ -510,6 +512,9 @@ class OperationView(DetailView):
def
description
(
self
):
def
description
(
self
):
return
self
.
get_op
()
.
description
return
self
.
get_op
()
.
description
def
is_preferred
(
self
):
return
self
.
get_op
()
.
is_preferred
()
@classmethod
@classmethod
def
get_urlname
(
cls
):
def
get_urlname
(
cls
):
return
'dashboard.vm.op.
%
s'
%
cls
.
op
return
'dashboard.vm.op.
%
s'
%
cls
.
op
...
@@ -559,14 +564,16 @@ class OperationView(DetailView):
...
@@ -559,14 +564,16 @@ class OperationView(DetailView):
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
@classmethod
@classmethod
def
factory
(
cls
,
op
,
icon
=
'cog'
):
def
factory
(
cls
,
op
,
icon
=
'cog'
,
effect
=
'info'
):
return
type
(
str
(
cls
.
__name__
+
op
),
return
type
(
str
(
cls
.
__name__
+
op
),
(
cls
,
),
{
'op'
:
op
,
'icon'
:
icon
})
(
cls
,
),
{
'op'
:
op
,
'icon'
:
icon
,
'effect'
:
effect
})
@classmethod
@classmethod
def
bind_to_object
(
cls
,
instance
):
def
bind_to_object
(
cls
,
instance
,
**
kwargs
):
v
=
cls
()
v
=
cls
()
v
.
get_object
=
lambda
:
instance
v
.
get_object
=
lambda
:
instance
for
key
,
value
in
kwargs
.
iteritems
():
setattr
(
v
,
key
,
value
)
return
v
return
v
...
@@ -643,6 +650,7 @@ class VmMigrateView(VmOperationView):
...
@@ -643,6 +650,7 @@ class VmMigrateView(VmOperationView):
op
=
'migrate'
op
=
'migrate'
icon
=
'truck'
icon
=
'truck'
effect
=
'info'
template_name
=
'dashboard/_vm-migrate.html'
template_name
=
'dashboard/_vm-migrate.html'
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
...
@@ -665,6 +673,7 @@ class VmSaveView(FormOperationMixin, VmOperationView):
...
@@ -665,6 +673,7 @@ class VmSaveView(FormOperationMixin, VmOperationView):
op
=
'save_as_template'
op
=
'save_as_template'
icon
=
'save'
icon
=
'save'
effect
=
'info'
form_class
=
VmSaveForm
form_class
=
VmSaveForm
...
@@ -690,21 +699,28 @@ class VmResourcesChangeView(VmOperationView):
...
@@ -690,21 +699,28 @@ class VmResourcesChangeView(VmOperationView):
*
args
,
**
kwargs
)
*
args
,
**
kwargs
)
vm_ops
=
{
vm_ops
=
OrderedDict
([
'reset'
:
VmOperationView
.
factory
(
op
=
'reset'
,
icon
=
'bolt'
),
(
'deploy'
,
VmOperationView
.
factory
(
'deploy'
:
VmOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
),
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
'migrate'
:
VmMigrateView
,
(
'wake_up'
,
VmOperationView
.
factory
(
'reboot'
:
VmOperationView
.
factory
(
op
=
'reboot'
,
icon
=
'refresh'
),
op
=
'wake_up'
,
icon
=
'sun'
,
effect
=
'success'
)),
'shut_off'
:
VmOperationView
.
factory
(
op
=
'shut_off'
,
icon
=
'ban-circle'
),
(
'sleep'
,
VmOperationView
.
factory
(
'shutdown'
:
VmOperationView
.
factory
(
op
=
'shutdown'
,
icon
=
'off'
),
op
=
'sleep'
,
icon
=
'moon'
,
effect
=
'info'
)),
'save_as_template'
:
VmSaveView
,
(
'migrate'
,
VmMigrateView
),
'destroy'
:
VmOperationView
.
factory
(
op
=
'destroy'
,
icon
=
'remove'
),
(
'save_as_template'
,
VmSaveView
),
'sleep'
:
VmOperationView
.
factory
(
op
=
'sleep'
,
icon
=
'moon'
),
(
'reboot'
,
VmOperationView
.
factory
(
'wake_up'
:
VmOperationView
.
factory
(
op
=
'wake_up'
,
icon
=
'sun'
),
op
=
'reboot'
,
icon
=
'refresh'
,
effect
=
'warning'
)),
'create_disk'
:
VmCreateDiskView
,
(
'reset'
,
VmOperationView
.
factory
(
'download_disk'
:
VmDownloadDiskView
,
op
=
'reset'
,
icon
=
'bolt'
,
effect
=
'warning'
)),
'resources_change'
:
VmResourcesChangeView
,
(
'shutdown'
,
VmOperationView
.
factory
(
}
op
=
'shutdown'
,
icon
=
'off'
,
effect
=
'warning'
)),
(
'shut_off'
,
VmOperationView
.
factory
(
op
=
'shut_off'
,
icon
=
'ban-circle'
,
effect
=
'warning'
)),
(
'destroy'
,
VmOperationView
.
factory
(
op
=
'destroy'
,
icon
=
'remove'
,
effect
=
'danger'
)),
(
'create_disk'
,
VmCreateDiskView
),
(
'download_disk'
,
VmDownloadDiskView
),
])
def
get_operations
(
instance
,
user
):
def
get_operations
(
instance
,
user
):
...
@@ -714,9 +730,11 @@ def get_operations(instance, user):
...
@@ -714,9 +730,11 @@ def get_operations(instance, user):
op
=
v
.
get_op_by_object
(
instance
)
op
=
v
.
get_op_by_object
(
instance
)
op
.
check_auth
(
user
)
op
.
check_auth
(
user
)
op
.
check_precond
()
op
.
check_precond
()
except
Exception
as
e
:
except
PermissionDenied
as
e
:
logger
.
debug
(
'Not showing operation
%
s for
%
s:
%
s'
,
logger
.
debug
(
'Not showing operation
%
s for
%
s:
%
s'
,
k
,
instance
,
unicode
(
e
))
k
,
instance
,
unicode
(
e
))
except
Exception
:
ops
.
append
(
v
.
bind_to_object
(
instance
,
disabled
=
True
))
else
:
else
:
ops
.
append
(
v
.
bind_to_object
(
instance
))
ops
.
append
(
v
.
bind_to_object
(
instance
))
return
ops
return
ops
...
@@ -803,6 +821,8 @@ class GroupDetailView(CheckedDetailView):
...
@@ -803,6 +821,8 @@ class GroupDetailView(CheckedDetailView):
context
=
super
(
GroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
GroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'group'
]
=
self
.
object
context
[
'group'
]
=
self
.
object
context
[
'users'
]
=
self
.
object
.
user_set
.
all
()
context
[
'users'
]
=
self
.
object
.
user_set
.
all
()
context
[
'future_users'
]
=
FutureMember
.
objects
.
filter
(
group
=
self
.
object
)
context
[
'acl'
]
=
get_group_acl_data
(
self
.
object
)
context
[
'acl'
]
=
get_group_acl_data
(
self
.
object
)
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
self
.
request
,
self
.
object
.
profile
)
self
.
request
,
self
.
object
.
profile
)
...
@@ -836,6 +856,10 @@ class GroupDetailView(CheckedDetailView):
...
@@ -836,6 +856,10 @@ class GroupDetailView(CheckedDetailView):
entity
=
User
.
objects
.
get
(
username
=
name
)
entity
=
User
.
objects
.
get
(
username
=
name
)
self
.
object
.
user_set
.
add
(
entity
)
self
.
object
.
user_set
.
add
(
entity
)
except
User
.
DoesNotExist
:
except
User
.
DoesNotExist
:
if
saml_available
:
FutureMember
.
objects
.
get_or_create
(
org_id
=
name
,
group
=
self
.
object
)
else
:
warning
(
request
,
_
(
'User "
%
s" not found.'
)
%
name
)
warning
(
request
,
_
(
'User "
%
s" not found.'
)
%
name
)
def
__add_list
(
self
,
request
):
def
__add_list
(
self
,
request
):
...
@@ -1350,6 +1374,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
...
@@ -1350,6 +1374,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
slug_field
=
'pk'
slug_field
=
'pk'
slug_url_kwarg
=
'group_pk'
slug_url_kwarg
=
'group_pk'
read_level
=
'operator'
read_level
=
'operator'
member_key
=
'member_pk'
def
get_has_level
(
self
):
def
get_has_level
(
self
):
return
self
.
object
.
profile
.
has_level
return
self
.
object
.
profile
.
has_level
...
@@ -1391,7 +1416,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
...
@@ -1391,7 +1416,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
object
=
self
.
get_object
()
object
=
self
.
get_object
()
if
not
object
.
profile
.
has_level
(
request
.
user
,
'operator'
):
if
not
object
.
profile
.
has_level
(
request
.
user
,
'operator'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
remove_member
(
kwargs
[
"member_pk"
])
self
.
remove_member
(
kwargs
[
self
.
member_key
])
success_url
=
self
.
get_success_url
()
success_url
=
self
.
get_success_url
()
success_message
=
self
.
get_success_message
()
success_message
=
self
.
get_success_message
()
if
request
.
is_ajax
():
if
request
.
is_ajax
():
...
@@ -1404,6 +1429,31 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
...
@@ -1404,6 +1429,31 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
return
HttpResponseRedirect
(
success_url
)
return
HttpResponseRedirect
(
success_url
)
class
GroupRemoveFutureUserView
(
GroupRemoveUserView
):
member_key
=
'member_org_id'
def
get
(
self
,
request
,
member_org_id
,
*
args
,
**
kwargs
):
self
.
member_org_id
=
member_org_id
return
super
(
GroupRemoveUserView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
GroupRemoveUserView
,
self
)
.
get_context_data
(
**
kwargs
)
try
:
context
[
'member'
]
=
FutureMember
.
objects
.
get
(
org_id
=
self
.
member_org_id
,
group
=
self
.
get_object
())
except
FutureMember
.
DoesNotExist
:
raise
Http404
()
return
context
def
remove_member
(
self
,
org_id
):
FutureMember
.
objects
.
filter
(
org_id
=
org_id
,
group
=
self
.
get_object
())
.
delete
()
def
get_success_message
(
self
):
return
_
(
"Future user successfully removed from group."
)
class
GroupRemoveAclUserView
(
GroupRemoveUserView
):
class
GroupRemoveAclUserView
(
GroupRemoveUserView
):
def
remove_member
(
self
,
pk
):
def
remove_member
(
self
,
pk
):
...
...
circle/firewall/fields.py
View file @
79a46294
...
@@ -28,6 +28,7 @@ import re
...
@@ -28,6 +28,7 @@ import re
alfanum_re
=
re
.
compile
(
r'^[A-Za-z0-9_-]+$'
)
alfanum_re
=
re
.
compile
(
r'^[A-Za-z0-9_-]+$'
)
domain_re
=
re
.
compile
(
r'^([A-Za-z0-9_-]\.?)+$'
)
domain_re
=
re
.
compile
(
r'^([A-Za-z0-9_-]\.?)+$'
)
domain_wildcard_re
=
re
.
compile
(
r'^(\*\.)?([A-Za-z0-9_-]\.?)+$'
)
ipv4_re
=
re
.
compile
(
'^([0-9]+)
\
.([0-9]+)
\
.([0-9]+)
\
.([0-9]+)$'
)
ipv4_re
=
re
.
compile
(
'^([0-9]+)
\
.([0-9]+)
\
.([0-9]+)
\
.([0-9]+)$'
)
reverse_domain_re
=
re
.
compile
(
r'^(
%
\([abcd]\)d|[a-z0-9.-])+$'
)
reverse_domain_re
=
re
.
compile
(
r'^(
%
\([abcd]\)d|[a-z0-9.-])+$'
)
ipv6_template_re
=
re
.
compile
(
r'^(
%
\([abcd]\)[dxX]|[A-Za-z0-9:-])+$'
)
ipv6_template_re
=
re
.
compile
(
r'^(
%
\([abcd]\)[dxX]|[A-Za-z0-9:-])+$'
)
...
@@ -216,12 +217,23 @@ def is_valid_domain(value):
...
@@ -216,12 +217,23 @@ def is_valid_domain(value):
return
domain_re
.
match
(
value
)
is
not
None
return
domain_re
.
match
(
value
)
is
not
None
def
is_valid_domain_wildcard
(
value
):
"""Check whether the parameter is a valid domain name."""
return
domain_wildcard_re
.
match
(
value
)
is
not
None
def
val_domain
(
value
):
def
val_domain
(
value
):
"""Validate whether the parameter is a valid domin name."""
"""Validate whether the parameter is a valid domin name."""
if
not
is_valid_domain
(
value
):
if
not
is_valid_domain
(
value
):
raise
ValidationError
(
_
(
u'
%
s - invalid domain name'
)
%
value
)
raise
ValidationError
(
_
(
u'
%
s - invalid domain name'
)
%
value
)
def
val_domain_wildcard
(
value
):
"""Validate whether the parameter is a valid domin name."""
if
not
is_valid_domain_wildcard
(
value
):
raise
ValidationError
(
_
(
u'
%
s - invalid domain name'
)
%
value
)
def
is_valid_reverse_domain
(
value
):
def
is_valid_reverse_domain
(
value
):
"""Check whether the parameter is a valid reverse domain name."""
"""Check whether the parameter is a valid reverse domain name."""
return
reverse_domain_re
.
match
(
value
)
is
not
None
return
reverse_domain_re
.
match
(
value
)
is
not
None
...
...
circle/firewall/models.py
View file @
79a46294
...
@@ -27,6 +27,7 @@ from django.forms import ValidationError
...
@@ -27,6 +27,7 @@ from django.forms import ValidationError
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
firewall.fields
import
(
MACAddressField
,
val_alfanum
,
val_reverse_domain
,
from
firewall.fields
import
(
MACAddressField
,
val_alfanum
,
val_reverse_domain
,
val_ipv6_template
,
val_domain
,
val_ipv4
,
val_ipv6_template
,
val_domain
,
val_ipv4
,
val_domain_wildcard
,
val_ipv6
,
val_mx
,
convert_ipv4_to_ipv6
,
val_ipv6
,
val_mx
,
convert_ipv4_to_ipv6
,
IPNetworkField
,
IPAddressField
)
IPNetworkField
,
IPAddressField
)
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
...
@@ -695,8 +696,7 @@ class Host(models.Model):
...
@@ -695,8 +696,7 @@ class Host(models.Model):
:param private: Port number of host in subject.
:param private: Port number of host in subject.
"""
"""
self
.
rules
.
filter
(
owner
=
self
.
owner
,
proto
=
proto
,
host
=
self
,
self
.
rules
.
filter
(
proto
=
proto
,
dport
=
private
)
.
delete
()
dport
=
private
)
.
delete
()
def
get_hostname
(
self
,
proto
,
public
=
True
):
def
get_hostname
(
self
,
proto
,
public
=
True
):
"""
"""
...
@@ -728,7 +728,7 @@ class Host(models.Model):
...
@@ -728,7 +728,7 @@ class Host(models.Model):
Return a list of ports with forwarding rules set.
Return a list of ports with forwarding rules set.
"""
"""
retval
=
[]
retval
=
[]
for
rule
in
self
.
rules
.
filter
(
owner
=
self
.
owner
):
for
rule
in
self
.
rules
.
all
(
):
forward
=
{
forward
=
{
'proto'
:
rule
.
proto
,
'proto'
:
rule
.
proto
,
'private'
:
rule
.
dport
,
'private'
:
rule
.
dport
,
...
@@ -770,9 +770,7 @@ class Host(models.Model):
...
@@ -770,9 +770,7 @@ class Host(models.Model):
if
public_port
else
if
public_port
else
None
)
None
)
# IPv6
# IPv6
blocked
=
self
.
incoming_rules
.
exclude
(
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
public_port
else
None
action
=
'accept'
)
.
filter
(
dport
=
port
,
proto
=
protocol
)
.
exists
()
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
not
blocked
else
None
return
endpoints
return
endpoints
@models.permalink
@models.permalink
...
@@ -821,7 +819,7 @@ class Domain(models.Model):
...
@@ -821,7 +819,7 @@ class Domain(models.Model):
class
Record
(
models
.
Model
):
class
Record
(
models
.
Model
):
CHOICES_type
=
((
'A'
,
'A'
),
(
'CNAME'
,
'CNAME'
),
(
'AAAA'
,
'AAAA'
),
CHOICES_type
=
((
'A'
,
'A'
),
(
'CNAME'
,
'CNAME'
),
(
'AAAA'
,
'AAAA'
),
(
'MX'
,
'MX'
),
(
'NS'
,
'NS'
),
(
'PTR'
,
'PTR'
),
(
'TXT'
,
'TXT'
))
(
'MX'
,
'MX'
),
(
'NS'
,
'NS'
),
(
'PTR'
,
'PTR'
),
(
'TXT'
,
'TXT'
))
name
=
models
.
CharField
(
max_length
=
40
,
validators
=
[
val_domain
],
name
=
models
.
CharField
(
max_length
=
40
,
validators
=
[
val_domain
_wildcard
],
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'name'
))
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'name'
))
domain
=
models
.
ForeignKey
(
'Domain'
,
verbose_name
=
_
(
'domain'
))
domain
=
models
.
ForeignKey
(
'Domain'
,
verbose_name
=
_
(
'domain'
))
host
=
models
.
ForeignKey
(
'Host'
,
blank
=
True
,
null
=
True
,
host
=
models
.
ForeignKey
(
'Host'
,
blank
=
True
,
null
=
True
,
...
...
circle/vm/models/instance.py
View file @
79a46294
...
@@ -579,11 +579,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -579,11 +579,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def
get_connect_host
(
self
,
use_ipv6
=
False
):
def
get_connect_host
(
self
,
use_ipv6
=
False
):
"""Get public hostname.
"""Get public hostname.
"""
"""
if
not
self
.
interface_set
.
exclude
(
host
=
None
)
:
if
not
self
.
primary_host
:
return
_
(
'None'
)
return
None
proto
=
'ipv6'
if
use_ipv6
else
'ipv4'
proto
=
'ipv6'
if
use_ipv6
else
'ipv4'
return
self
.
interface_set
.
exclude
(
host
=
None
)[
0
]
.
host
.
get_hostname
(
return
self
.
primary_host
.
get_hostname
(
proto
=
proto
)
proto
=
proto
)
def
get_connect_command
(
self
,
use_ipv6
=
False
):
def
get_connect_command
(
self
,
use_ipv6
=
False
):
"""Returns a formatted connect string.
"""Returns a formatted connect string.
...
...
circle/vm/operations.py
View file @
79a46294
...
@@ -76,6 +76,11 @@ class InstanceOperation(Operation):
...
@@ -76,6 +76,11 @@ class InstanceOperation(Operation):
code_suffix
=
self
.
activity_code_suffix
,
instance
=
self
.
instance
,
code_suffix
=
self
.
activity_code_suffix
,
instance
=
self
.
instance
,
user
=
user
,
concurrency_check
=
self
.
concurrency_check
)
user
=
user
,
concurrency_check
=
self
.
concurrency_check
)
def
is_preferred
(
self
):
"""If this is the recommended op in the current state of the instance.
"""
return
False
class
AddInterfaceOperation
(
InstanceOperation
):
class
AddInterfaceOperation
(
InstanceOperation
):
activity_code_suffix
=
'add_interface'
activity_code_suffix
=
'add_interface'
...
@@ -166,6 +171,10 @@ class DeployOperation(InstanceOperation):
...
@@ -166,6 +171,10 @@ class DeployOperation(InstanceOperation):
if
self
.
instance
.
status
in
[
'RUNNING'
,
'SUSPENDED'
]:
if
self
.
instance
.
status
in
[
'RUNNING'
,
'SUSPENDED'
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
is_preferred
(
self
):
return
self
.
instance
.
status
in
(
self
.
instance
.
STATUS
.
STOPPED
,
self
.
instance
.
STATUS
.
ERROR
)
def
on_commit
(
self
,
activity
):
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'RUNNING'
activity
.
resultant_state
=
'RUNNING'
...
@@ -377,6 +386,10 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -377,6 +386,10 @@ class SaveAsTemplateOperation(InstanceOperation):
abortable
=
True
abortable
=
True
required_perms
=
(
'vm.create_template'
,
)
required_perms
=
(
'vm.create_template'
,
)
def
is_preferred
(
self
):
return
(
self
.
instance
.
is_base
and
self
.
instance
.
status
==
self
.
instance
.
STATUS
.
RUNNING
)
@staticmethod
@staticmethod
def
_rename
(
name
):
def
_rename
(
name
):
m
=
search
(
r" v(\d+)$"
,
name
)
m
=
search
(
r" v(\d+)$"
,
name
)
...
@@ -525,6 +538,10 @@ class SleepOperation(InstanceOperation):
...
@@ -525,6 +538,10 @@ class SleepOperation(InstanceOperation):
description
=
_
(
"Suspend virtual machine with memory dump."
)
description
=
_
(
"Suspend virtual machine with memory dump."
)
required_perms
=
()
required_perms
=
()
def
is_preferred
(
self
):
return
(
not
self
.
instance
.
is_base
and
self
.
instance
.
status
==
self
.
instance
.
STATUS
.
RUNNING
)
def
check_precond
(
self
):
def
check_precond
(
self
):
super
(
SleepOperation
,
self
)
.
check_precond
()
super
(
SleepOperation
,
self
)
.
check_precond
()
if
self
.
instance
.
status
not
in
[
'RUNNING'
]:
if
self
.
instance
.
status
not
in
[
'RUNNING'
]:
...
@@ -565,6 +582,10 @@ class WakeUpOperation(InstanceOperation):
...
@@ -565,6 +582,10 @@ class WakeUpOperation(InstanceOperation):
"""
)
"""
)
required_perms
=
()
required_perms
=
()
def
is_preferred
(
self
):
return
(
self
.
instance
.
is_base
and
self
.
instance
.
status
==
self
.
instance
.
STATUS
.
SUSPENDED
)
def
check_precond
(
self
):
def
check_precond
(
self
):
super
(
WakeUpOperation
,
self
)
.
check_precond
()
super
(
WakeUpOperation
,
self
)
.
check_precond
()
if
self
.
instance
.
status
not
in
[
'SUSPENDED'
]:
if
self
.
instance
.
status
not
in
[
'SUSPENDED'
]:
...
...
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