Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
ad8dfd89
Commit
ad8dfd89
authored
Aug 01, 2019
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
9df280f3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
36 deletions
+38
-36
slapos/pubsub/notifier.py
slapos/pubsub/notifier.py
+2
-2
slapos/resiliencytest/suites/erp5.py
slapos/resiliencytest/suites/erp5.py
+8
-7
slapos/resiliencytest/suites/kvm.py
slapos/resiliencytest/suites/kvm.py
+3
-3
slapos/resiliencytest/suites/resiliencytestsuite.py
slapos/resiliencytest/suites/resiliencytestsuite.py
+4
-4
slapos/resiliencytest/suites/slaprunner.py
slapos/resiliencytest/suites/slaprunner.py
+11
-10
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+10
-10
No files found.
slapos/pubsub/notifier.py
View file @
ad8dfd89
...
...
@@ -14,7 +14,7 @@ import subprocess
import
sys
import
time
import
traceback
import
urllib2
from
six.moves.urllib.request
import
urlopen
import
urlparse
import
uuid
...
...
@@ -145,7 +145,7 @@ def main():
print
(
'Fetching %s feed...'
%
args
.
feed_url
[
0
])
feed
=
url
lib2
.
url
open
(
args
.
feed_url
[
0
])
feed
=
urlopen
(
args
.
feed_url
[
0
])
body
=
feed
.
read
()
some_notification_failed
=
False
...
...
slapos/resiliencytest/suites/erp5.py
View file @
ad8dfd89
...
...
@@ -33,8 +33,9 @@ import random
import
ssl
import
string
import
time
import
urllib
import
urllib2
from
six.moves.urllib.parse
import
quote
from
six.moves.urllib.request
import
HTTPBasicAuthHandler
,
HTTPSHandler
,
build_opener
class
NotHttpOkException
(
Exception
):
pass
...
...
@@ -50,7 +51,7 @@ class ERP5TestSuite(SlaprunnerTestSuite):
Set inside of slaprunner the instance parameter to use to deploy erp5 instance.
"""
p
=
'<?xml version="1.0" encoding="utf-8"?> <instance> <parameter id="_">{"zodb-zeo": {"backup-periodicity": "*:1/4"}, "mariadb": {"backup-periodicity": "*:1/4"}}</parameter> </instance>'
parameter
=
urllib2
.
quote
(
p
)
parameter
=
quote
(
p
)
self
.
_connectToSlaprunner
(
resource
=
'saveParameterXml'
,
data
=
'software_type=default¶meter=%s'
%
parameter
)
...
...
@@ -109,7 +110,7 @@ class ERP5TestSuite(SlaprunnerTestSuite):
resource
=
'/saveFileContent'
,
data
=
'file=runner_workdir%%2Finstance%%2F%s%%2Fetc%%2Fhaproxy.cfg&content=%s'
%
(
haproxy_slappart
,
urllib
.
quote
(
file_content
),
quote
(
file_content
),
)
)
...
...
@@ -133,12 +134,12 @@ class ERP5TestSuite(SlaprunnerTestSuite):
def
_connectToERP5
(
self
,
url
,
data
=
None
,
password
=
None
):
if
password
is
None
:
password
=
self
.
_getERP5Password
()
auth_handler
=
urllib2
.
HTTPBasicAuthHandler
()
auth_handler
=
HTTPBasicAuthHandler
()
auth_handler
.
add_password
(
realm
=
'Zope'
,
uri
=
url
,
user
=
'zope'
,
passwd
=
password
)
ssl_context
=
ssl
.
_create_unverified_context
()
opener_director
=
urllib2
.
build_opener
(
opener_director
=
build_opener
(
auth_handler
,
urllib2
.
HTTPSHandler
(
context
=
ssl_context
)
HTTPSHandler
(
context
=
ssl_context
)
)
self
.
logger
.
info
(
'Calling ERP5 url %s'
%
url
)
...
...
slapos/resiliencytest/suites/kvm.py
View file @
ad8dfd89
...
...
@@ -32,7 +32,7 @@ import logging
import
random
import
string
import
time
import
urllib
from
six.moves.urllib.request
import
urlopen
logger
=
logging
.
getLogger
(
'KVMResiliencyTest'
)
...
...
@@ -45,7 +45,7 @@ def fetchKey(ip):
new_key
=
None
for
i
in
range
(
0
,
10
):
try
:
new_key
=
url
lib
.
url
open
(
'http://%s:10080/get'
%
ip
).
read
().
strip
()
new_key
=
urlopen
(
'http://%s:10080/get'
%
ip
).
read
().
strip
()
break
except
IOError
:
logger
.
error
(
'Server in new KVM does not answer.'
)
...
...
@@ -148,7 +148,7 @@ class KVMTestSuite(ResiliencyTestSuite):
for
i
in
range
(
0
,
60
):
failure
=
False
try
:
connection
=
url
lib
.
url
open
(
'http://%s:10080/set?key=%s'
%
(
self
.
ip
,
self
.
key
))
connection
=
urlopen
(
'http://%s:10080/set?key=%s'
%
(
self
.
ip
,
self
.
key
))
if
connection
.
getcode
()
is
200
:
break
else
:
...
...
slapos/resiliencytest/suites/resiliencytestsuite.py
View file @
ad8dfd89
...
...
@@ -34,7 +34,7 @@ import os
import
subprocess
import
sys
import
time
import
urllib2
from
six.moves.urllib.request
import
urlopen
UNIT_TEST_ERP5TESTNODE
=
'UnitTest'
...
...
@@ -85,13 +85,13 @@ class ResiliencyTestSuite(object):
takeover_url
=
root_partition_parameter_dict
[
'takeover-%s-%s-url'
%
(
namebase
,
target_clone
)]
takeover_password
=
root_partition_parameter_dict
[
'takeover-%s-%s-password'
%
(
namebase
,
target_clone
)]
# Connect to takeover web interface
takeover_page_content
=
url
lib2
.
url
open
(
takeover_url
).
read
()
takeover_page_content
=
urlopen
(
takeover_url
).
read
()
# Wait for importer script to be not running
while
'Importer script(s) of backup in progress: True'
in
takeover_page_content
:
time
.
sleep
(
10
)
takeover_page_content
=
url
lib2
.
url
open
(
takeover_url
).
read
()
takeover_page_content
=
urlopen
(
takeover_url
).
read
()
# Do takeover
takeover_result
=
url
lib2
.
url
open
(
'%s?password=%s'
%
(
takeover_url
,
takeover_password
)).
read
()
takeover_result
=
urlopen
(
'%s?password=%s'
%
(
takeover_url
,
takeover_password
)).
read
()
if
'Error'
in
takeover_result
:
raise
Exception
(
'Error while doing takeover: %s'
%
takeover_result
)
...
...
slapos/resiliencytest/suites/slaprunner.py
View file @
ad8dfd89
...
...
@@ -36,8 +36,9 @@ import random
import
ssl
import
string
import
time
import
urllib2
import
urllib
from
six.moves.urllib.request
import
HTTPCookieProcessor
,
HTTPSHandler
,
build_opener
from
six.moves.urllib.error
import
HTTPError
class
NotHttpOkException
(
Exception
):
pass
...
...
@@ -52,9 +53,9 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
cookie_jar
=
cookielib
.
CookieJar
()
ssl_context
=
ssl
.
_create_unverified_context
()
self
.
_opener_director
=
urllib2
.
build_opener
(
urllib2
.
HTTPCookieProcessor
(
cookie_jar
),
urllib2
.
HTTPSHandler
(
context
=
ssl_context
)
self
.
_opener_director
=
build_opener
(
HTTPCookieProcessor
(
cookie_jar
),
HTTPSHandler
(
context
=
ssl_context
)
)
ResiliencyTestSuite
.
__init__
(
self
,
*
args
,
**
kwargs
)
...
...
@@ -95,7 +96,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
if
result
.
getcode
()
is
not
200
:
raise
NotHttpOkException
(
result
.
getcode
())
return
result
.
read
()
except
urllib2
.
HTTPError
:
except
HTTPError
:
self
.
logger
.
error
(
'Error when contacting slaprunner at URL: {}'
.
format
(
url
))
raise
...
...
@@ -164,7 +165,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
"""
try
:
return
self
.
_connectToSlaprunner
(
resource
=
'isSRReady'
)
except
(
NotHttpOkException
,
urllib2
.
HTTPError
)
as
error
:
except
(
NotHttpOkException
,
HTTPError
)
as
error
:
# The nginx frontend might timeout before software release is finished.
self
.
logger
.
warning
(
'Problem occured when contacting the server: %s'
%
error
)
return
-
1
...
...
@@ -187,7 +188,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
self
.
logger
.
info
(
'Building the Software Release...'
)
try
:
self
.
_connectToSlaprunner
(
resource
=
'runSoftwareProfile'
)
except
(
NotHttpOkException
,
urllib2
.
HTTPError
):
except
(
NotHttpOkException
,
HTTPError
):
# The nginx frontend might timeout before software release is finished.
pass
...
...
@@ -197,7 +198,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
self
.
logger
.
info
(
'Deploying instance...'
)
try
:
self
.
_connectToSlaprunner
(
resource
=
'runInstanceProfile'
)
except
(
NotHttpOkException
,
urllib2
.
HTTPError
):
except
(
NotHttpOkException
,
HTTPError
):
# The nginx frontend might timeout before someftware release is finished.
pass
while
True
:
...
...
@@ -219,7 +220,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
if
data
[
'code'
]
==
0
:
self
.
logger
.
warning
(
data
[
'result'
])
except
(
NotHttpOkException
,
urllib2
.
HTTPError
):
except
(
NotHttpOkException
,
HTTPError
):
# cloning can be very long.
# XXX: quite dirty way to check.
while
self
.
_connectToSlaprunner
(
'getProjectStatus'
,
data
=
'project=workspace/slapos'
).
find
(
'On branch master'
)
==
-
1
:
...
...
slapos/runner/fileBrowser.py
View file @
ad8dfd89
...
...
@@ -7,7 +7,7 @@ import md5
import
os
import
re
import
shutil
import
urllib
from
six.moves.urllib.parse
import
unquote
import
zipfile
import
fnmatch
...
...
@@ -22,7 +22,7 @@ class FileBrowser(object):
self
.
config
=
config
def
_realdir
(
self
,
dir
):
realdir
=
realpath
(
self
.
config
,
u
rllib
.
u
nquote
(
dir
))
realdir
=
realpath
(
self
.
config
,
unquote
(
dir
))
if
not
realdir
:
raise
NameError
(
'Could not load directory %s: Permission denied'
%
dir
)
return
realdir
...
...
@@ -45,7 +45,7 @@ class FileBrowser(object):
"""List elements of directory 'dir' taken"""
html
=
'var gsdirs = [], gsfiles = [];'
dir
=
u
rllib
.
u
nquote
(
dir
)
dir
=
unquote
(
dir
)
# XXX-Marco 'dir' and 'all' should not shadow builtin names
realdir
=
realpath
(
self
.
config
,
dir
)
if
not
realdir
:
...
...
@@ -74,7 +74,7 @@ class FileBrowser(object):
return html
def fancylistDirs(self, dir, key, listfiles, all=False):
dir = u
rllib.u
nquote(dir)
dir = unquote(dir)
realdir = realpath(self.config, dir)
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
...
...
@@ -125,7 +125,7 @@ class FileBrowser(object):
"""Delete a list of files or directories"""
# XXX-Marco do not shadow 'dir'
realdir = self._realdir(dir)
lfiles = u
rllib.u
nquote(files).split(',,,')
lfiles = unquote(files).split(',,,')
try:
# XXX-Marco do not shadow 'file'
for item in lfiles:
...
...
@@ -147,7 +147,7 @@ class FileBrowser(object):
def copyItem(self, dir, files, del_source=False):
"""Copy a list of files or directory to dir"""
realdir = self._realdir(dir)
lfiles = u
rllib.u
nquote(files).split(',,,')
lfiles = unquote(files).split(',,,')
try:
# XXX-Marco do not shadow 'file'
for file in lfiles:
...
...
@@ -174,7 +174,7 @@ class FileBrowser(object):
def rename(self, dir, filename, newfilename):
"""Rename file or directory to dir/filename"""
realdir = self._realdir(dir)
realfile = realpath(self.config, u
rllib.u
nquote(filename))
realfile = realpath(self.config, unquote(filename))
if not realfile:
raise NameError('Could not load directory %s: Permission denied' % filename)
tofile = os.path.join(realdir, newfilename)
...
...
@@ -208,7 +208,7 @@ class FileBrowser(object):
def downloadFile(self, dir, filename):
"""Download file dir/filename"""
realdir = self._realdir(dir)
file = os.path.join(realdir, u
rllib.u
nquote(filename))
file = os.path.join(realdir, unquote(filename))
if not os.path.exists(file):
raise NameError('NOT ALLOWED OPERATION : File or directory does not exist %s'
% os.path.join(dir, filename))
...
...
@@ -255,8 +255,8 @@ class FileBrowser(object):
def readFile(self, dir, filename, truncate=False):
"""Read file dir/filename and return content"""
realfile = realpath(self.config, os.path.join(u
rllib.u
nquote(dir),
u
rllib.u
nquote(filename)))
realfile = realpath(self.config, os.path.join(unquote(dir),
unquote(filename)))
if not realfile:
raise NameError('Could not load directory %s: Permission denied' % dir)
if not isText(realfile):
...
...
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