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
472b00ed
authored
Feb 05, 2014
by
Gregory Nagy
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
c6702fc4
fb11903b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
16 deletions
+64
-16
circle/dashboard/templates/dashboard/vm-detail/home.html
+3
-4
circle/dashboard/templates/dashboard/vm-detail/resources.html
+1
-1
circle/dashboard/urls.py
+5
-0
circle/dashboard/views.py
+42
-0
circle/firewall/fw.py
+10
-8
circle/monitor/calvin/calvin.py
+3
-3
No files found.
circle/dashboard/templates/dashboard/vm-detail/home.html
View file @
472b00ed
...
@@ -37,9 +37,8 @@
...
@@ -37,9 +37,8 @@
</div>
<!-- id:vm-details-tags -->
</div>
<!-- id:vm-details-tags -->
</div>
</div>
<div
class=
"col-md-8"
>
<div
class=
"col-md-8"
>
<img
src=
"/static/grafikon.png"
style=
"width:45%"
/>
<img
src=
"{% url "
dashboard
.
views
.
vm-graph
"
instance
.
pk
"
cpu
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"/static/grafikon.png"
style=
"width:45%"
/>
<img
src=
"{% url "
dashboard
.
views
.
vm-graph
"
instance
.
pk
"
memory
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"/static/grafikon.png"
style=
"width:45%"
/>
<img
src=
"{% url "
dashboard
.
views
.
vm-graph
"
instance
.
pk
"
network
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"/static/grafikon.png"
style=
"width:45%"
/>
</div>
</div>
</div>
</div>
circle/dashboard/templates/dashboard/vm-detail/resources.html
View file @
472b00ed
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
</div>
</div>
{% for d in instance.disks.all %}
{% for d in instance.disks.all %}
<h4
class=
"list-group-item-heading dashboard-vm-details-network-h3"
>
<h4
class=
"list-group-item-heading dashboard-vm-details-network-h3"
>
<i
class=
"icon-file"
></i>
{{ d.name }} - {{ d.size|filesize }}
<i
class=
"icon-file"
></i>
{{ d.name }}
(#{{ d.id }})
- {{ d.size|filesize }}
</h4>
</h4>
{% endfor %}
{% endfor %}
</div>
</div>
...
...
circle/dashboard/urls.py
View file @
472b00ed
...
@@ -7,6 +7,7 @@ from .views import (
...
@@ -7,6 +7,7 @@ from .views import (
TransferOwnershipView
,
TransferOwnershipConfirmView
,
NodeDelete
,
TransferOwnershipView
,
TransferOwnershipConfirmView
,
NodeDelete
,
TemplateList
,
LeaseDetail
,
NodeCreate
,
LeaseCreate
,
TemplateCreate
,
TemplateList
,
LeaseDetail
,
NodeCreate
,
LeaseCreate
,
TemplateCreate
,
FavouriteView
,
NodeStatus
,
GroupList
,
TemplateDelete
,
LeaseDelete
,
FavouriteView
,
NodeStatus
,
GroupList
,
TemplateDelete
,
LeaseDelete
,
VmGraphView
,
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -57,4 +58,8 @@ urlpatterns = patterns(
...
@@ -57,4 +58,8 @@ urlpatterns = patterns(
name
=
'dashboard.views.favourite'
),
name
=
'dashboard.views.favourite'
),
url
(
r'^group/list/$'
,
GroupList
.
as_view
(),
url
(
r'^group/list/$'
,
GroupList
.
as_view
(),
name
=
'dashboard.views.group-list'
),
name
=
'dashboard.views.group-list'
),
url
((
r'^vm/(?P<pk>\d+)/graph/(?P<metric>cpu|memory|network)/'
r'(?P<time>[0-9]+[hdwy])$'
),
VmGraphView
.
as_view
(),
name
=
'dashboard.views.vm-graph'
),
)
)
circle/dashboard/views.py
View file @
472b00ed
...
@@ -1224,3 +1224,45 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
...
@@ -1224,3 +1224,45 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
unicode
(
user
),
user
.
pk
,
new_owner
,
key
)
unicode
(
user
),
user
.
pk
,
new_owner
,
key
)
raise
PermissionDenied
()
raise
PermissionDenied
()
return
(
instance
,
new_owner
)
return
(
instance
,
new_owner
)
class
VmGraphView
(
LoginRequiredMixin
,
View
):
def
get
(
self
,
request
,
pk
,
metric
,
time
,
*
args
,
**
kwargs
):
from
urllib
import
urlencode
import
urllib2
if
metric
not
in
[
'cpu'
,
'memory'
,
'network'
]:
raise
SuspiciousOperation
()
try
:
instance
=
Instance
.
objects
.
get
(
id
=
pk
)
except
Instance
.
DoesNotExist
:
raise
Http404
()
if
not
instance
.
has_level
(
request
.
user
,
'user'
):
raise
PermissionDenied
()
prefix
=
'vm.
%
s'
%
instance
.
vm_name
if
metric
==
'cpu'
:
target
=
(
'cactiStyle(alias(derivative(
%
s.cpu.usage),'
'"cpu usage (
%%
)"))'
)
%
prefix
elif
metric
==
'memory'
:
target
=
(
'cactiStyle(alias(
%
s.memory.usage,'
'"memory usage (
%%
)"))'
)
%
prefix
elif
metric
==
'network'
:
target
=
(
'cactiStyle(aliasByMetric('
'derivative(
%
s.network.bytes_*)))'
)
%
prefix
else
:
raise
SuspiciousOperation
()
title
=
'
%
s (
%
s) -
%
s'
%
(
instance
.
name
,
instance
.
vm_name
,
metric
)
params
=
urlencode
({
'target'
:
target
,
'from'
:
'-
%
s'
%
time
,
'title'
:
title
.
encode
(
'UTF-8'
)})
url
=
(
'http://
%
s:
%
s/render/?width=500&height=200&
%
s'
%
(
getenv
(
"GRAPHITE_HOST"
),
getenv
(
"GRAPHITE_PORT"
),
params
))
print
url
response
=
urllib2
.
urlopen
(
urllib2
.
Request
(
url
))
return
HttpResponse
(
response
.
read
(),
mimetype
=
"image/png"
)
print
pk
,
metric
circle/firewall/fw.py
View file @
472b00ed
...
@@ -59,11 +59,11 @@ class Firewall:
...
@@ -59,11 +59,11 @@ class Firewall:
if
rule
.
direction
==
'1'
:
# going TO host
if
rule
.
direction
==
'1'
:
# going TO host
self
.
iptables
(
'-A
%
s_
%
s -d
%
s
%
s
%
s -g
%
s'
%
self
.
iptables
(
'-A
%
s_
%
s -d
%
s
%
s
%
s -g
%
s'
%
(
vlan
,
host
.
vlan
,
ipaddr
,
dport_sport
,
(
vlan
.
name
,
host
.
vlan
.
name
,
ipaddr
,
dport_sport
,
rule
.
extra
,
action
))
rule
.
extra
,
action
))
else
:
else
:
self
.
iptables
(
'-A
%
s_
%
s -s
%
s
%
s
%
s -g
%
s'
%
self
.
iptables
(
'-A
%
s_
%
s -s
%
s
%
s
%
s -g
%
s'
%
(
host
.
vlan
,
vlan
,
ipaddr
,
dport_sport
,
(
host
.
vlan
.
name
,
vlan
.
name
,
ipaddr
,
dport_sport
,
rule
.
extra
,
action
))
rule
.
extra
,
action
))
def
fw2vlan
(
self
,
rule
):
def
fw2vlan
(
self
,
rule
):
...
@@ -99,9 +99,10 @@ class Firewall:
...
@@ -99,9 +99,10 @@ class Firewall:
if
rule
.
direction
==
'1'
:
# going TO host
if
rule
.
direction
==
'1'
:
# going TO host
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
(
vlan
,
l_vlan
,
dport_sport
,
rule
.
extra
,
action
))
(
vlan
.
name
,
l_vlan
.
name
,
dport_sport
,
rule
.
extra
,
action
))
else
:
else
:
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
(
l_vlan
,
vlan
,
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
(
l_vlan
.
name
,
vlan
.
name
,
dport_sport
,
dport_sport
,
rule
.
extra
,
action
))
rule
.
extra
,
action
))
...
@@ -223,10 +224,10 @@ class Firewall:
...
@@ -223,10 +224,10 @@ class Firewall:
for
s_vlan
in
self
.
vlans
:
for
s_vlan
in
self
.
vlans
:
for
d_vlan
in
self
.
vlans
:
for
d_vlan
in
self
.
vlans
:
self
.
iptables
(
'-N
%
s_
%
s'
%
(
s_vlan
,
d_vlan
))
self
.
iptables
(
'-N
%
s_
%
s'
%
(
s_vlan
.
name
,
d_vlan
.
name
))
self
.
iptables
(
'-A FORWARD -i
%
s -o
%
s -g
%
s_
%
s'
%
self
.
iptables
(
'-A FORWARD -i
%
s -o
%
s -g
%
s_
%
s'
%
(
s_vlan
.
name
,
d_vlan
.
name
,
s_vlan
,
(
s_vlan
.
name
,
d_vlan
.
name
,
s_vlan
.
name
,
d_vlan
))
d_vlan
.
name
))
def
ipt_filter_host_rules
(
self
):
def
ipt_filter_host_rules
(
self
):
"""Build hosts' rules."""
"""Build hosts' rules."""
...
@@ -251,7 +252,8 @@ class Firewall:
...
@@ -251,7 +252,8 @@ class Firewall:
for
s_vlan
in
self
.
vlans
:
for
s_vlan
in
self
.
vlans
:
for
d_vlan
in
self
.
vlans
:
for
d_vlan
in
self
.
vlans
:
self
.
iptables
(
'-A
%
s_
%
s -g LOG_DROP'
%
(
s_vlan
,
d_vlan
))
self
.
iptables
(
'-A
%
s_
%
s -g LOG_DROP'
%
(
s_vlan
.
name
,
d_vlan
.
name
))
def
__init__
(
self
,
proto
=
4
):
def
__init__
(
self
,
proto
=
4
):
self
.
RULES
=
[]
self
.
RULES
=
[]
...
...
circle/monitor/calvin/calvin.py
View file @
472b00ed
...
@@ -5,10 +5,10 @@ import os
...
@@ -5,10 +5,10 @@ import os
class
GraphiteHandler
:
class
GraphiteHandler
:
def
__init__
(
self
):
def
__init__
(
self
):
if
os
.
getenv
(
"GRAPHITE_
SERVER"
)
is
""
:
if
os
.
getenv
(
"GRAPHITE_
HOST"
)
in
[
''
,
None
]
:
raise
RuntimeError
raise
RuntimeError
self
.
__server_name
=
os
.
getenv
(
"GRAPHITE_
SERVER
"
)
self
.
__server_name
=
os
.
getenv
(
"GRAPHITE_
HOST
"
)
if
os
.
getenv
(
"GRAPHITE_PORT"
)
i
s
""
:
if
os
.
getenv
(
"GRAPHITE_PORT"
)
i
n
[
''
,
None
]
:
raise
RuntimeError
raise
RuntimeError
self
.
__server_port
=
os
.
getenv
(
"GRAPHITE_PORT"
)
self
.
__server_port
=
os
.
getenv
(
"GRAPHITE_PORT"
)
self
.
__queries
=
[]
self
.
__queries
=
[]
...
...
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