Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
ab444298
Commit
ab444298
authored
12 years ago
by
Anael Beutot
Browse files
Options
Downloads
Patches
Plain Diff
Moved SocketBuffer in utils.py.
parent
3aa5c928
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cloudcontrol/node/hypervisor/jobs.py
+1
-57
1 addition, 57 deletions
cloudcontrol/node/hypervisor/jobs.py
cloudcontrol/node/utils.py
+56
-0
56 additions, 0 deletions
cloudcontrol/node/utils.py
with
57 additions
and
57 deletions
cloudcontrol/node/hypervisor/jobs.py
+
1
−
57
View file @
ab444298
...
...
@@ -6,7 +6,6 @@ import logging
from
os.path
import
exists
as
path_exists
from
time
import
sleep
from
hashlib
import
md5
from
collections
import
deque
from
StringIO
import
StringIO
from
subprocess
import
CalledProcessError
from
xml.etree
import
ElementTree
as
et
...
...
@@ -15,7 +14,7 @@ import pyev
from
cloudcontrol.node.exc
import
TunnelError
,
DRBDAllocationError
,
DRBDError
from
cloudcontrol.node.jobs
import
BaseThreadedJob
from
cloudcontrol.node.utils
import
subproc_call
from
cloudcontrol.node.utils
import
SocketBuffer
,
subproc_call
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -249,61 +248,6 @@ class ExportVolume(BaseThreadedJob):
self
.
clean_fds
()
class
SocketBuffer
(
deque
):
"""
Holds bytes in a list.
This class don
'
t handle maximum size but instead give help like handling
count automatically.
"""
def
__init__
(
self
,
max_len
=
8
*
64
*
1024
):
deque
.
__init__
(
self
)
self
.
max_len
=
max_len
self
.
current_len
=
0
def
append
(
self
,
x
):
deque
.
append
(
self
,
x
)
self
.
current_len
+=
len
(
x
)
def
appendleft
(
self
,
x
):
deque
.
appendleft
(
self
,
x
)
self
.
current_len
+=
len
(
x
)
def
clear
(
self
):
deque
.
clear
(
self
)
self
.
current_len
=
0
def
extend
(
self
,
iterable
):
raise
NotImplementedError
def
extendleft
(
self
,
iterable
):
raise
NotImplementedError
def
pop
(
self
):
elt
=
deque
.
pop
(
self
)
self
.
current_len
-=
len
(
elt
)
return
elt
def
popleft
(
self
):
elt
=
deque
.
popleft
(
self
)
self
.
current_len
-=
len
(
elt
)
return
elt
def
remove
(
value
):
raise
NotImplementedError
def
reverse
(
self
):
raise
NotImplementedError
def
rotate
(
self
,
n
):
raise
NotImplementedError
def
is_full
(
self
):
return
self
.
current_len
>=
self
.
max_len
def
is_empty
(
self
):
return
self
.
current_len
==
0
class
TCPTunnel
(
object
):
"""
Handles a TCP tunnel.
"""
...
...
This diff is collapsed.
Click to expand it.
cloudcontrol/node/utils.py
+
56
−
0
View file @
ab444298
import
subprocess
from
collections
import
deque
def
and_
(
iter
):
...
...
@@ -25,3 +26,58 @@ def subproc_call(args, stdin=None):
raise
subprocess
.
CalledProcessError
(
proc
.
returncode
,
'
Error while executing command
'
)
return
result
class
SocketBuffer
(
deque
):
"""
Holds bytes in a list.
This class don
'
t handle maximum size but instead give help like handling
count automatically.
"""
def
__init__
(
self
,
max_len
=
8
*
64
*
1024
):
deque
.
__init__
(
self
)
self
.
max_len
=
max_len
self
.
current_len
=
0
def
append
(
self
,
x
):
deque
.
append
(
self
,
x
)
self
.
current_len
+=
len
(
x
)
def
appendleft
(
self
,
x
):
deque
.
appendleft
(
self
,
x
)
self
.
current_len
+=
len
(
x
)
def
clear
(
self
):
deque
.
clear
(
self
)
self
.
current_len
=
0
def
extend
(
self
,
iterable
):
raise
NotImplementedError
def
extendleft
(
self
,
iterable
):
raise
NotImplementedError
def
pop
(
self
):
elt
=
deque
.
pop
(
self
)
self
.
current_len
-=
len
(
elt
)
return
elt
def
popleft
(
self
):
elt
=
deque
.
popleft
(
self
)
self
.
current_len
-=
len
(
elt
)
return
elt
def
remove
(
value
):
raise
NotImplementedError
def
reverse
(
self
):
raise
NotImplementedError
def
rotate
(
self
,
n
):
raise
NotImplementedError
def
is_full
(
self
):
return
self
.
current_len
>=
self
.
max_len
def
is_empty
(
self
):
return
self
.
current_len
==
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment