29 namespace swissknife {
57 params.
action = *(args.find(
'a')->second);
58 params.
key_file = *(args.find(
'k')->second);
62 const std::string lease_fqdn = tokens.front();
69 if (curl_global_init(CURL_GLOBAL_ALL)) {
82 if (params.
action ==
"acquire") {
86 std::string session_token;
91 const std::string token_file_name =
92 "/var/spool/cvmfs/" + lease_fqdn +
"/session_token";
96 std::strerror(errno));
111 }
else if (params.
action ==
"drop") {
113 std::string session_token;
114 std::string token_file_name =
115 "/var/spool/cvmfs/" + lease_fqdn +
"/session_token";
116 FILE* token_file = std::fopen(token_file_name.c_str(),
"r");
120 session_token.c_str());
126 std::fclose(token_file);
127 if (unlink(token_file_name.c_str())) {
129 "Warning - Could not delete session token file.");
141 std::fclose(token_file);
bool MakeEndRequest(const std::string &method, const std::string &key_id, const std::string &secret, const std::string &session_token, const std::string &repo_service_url, const std::string &request_payload, CurlBuffer *reply)
virtual int Main(const ArgumentList &args)
std::vector< Parameter > ParameterList
bool SafeWriteToFile(const std::string &content, const std::string &path, int mode)
bool GetLineFile(FILE *f, std::string *line)
vector< string > SplitString(const string &str, char delim)
bool CheckParams(const swissknife::CommandLease::Parameters &p)
static Parameter Mandatory(const char key, const std::string &desc)
bool ReadKeys(const std::string &key_file_name, std::string *key_id, std::string *secret)
std::string repo_service_url
virtual ParameterList GetParams() const
static void MakeAcquireRequest(const gateway::GatewayKey &key, const std::string &repo_path, const std::string &repo_service_url, int llvl, CurlBuffer *buffer)
std::map< char, SharedPtr< std::string > > ArgumentList
static LeaseReply ParseDropReply(const CurlBuffer &buffer, int llvl)
static LeaseReply ParseAcquireReply(const CurlBuffer &buffer, std::string *session_token, int llvl)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)