Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
R
router_services
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nova
router_services
Commits
ede88c92
Commit
ede88c92
authored
Nov 27, 2013
by
Sigmund Augdal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port from python-daemon to daemonize library (which seems to work with python3)
parent
d08e1f69
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
iptables_configurator.py
iptables_configurator.py
+14
-17
setup.py
setup.py
+1
-1
No files found.
iptables_configurator.py
View file @
ede88c92
...
...
@@ -5,27 +5,19 @@ import logging
import
logging.handlers
import
time
import
argparse
import
daemon
from
daemonize
import
Daemonize
import
sys
import
tempfile
try
:
from
daemon.pidfile
import
TimeoutPIDLockFile
except
ImportError
:
from
daemon.pidlockfile
import
TimeoutPIDLockFile
from
nova_router
import
security_groups
CONF_FILE
=
"/etc/haproxy/haproxy.cfg"
class
Generator
(
object
):
def
__init__
(
self
,
cert
,
key
,
cacert
,
logfile
=
None
):
self
.
etcd_client
=
etcd
.
Etcd
(
ssl_key
=
key
,
ssl_cert
=
cert
,
verify
=
cacert
)
if
logfile
:
handler
=
logging
.
handlers
.
RotatingFileHandler
(
logfile
,
maxBytes
=
10
*
1024
**
3
,
backupCount
=
5
)
logging
.
getLogger
(
""
).
addHandler
(
handler
)
self
.
range
=
[
150
,
200
]
self
.
prefix
=
"158.38.213."
def
__init__
(
self
,
cert
,
key
,
cacert
):
self
.
etcd_key
=
key
self
.
etcd_cert
=
cert
self
.
etcd_cacert
=
cacert
def
output
(
self
,
line
):
self
.
output_file
.
write
(
line
)
...
...
@@ -111,7 +103,12 @@ class Generator(object):
subprocess
.
call
(
"ipset restore"
,
stdin
=
self
.
output_file
,
shell
=
True
)
return
index
def
main
(
self
):
def
main
(
self
,
logfile
=
None
):
if
logfile
:
handler
=
logging
.
handlers
.
RotatingFileHandler
(
logfile
,
maxBytes
=
10
*
1024
**
3
,
backupCount
=
5
)
logging
.
getLogger
(
""
).
addHandler
(
handler
)
self
.
etcd_client
=
etcd
.
Etcd
(
ssl_key
=
self
.
etcd_key
,
ssl_cert
=
self
.
etcd_cert
,
verify
=
self
.
etcd_cacert
)
index
=
self
.
generate_all
()
sys
.
exit
(
0
)
while
True
:
...
...
@@ -136,8 +133,8 @@ if __name__ == '__main__':
args
=
parse_args
()
if
args
.
daemonize
:
logfile
=
'/var/log/nova_sg_configurator.log'
daemon_context
=
daemon
.
DaemonContext
(
pidfile
=
TimeoutPIDLockFile
(
args
.
pidfile
)
)
with
daemon_context
:
Generator
(
args
.
cert
,
args
.
key
,
args
.
cacert
,
logfile
=
logfile
).
main
()
generator
=
Generator
(
args
.
cert
,
args
.
key
,
args
.
cacert
)
daemon
=
Daemonize
(
app
=
"nova_sg_configurator"
,
pid
=
args
.
pidfile
,
action
=
lambda
:
generator
.
main
(
logfile
))
daemon
.
start
()
else
:
Generator
(
args
.
cert
,
args
.
key
,
args
.
cacert
).
main
()
setup.py
View file @
ede88c92
...
...
@@ -7,7 +7,7 @@ here = os.path.abspath(os.path.dirname(__file__))
requires
=
[
'etcd-py>0.0.5'
,
'requests'
,
'
python-daemon
'
,
'
daemonize
'
,
'pytest'
,
'mock'
,
]
...
...
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