Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-transfer-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-transfer-service
Commits
080f8231
Commit
080f8231
authored
Feb 27, 2021
by
Cristiano Urban
Browse files
Options
Downloads
Patches
Plain Diff
Added 'del' command support to 'vos_storage'.
Signed-off-by:
Cristiano Urban
<
cristiano.urban@inaf.it
>
parent
a5a36785
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/vos_storage
+70
-2
70 additions, 2 deletions
client/vos_storage
transfer_service/storage_amqp_server.py
+37
-6
37 additions, 6 deletions
transfer_service/storage_amqp_server.py
with
107 additions
and
8 deletions
client/vos_storage
+
70
−
2
View file @
080f8231
...
...
@@ -83,6 +83,69 @@ class AMQPClient(object):
else
:
sys
.
exit
(
"
\n
FATAL: Unknown response type.
\n
"
)
def
delete
(
self
):
storageRequest
=
{
"
requestType
"
:
"
STORAGE_DEL_REQ
"
}
storageResponse
=
self
.
call
(
storageRequest
)
if
"
responseType
"
not
in
storageResponse
:
sys
.
exit
(
"
FATAL: Malformed response, storage acknowledge expected.
\n
"
)
elif
storageResponse
[
"
responseType
"
]
==
"
STORAGE_DEL_ACK
"
:
storageList
=
storageResponse
[
"
storageList
"
]
if
not
storageList
:
sys
.
exit
(
"
No storage point found. Please add at least one storage point.
\n
"
)
print
(
"
\n
Select the storage location to remove:
\n
"
)
print
(
tabulate
(
storageList
,
headers
=
"
keys
"
,
tablefmt
=
"
pretty
"
))
print
()
storageIdList
=
[]
for
st
in
storageList
:
storageIdList
.
append
(
st
[
"
storage_id
"
])
storageId
=
None
while
not
storageId
in
storageIdList
:
try
:
storageId
=
input
(
"
Please, insert a storage id:
"
)
storageId
=
int
(
storageId
)
except
ValueError
:
print
(
"
Input type is not valid!
"
)
except
EOFError
:
print
(
"
\n
Please, use CTRL+C to quit.
"
)
except
KeyboardInterrupt
:
sys
.
exit
(
"
\n
CTRL+C detected. Exiting...
"
)
print
()
print
(
"
!!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
"
)
print
(
"
! This operation will remove the selected storage location only !
"
)
print
(
"
! from the database. !
"
)
print
(
"
! The mount point on the transfer node will not be removed, you !
"
)
print
(
"
! must do it manually. !
"
)
print
(
"
! Anyway, you MUST BE AWARE that all the VOSpace nodes affected !
"
)
print
(
"
! by this operation will not be accessible anymore from now on. !
"
)
print
(
"
! We strongly recommend to move all the data to another storage !
"
)
print
(
"
! location and update the database accordingly. !
"
)
print
(
"
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
"
)
print
()
confirm
=
None
while
not
confirm
in
(
"
yes
"
,
"
no
"
):
try
:
confirm
=
input
(
"
Are you sure to proceed? [yes/no]:
"
)
except
KeyboardInterrupt
:
sys
.
exit
(
"
\n
CTRL+C detected. Exiting...
"
)
except
EOFError
:
print
(
"
\n
Please, use CTRL+C to quit.
"
)
if
confirm
==
"
yes
"
:
confirmRequest
=
{
"
requestType
"
:
"
STORAGE_DEL_CON
"
,
"
storageId
"
:
storageId
}
confirmResponse
=
self
.
call
(
confirmRequest
)
if
"
responseType
"
not
in
confirmResponse
:
sys
.
exit
(
"
\n
FATAL: Malformed response, storage confirmation expected.
\n
"
)
elif
confirmResponse
[
"
responseType
"
]
==
"
STORAGE_DEL_DONE
"
:
print
(
"
\n
Storage location deleted successfully!
\n
"
)
else
:
sys
.
exit
(
"
FATAL: Unknown response type.
\n
"
)
elif
storeResponse
[
"
responseType
"
]
==
"
ERROR
"
:
errorCode
=
storeResponse
[
"
errorCode
"
]
errorMsg
=
storeResponse
[
"
errorMsg
"
]
sys
.
exit
(
f
"
Error code:
{
errorCode
}
\n
Error message:
{
errorMsg
}
\n
"
)
else
:
sys
.
exit
(
"
\n
FATAL: Unknown response type.
\n
"
)
def
list
(
self
):
storageRequest
=
{
"
requestType
"
:
"
STORAGE_LST
"
}
storageResponse
=
self
.
call
(
storageRequest
)
...
...
@@ -117,8 +180,11 @@ DESCRIPTION
add
adds a storage point to the database.
del
deletes a storage point from the database.
list
prints the storage point
s
list.
prints the
full
storage point list.
"""
)
# Create new AMQPClient object
...
...
@@ -134,5 +200,7 @@ if cmd == "add":
vosStorageCli
.
add
()
elif
cmd
==
"
list
"
:
vosStorageCli
.
list
()
elif
cmd
==
"
del
"
:
vosStorageCli
.
delete
()
else
:
vosStorageCli
.
help
()
This diff is collapsed.
Click to expand it.
transfer_service/storage_amqp_server.py
+
37
−
6
View file @
080f8231
...
...
@@ -19,6 +19,8 @@ class StorageAMQPServer(AMQPServer):
self
.
storageType
=
None
self
.
storageBasePath
=
None
self
.
storageHostname
=
None
self
.
storageId
=
None
self
.
storageAck
=
False
super
(
StorageAMQPServer
,
self
).
__init__
(
host
,
port
,
queue
)
def
execute_callback
(
self
,
requestBody
):
...
...
@@ -27,6 +29,7 @@ class StorageAMQPServer(AMQPServer):
response
=
{
"
responseType
"
:
"
ERROR
"
,
"
errorCode
"
:
1
,
"
errorMsg
"
:
"
Malformed request, missing parameters.
"
}
elif
requestBody
[
"
requestType
"
]
==
"
STORAGE_ADD
"
:
self
.
storageType
=
requestBody
[
"
storageType
"
]
self
.
storageBasePath
=
requestBody
[
"
basePath
"
]
...
...
@@ -37,6 +40,7 @@ class StorageAMQPServer(AMQPServer):
"
errorCode
"
:
2
,
"
errorMsg
"
:
"
Base path doesn
'
t exist.
"
}
return
response
self
.
dbConn
.
connect
()
result
=
self
.
dbConn
.
insertStorage
(
self
.
storageType
,
self
.
storageBasePath
,
...
...
@@ -45,14 +49,36 @@ class StorageAMQPServer(AMQPServer):
if
result
:
response
=
{
"
responseType
"
:
"
STORAGE_ADD_DONE
"
}
return
response
else
:
response
=
{
"
responseType
"
:
"
ERROR
"
,
"
errorCode
"
:
3
,
"
errorMsg
"
:
"
Storage point already exists.
"
}
return
response
elif
requestBody
[
"
requestType
"
]
==
"
STORAGE_RMV
"
:
pass
elif
requestBody
[
"
requestType
"
]
==
"
STORAGE_DEL_REQ
"
:
self
.
dbConn
.
connect
()
result
=
self
.
dbConn
.
getStorageList
()
self
.
dbConn
.
disconnect
()
response
=
{
"
responseType
"
:
"
STORAGE_DEL_ACK
"
,
"
storageList
"
:
result
}
self
.
storageAck
=
True
elif
requestBody
[
"
requestType
"
]
==
"
STORAGE_DEL_CON
"
:
self
.
storageId
=
requestBody
[
"
storageId
"
]
if
self
.
storageAck
:
self
.
storageAck
=
False
self
.
dbConn
.
connect
()
self
.
dbConn
.
deleteStorage
(
self
.
storageId
)
self
.
dbConn
.
disconnect
()
response
=
{
"
responseType
"
:
"
STORAGE_DEL_DONE
"
}
else
:
response
=
{
"
responseType
"
:
"
ERROR
"
,
"
errorCode
"
:
4
,
"
errorMsg
"
:
"
Store request not acknowledged.
"
}
elif
requestBody
[
"
requestType
"
]
==
"
STORAGE_LST
"
:
self
.
dbConn
.
connect
()
result
=
self
.
dbConn
.
getStorageList
()
...
...
@@ -61,6 +87,11 @@ class StorageAMQPServer(AMQPServer):
response
=
{
"
responseType
"
:
"
STORAGE_LST_DONE
"
,
"
storageList
"
:
result
}
else
:
response
=
{
"
responseType
"
:
"
ERROR
"
,
"
errorCode
"
:
5
,
"
errorMsg
"
:
"
Unkown request type.
"
}
return
response
def
run
(
self
):
...
...
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