Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vnf-onboarding
OSM Packages
Commits
d3f687aa
Commit
d3f687aa
authored
May 29, 2020
by
lavado
Browse files
Merge branch 'squid' into 'master'
Remove service Actions and add Delete URL See merge request
!19
parents
e997a989
e984af0d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
26 deletions
+38
-26
magma/hackfest_squid_cnf/charms/squid/actions.yaml
magma/hackfest_squid_cnf/charms/squid/actions.yaml
+8
-7
magma/hackfest_squid_cnf/charms/squid/actions/restart
magma/hackfest_squid_cnf/charms/squid/actions/restart
+0
-2
magma/hackfest_squid_cnf/charms/squid/actions/start
magma/hackfest_squid_cnf/charms/squid/actions/start
+0
-2
magma/hackfest_squid_cnf/charms/squid/actions/stop
magma/hackfest_squid_cnf/charms/squid/actions/stop
+0
-2
magma/hackfest_squid_cnf/charms/squid/config.yaml
magma/hackfest_squid_cnf/charms/squid/config.yaml
+1
-1
magma/hackfest_squid_cnf/charms/squid/src/charm.py
magma/hackfest_squid_cnf/charms/squid/src/charm.py
+25
-1
magma/hackfest_squid_cnf/squid_vnf.yaml
magma/hackfest_squid_cnf/squid_vnf.yaml
+4
-11
No files found.
magma/hackfest_squid_cnf/charms/squid/actions.yaml
View file @
d3f687aa
addurl
:
description
:
"
Add
squid
config"
description
:
"
Add
allowed
URL
to
squid
config"
params
:
url
:
description
:
"
URL
that
will
be
allowed"
type
:
string
default
:
"
"
start
:
description
:
"
Start
squid
service"
restart
:
description
:
"
Retart
squid
service"
stop
:
description
:
"
Stop
squid
service"
deleteurl
:
description
:
"
Delete
allowed
URL
squid
config"
params
:
url
:
description
:
"
URL
that
will
stop
to
be
allowed"
type
:
string
default
:
"
"
magma/hackfest_squid_cnf/charms/squid/actions/restart
deleted
100755 → 0
View file @
e997a989
#!/bin/bash
service squid restart
magma/hackfest_squid_cnf/charms/squid/actions/start
deleted
100755 → 0
View file @
e997a989
#!/bin/bash
service squid start
magma/hackfest_squid_cnf/charms/squid/actions/stop
deleted
100755 → 0
View file @
e997a989
#!/bin/bash
service squid stop
magma/hackfest_squid_cnf/charms/squid/config.yaml
View file @
d3f687aa
...
...
@@ -2,7 +2,7 @@ options:
image
:
type
:
string
description
:
'
Docker
image
for
squid'
default
:
'
sameersbn/squid:latest
'
default
:
'
domfleischmann/squid-python
'
port
:
type
:
int
description
:
'
Port'
...
...
magma/hackfest_squid_cnf/charms/squid/src/charm.py
View file @
d3f687aa
...
...
@@ -12,6 +12,7 @@ from ops.charm import CharmBase
from
ops.framework
import
StoredState
from
ops.main
import
main
from
ops.model
import
ActiveStatus
,
MaintenanceStatus
import
subprocess
class
SquidK8SCharm
(
CharmBase
):
...
...
@@ -26,7 +27,7 @@ class SquidK8SCharm(CharmBase):
self
.
framework
.
observe
(
self
.
on
.
install
,
self
.
on_install
)
self
.
framework
.
observe
(
self
.
on
.
start
,
self
.
on_start
)
self
.
framework
.
observe
(
self
.
on
.
config_changed
,
self
.
on_config_changed
)
#
self.framework.observe(self.on.
addconfig
_action, self)
self
.
framework
.
observe
(
self
.
on
.
deleteurl
_action
,
self
)
# -- initialize states --
self
.
state
.
set_default
(
installed
=
False
)
self
.
state
.
set_default
(
configured
=
False
)
...
...
@@ -91,6 +92,29 @@ class SquidK8SCharm(CharmBase):
self
.
state
.
started
=
True
logging
.
info
(
"Started"
)
def
on_deleteurl_action
(
self
,
event
):
"""Handle the deleteurl action."""
url
=
event
.
params
[
"url"
]
line_to_delete
=
"acl allowedurls dstdomain .{}"
.
format
(
url
)
line_deleted
=
False
with
open
(
"/etc/squid/squid.conf"
,
"r"
)
as
f
:
lines
=
f
.
readlines
()
with
open
(
"/etc/squid/squid.conf"
,
"w"
)
as
f
:
for
line
in
lines
:
if
line_to_delete
not
in
line
:
f
.
write
(
line
)
else
:
line_deleted
=
True
if
line_deleted
:
event
.
set_results
({
"output"
:
"URL deleted succesfully"
})
subprocess
.
check_output
(
"kill -HUP `cat /var/run/squid.pid`"
,
shell
=
True
)
else
:
event
.
fail
(
"No URL was deleted"
)
if
__name__
==
"__main__"
:
from
ops.main
import
main
main
(
SquidK8SCharm
)
magma/hackfest_squid_cnf/squid_vnf.yaml
View file @
d3f687aa
...
...
@@ -11,22 +11,15 @@ vnfd-catalog:
juju-bundle
:
bundle.yaml
kdu-configuration
:
config-primitive
:
-
name
:
restart
parameter
:
-
name
:
application-name
data-type
:
STRING
default-value
:
squid
-
name
:
start
-
name
:
addurl
parameter
:
-
name
:
application-name
data-type
:
STRING
default-value
:
squid
-
name
:
stop
parameter
:
-
name
:
application-name
-
name
:
url
data-type
:
STRING
default-value
:
squid
-
name
:
add
url
default-value
:
"
"
-
name
:
delete
url
parameter
:
-
name
:
application-name
data-type
:
STRING
...
...
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