Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
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
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
dCache
cta
Commits
be33c051
Commit
be33c051
authored
9 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Added the creation, deletion and retrieval of AdminHosts to MockSchedulerDatabase
parent
f5a8d8dc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scheduler/CMakeLists.txt
+1
-0
1 addition, 0 deletions
scheduler/CMakeLists.txt
scheduler/MockSchedulerDatabase.cpp
+70
-5
70 additions, 5 deletions
scheduler/MockSchedulerDatabase.cpp
with
71 additions
and
5 deletions
scheduler/CMakeLists.txt
+
1
−
0
View file @
be33c051
...
...
@@ -41,6 +41,7 @@ set (CTA_SCHEDULER_SRC_FILES
RetrieveToFileRequest.cpp
SchedulerDatabase.cpp
SecurityIdentity.cpp
SqliteColumnNameToIndex.cpp
StorageClass.cpp
Tape.cpp
TapeException.cpp
...
...
This diff is collapsed.
Click to expand it.
scheduler/MockSchedulerDatabase.cpp
+
70
−
5
View file @
be33c051
...
...
@@ -26,6 +26,7 @@
#include
"scheduler/LogicalLibrary.hpp"
#include
"scheduler/MockSchedulerDatabase.hpp"
#include
"scheduler/SecurityIdentity.hpp"
#include
"scheduler/SqliteColumnNameToIndex.hpp"
#include
"scheduler/StorageClass.hpp"
#include
"scheduler/Tape.hpp"
#include
"scheduler/TapePool.hpp"
...
...
@@ -157,7 +158,7 @@ void cta::MockSchedulerDatabase::createSchema() {
"FOREIGN KEY (VID) REFERENCES TAPE(VID)"
");"
,
0
,
0
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
)
{
if
(
SQLITE_OK
!=
rc
)
{
std
::
ostringstream
message
;
message
<<
"createRetrievalJobTable() - SQLite error: "
<<
zErrMsg
;
sqlite3_free
(
zErrMsg
);
...
...
@@ -169,6 +170,7 @@ void cta::MockSchedulerDatabase::createSchema() {
// destructor
//------------------------------------------------------------------------------
cta
::
MockSchedulerDatabase
::~
MockSchedulerDatabase
()
throw
()
{
sqlite3_close
(
m_dbHandle
);
}
//------------------------------------------------------------------------------
...
...
@@ -178,7 +180,26 @@ void cta::MockSchedulerDatabase::createAdminUser(
const
SecurityIdentity
&
requester
,
const
UserIdentity
&
user
,
const
std
::
string
&
comment
)
{
//m_db.insertAdminUser(requester, user, comment);
char
*
zErrMsg
=
0
;
std
::
ostringstream
query
;
query
<<
"INSERT INTO ADMINUSER(ADMIN_UID, ADMIN_GID, UID, GID,"
" CREATIONTIME, COMMENT) VALUES("
<<
user
.
getUid
()
<<
","
<<
user
.
getGid
()
<<
","
<<
requester
.
user
.
getUid
()
<<
","
<<
requester
.
user
.
getGid
()
<<
","
<<
(
int
)
time
(
NULL
)
<<
",'"
<<
comment
<<
"');"
;
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_dbHandle
,
query
.
str
().
c_str
(),
0
,
0
,
&
zErrMsg
))
{
std
::
ostringstream
message
;
message
<<
"insertAdminUser() - SQLite error: "
<<
zErrMsg
;
sqlite3_free
(
zErrMsg
);
throw
(
exception
::
Exception
(
message
.
str
()));
}
const
int
nbRowsModified
=
sqlite3_changes
(
m_dbHandle
);
if
(
0
>
nbRowsModified
)
{
std
::
ostringstream
message
;
message
<<
"ADMINUSER: "
<<
user
.
getUid
()
<<
":"
<<
user
.
getGid
()
<<
" already exists"
;
throw
(
exception
::
Exception
(
message
.
str
()));
}
}
//------------------------------------------------------------------------------
...
...
@@ -187,7 +208,24 @@ void cta::MockSchedulerDatabase::createAdminUser(
void
cta
::
MockSchedulerDatabase
::
deleteAdminUser
(
const
SecurityIdentity
&
requester
,
const
UserIdentity
&
user
)
{
//m_db.deleteAdminUser(requester, user);
char
*
zErrMsg
=
0
;
std
::
ostringstream
query
;
query
<<
"DELETE FROM ADMINUSER WHERE ADMIN_UID="
<<
user
.
getUid
()
<<
" AND ADMIN_GID="
<<
user
.
getGid
()
<<
";"
;
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_dbHandle
,
query
.
str
().
c_str
(),
0
,
0
,
&
zErrMsg
))
{
std
::
ostringstream
message
;
message
<<
"deleteAdminUser() - SQLite error: "
<<
zErrMsg
;
sqlite3_free
(
zErrMsg
);
throw
(
exception
::
Exception
(
message
.
str
()));
}
const
int
nbRowsModified
=
sqlite3_changes
(
m_dbHandle
);
if
(
0
>
nbRowsModified
)
{
std
::
ostringstream
message
;
message
<<
"ADMINUSER: "
<<
user
.
getUid
()
<<
":"
<<
user
.
getGid
()
<<
" does not exist"
;
throw
(
exception
::
Exception
(
message
.
str
()));
}
}
//------------------------------------------------------------------------------
...
...
@@ -195,8 +233,35 @@ void cta::MockSchedulerDatabase::deleteAdminUser(
//------------------------------------------------------------------------------
std
::
list
<
cta
::
AdminUser
>
cta
::
MockSchedulerDatabase
::
getAdminUsers
(
const
SecurityIdentity
&
requester
)
const
{
//return m_db.selectAllAdminUsers(requester);
return
std
::
list
<
cta
::
AdminUser
>
();
char
*
zErrMsg
=
0
;
std
::
ostringstream
query
;
std
::
list
<
cta
::
AdminUser
>
list
;
query
<<
"SELECT ADMIN_UID, ADMIN_GID, UID, GID, CREATIONTIME, COMMENT"
" FROM ADMINUSER ORDER BY ADMIN_UID, ADMIN_GID;"
;
sqlite3_stmt
*
statement
;
int
rc
=
sqlite3_prepare
(
m_dbHandle
,
query
.
str
().
c_str
(),
-
1
,
&
statement
,
0
);
if
(
rc
!=
SQLITE_OK
){
std
::
ostringstream
message
;
message
<<
"selectAllAdminUsers() - SQLite error: "
<<
zErrMsg
;
sqlite3_free
(
zErrMsg
);
sqlite3_finalize
(
statement
);
throw
(
exception
::
Exception
(
message
.
str
()));
}
while
(
SQLITE_ROW
==
sqlite3_step
(
statement
))
{
SqliteColumnNameToIndex
idx
(
statement
);
const
UserIdentity
user
(
sqlite3_column_int
(
statement
,
idx
(
"ADMIN_UID"
)),
sqlite3_column_int
(
statement
,
idx
(
"ADMIN_GID"
)));
const
UserIdentity
creator
(
sqlite3_column_int
(
statement
,
idx
(
"UID"
)),
sqlite3_column_int
(
statement
,
idx
(
"GID"
)));
list
.
push_back
(
cta
::
AdminUser
(
user
,
creator
,
std
::
string
((
char
*
)
sqlite3_column_text
(
statement
,
idx
(
"COMMENT"
))),
time_t
(
sqlite3_column_int
(
statement
,
idx
(
"CREATIONTIME"
)))
));
}
sqlite3_finalize
(
statement
);
return
list
;
}
//------------------------------------------------------------------------------
...
...
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