Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
toolbox
WindEnergyToolbox
Commits
857539fd
Commit
857539fd
authored
8 years ago
by
mads
Browse files
Options
Downloads
Patches
Plain Diff
Improved error handling
parent
4497a8fe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/utils/cluster_tools/cluster_resource.py
+5
-4
5 additions, 4 deletions
wetb/utils/cluster_tools/cluster_resource.py
wetb/utils/cluster_tools/ssh_client.py
+12
-9
12 additions, 9 deletions
wetb/utils/cluster_tools/ssh_client.py
with
17 additions
and
13 deletions
wetb/utils/cluster_tools/cluster_resource.py
+
5
−
4
View file @
857539fd
...
...
@@ -24,7 +24,10 @@ class Resource(object):
def
ok2submit
(
self
):
"""
Always ok to have min_cpu cpus and ok to have more if there are min_free free cpus
"""
total
,
free
,
user
=
self
.
check_resources
()
try
:
total
,
free
,
user
=
self
.
check_resources
()
except
:
return
False
if
user
<
self
.
min_cpu
:
return
True
...
...
@@ -75,9 +78,7 @@ class SSHPBSClusterResource(Resource, SSHClient):
cpu_free
,
nodeSum
=
pbswrap
.
count_cpus
(
users
,
host
,
pbsnodes
)
return
nodeSum
[
'
used_cpu
'
]
+
cpu_free
,
cpu_free
,
cpu_user
except
IOError
as
e
:
raise
e
except
:
except
Exception
as
e
:
raise
EnvironmentError
(
"
check resources failed
"
)
def
jobids
(
self
,
jobname_prefix
):
...
...
This diff is collapsed.
Click to expand it.
wetb/utils/cluster_tools/ssh_client.py
+
12
−
9
View file @
857539fd
...
...
@@ -25,6 +25,8 @@ class SSHClient(object):
self
.
key
=
key
self
.
disconnect
=
0
self
.
client
=
None
self
.
sftp
=
None
self
.
transport
=
None
if
key
is
not
None
:
self
.
key
=
paramiko
.
RSAKey
.
from_private_key
(
StringIO
(
key
),
password
=
passphrase
)
...
...
@@ -33,7 +35,8 @@ class SSHClient(object):
def
__enter__
(
self
):
self
.
disconnect
+=
1
if
self
.
client
is
None
:
if
self
.
client
is
None
or
self
.
client
.
_transport
is
None
or
self
.
client
.
_transport
.
is_active
()
is
False
:
self
.
close
()
self
.
connect
()
return
self
.
client
...
...
@@ -44,9 +47,7 @@ class SSHClient(object):
self
.
client
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
self
.
client
.
connect
(
self
.
host
,
self
.
port
,
username
=
self
.
username
,
password
=
self
.
password
,
pkey
=
self
.
key
,
timeout
=
self
.
TIMEOUT
)
assert
self
.
client
is
not
None
self
.
transport
=
paramiko
.
Transport
((
self
.
host
,
self
.
port
))
self
.
transport
.
connect
(
username
=
self
.
username
,
password
=
self
.
password
)
self
.
sftp
=
paramiko
.
SFTPClient
.
from_transport
(
self
.
transport
)
self
.
sftp
=
paramiko
.
SFTPClient
.
from_transport
(
self
.
client
.
_transport
)
return
self
def
__exit__
(
self
,
*
args
):
...
...
@@ -85,11 +86,12 @@ class SSHClient(object):
print
(
ret
)
def
close
(
self
):
if
self
.
client
is
not
None
:
self
.
client
.
close
()
self
.
client
=
None
self
.
sftp
.
close
()
self
.
transport
.
close
()
for
x
in
[
"
sftp
"
,
"
client
"
]:
try
:
getattr
(
self
,
x
).
close
()
setattr
(
self
,
x
,
None
)
except
:
pass
self
.
disconnect
=
False
def
file_exists
(
self
,
filename
):
...
...
@@ -180,6 +182,7 @@ class SharedSSHClient(SSHClient):
while
self
.
next
!=
threading
.
currentThread
():
time
.
sleep
(
1
)
SSHClient
.
__enter__
(
self
)
return
self
.
client
def
__exit__
(
self
,
*
args
):
...
...
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