DDS  ver. 3.6
SSHConfigFile.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef _DDS_NCF_H_
6 #define _DDS_NCF_H_
7 //
8 // - - - - - = = = DDS NCF (nodes configuration file parcer) = = = - - - - -
9 //
10 // a configuration should be a comma-separated values (CSV) with
11 // the following records:
12 //
13 // id, login@host.fqdn, ssh params, remote working dir, number of workers,
15 // r1, anar@lxg0527.gsi.de, -p24, /tmp/test, 4
16 // r2, anar@lxi001.gsi.de,,/tmp/test,2
17 // 125, anar@lxg0055.gsi.de, -p22, /tmp/test,8
18 // ________________________________________________________
19 //
20 // it can be read from a stream.
21 // Fields are normally separated by commas. If you want to put a comma in a field,
22 // you need to put quotes around it. Also 3 escape sequences are supported.
23 //
24 //=============================================================================
25 // STD
26 #include <memory>
27 #include <vector>
28 namespace dds
29 {
30  //=============================================================================
33  {
34  template <class InputIterator>
35  int assign(const InputIterator& _begin, const InputIterator& _end);
36  bool operator==(const SConfigRecord& _rec) const;
37 
38  std::string m_id;
39  std::string m_addr;
40  std::string m_sshOptions;
41  std::string m_wrkDir;
42  size_t m_nSlots{ 1 };
43  };
44  //=============================================================================
45  using configRecord_t = std::shared_ptr<SConfigRecord>;
46  using configRecords_t = std::vector<configRecord_t>;
47  //=============================================================================
50  {
51  public:
52  CSSHConfigFile(const std::string& _filepath);
53  CSSHConfigFile(std::istream& _stream);
54 
55  static void make(const std::string& _filepath, const configRecords_t& _records, const std::string& _bash = "");
56  static void make(std::ostream& _stream, const configRecords_t& _records, const std::string& _bash = "");
57  static void make(const std::string& _filepath,
58  const std::vector<std::string>& _hosts,
59  const std::string& _sshOptions = "",
60  const std::string& _wrkDir = "/tmp/wn_dds",
61  size_t _numSlots = 1,
62  const std::string& _bash = "");
63  static void make(std::ostream& _stream,
64  const std::vector<std::string>& _hosts,
65  const std::string& _sshOptions = "",
66  const std::string& _wrkDir = "/tmp/wn_dds",
67  size_t _numSlots = 1,
68  const std::string& _bash = "");
69 
70  const configRecords_t& getRecords();
71  const std::string& getBash();
72 
73  private:
74  struct SImpl;
75  std::shared_ptr<SImpl> m_impl;
76  };
77 } // namespace dds
78 #endif
int assign(const InputIterator &_begin, const InputIterator &_end)
Definition: SSHConfigFile.cpp:211
std::vector< configRecord_t > configRecords_t
Definition: SSHConfigFile.h:46
std::shared_ptr< SConfigRecord > configRecord_t
Definition: SSHConfigFile.h:45
bool operator==(const SConfigRecord &_rec) const
Definition: SSHConfigFile.cpp:246
const configRecords_t & getRecords()
Definition: SSHConfigFile.cpp:296
std::string m_addr
Definition: SSHConfigFile.h:39
std::string m_sshOptions
Definition: SSHConfigFile.h:40
const std::string & getBash()
Definition: SSHConfigFile.cpp:301
Definition: SSHConfigFile.cpp:29
The class represents a single record of a dds-ssh configuration file.
Definition: SSHConfigFile.h:32
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
std::string m_id
Definition: SSHConfigFile.h:38
size_t m_nSlots
Definition: SSHConfigFile.h:42
CSSHConfigFile(const std::string &_filepath)
Definition: SSHConfigFile.cpp:254
static void make(const std::string &_filepath, const configRecords_t &_records, const std::string &_bash="")
Definition: SSHConfigFile.cpp:266
std::string m_wrkDir
Definition: SSHConfigFile.h:41
Reads dds-ssh configuration file either from a text file or stream.
Definition: SSHConfigFile.h:49