71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
//database file location to read in the json?
|
|
|
|
//deployer SLmanager implementation
|
|
// Copyright (C) 2024 Jean-Cloud
|
|
// GNU General Public License v3
|
|
|
|
#include <iostream>
|
|
#include <cstring>
|
|
#include <vector>
|
|
#include <list>
|
|
#include <sqlite3.h>
|
|
#include "Service.h"
|
|
#include "SQLmanager.h"
|
|
|
|
using namespace std;
|
|
|
|
//constructor
|
|
SQLmanager::SQLmanager()
|
|
{
|
|
sqlite3 *db;
|
|
char *zErrMsg = 0;
|
|
int rc;
|
|
|
|
rc = sqlite3_open("test.db", &db);
|
|
|
|
if(rc) {
|
|
cerr << "Error. Database cannot be opened." << endl << sqlite3_errmsg(db) << endl;
|
|
} else {
|
|
cout << "Database opened" << endl;
|
|
}
|
|
sqlite3_close(db);
|
|
}
|
|
|
|
//destructor inline
|
|
|
|
//public methods
|
|
vector<Service> SQLmanager::GetServices() const
|
|
{
|
|
|
|
}
|
|
const Service * SQLmanager::FindServiceByUsername(string aUsername) const
|
|
{
|
|
|
|
}
|
|
const Service * SQLmanager::FindServiceByID(int aUserID) const
|
|
{
|
|
|
|
}
|
|
//list<const Service*> FindServicesByServer(string aServer) const;
|
|
int SQLmanager::isServiceOnServer(string serviceUsername)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//int isServiceOnServer(string serviceUsername)
|
|
//this method tests if a certain service is on the current server
|
|
//it looks into the /etc/hosts file thanks to a pipe to a separate bash process
|
|
// {
|
|
// string cmd ="getent hosts " +serviceUsername;
|
|
// string result = BashManager::ExecuteAndReadResult(cmd);
|
|
// if(result.find("::1")!=string::npos){ //if result contains "::1" which is the notation for loopback in IpV6
|
|
// cout << "service " << serviceUsername << " on server" << endl;
|
|
// return 0;
|
|
// }
|
|
// cout << "service" << serviceUsername << " not on server" << endl;
|
|
// return 1;
|
|
// return 0;
|
|
// }
|