irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_report_plugins_in_json.cpp
Go to the documentation of this file.
2 
4 
5 namespace irods {
6 
8  const std::string _plugin_type,
9  const char* _type_name,
10  json& _json_array)
11  {
12  std::string plugin_home;
13  error ret = resolve_plugin_path( _plugin_type, plugin_home );
14  if (!ret.ok()) {
15  return PASS( ret );
16  }
17 
18  plugin_name_generator name_gen;
20  ret = name_gen.list_plugins( plugin_home, plugin_list );
21  if ( !ret.ok() ) {
22  return PASS( ret );
23  }
24 
25  for (plugin_name_generator::plugin_list_t::iterator itr = plugin_list.begin();
26  itr != plugin_list.end();
27  ++itr)
28  {
29  json plug{
30  {"name", itr->c_str()},
31  {"type", _type_name},
32  {"version", ""},
33  {"checksum_sha256", ""}
34  };
35 
36  _json_array.push_back(plug);
37  }
38 
39  return SUCCESS();
40  }
41 
43  {
44  _plugins = json::array();
45 
46  error ret = add_plugin_type_to_json_array( PLUGIN_TYPE_RESOURCE, "resource", _plugins );
47  if ( !ret.ok() ) {
48  return PASS( ret );
49  }
50 
51  std::string svc_role;
52  ret = get_catalog_service_role(svc_role);
53  if(!ret.ok()) {
54  log(PASS(ret));
55  return PASS( ret );
56  }
57 
58  if( CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
59  ret = add_plugin_type_to_json_array( PLUGIN_TYPE_DATABASE, "database", _plugins );
60  if ( !ret.ok() ) {
61  return PASS( ret );
62  }
63  }
64 
65  ret = add_plugin_type_to_json_array( PLUGIN_TYPE_AUTHENTICATION, "authentication", _plugins );
66  if ( !ret.ok() ) {
67  return PASS( ret );
68  }
69 
70  ret = add_plugin_type_to_json_array( PLUGIN_TYPE_NETWORK, "network", _plugins );
71  if ( !ret.ok() ) {
72  return PASS( ret );
73  }
74 
75  ret = add_plugin_type_to_json_array( PLUGIN_TYPE_API, "api", _plugins );
76  if ( !ret.ok() ) {
77  return PASS( ret );
78  }
79 
80  ret = add_plugin_type_to_json_array( PLUGIN_TYPE_MICROSERVICE, "microservice", _plugins );
81  if ( !ret.ok() ) {
82  return PASS( ret );
83  }
84 
85  return SUCCESS();
86  } // get_plugin_array
87 
89  {
90  if (_entry.is_null()) {
91  return ERROR(SYS_NULL_INPUT, "null json object _entry");
92  }
93 
94  std::string host_name;
95  error ret = _resc->get_property< std::string >( irods::RESOURCE_LOCATION, host_name );
96  if ( !ret.ok() ) {
97  return PASS(ret);
98  }
99 
100  std::string name;
101  ret = _resc->get_property< std::string >( irods::RESOURCE_NAME, name );
102  if ( !ret.ok() ) {
103  return PASS(ret);
104  }
105 
106  std::string type;
107  ret = _resc->get_property< std::string >( irods::RESOURCE_TYPE, type );
108  if ( !ret.ok() ) {
109  return PASS(ret);
110  }
111 
112  std::string vault;
113  ret = _resc->get_property< std::string >( irods::RESOURCE_PATH, vault );
114  if ( !ret.ok() ) {
115  return PASS(ret);
116  }
117 
118  std::string context;
119  ret = _resc->get_property< std::string >( irods::RESOURCE_CONTEXT, context );
120  if ( !ret.ok() ) {
121  return PASS(ret);
122  }
123 
124  std::string parent;
125  ret = _resc->get_property< std::string >( irods::RESOURCE_PARENT, parent );
126  if ( !ret.ok() ) {
127  return PASS(ret);
128  }
129 
130  std::string parent_context;
131  ret = _resc->get_property< std::string >( irods::RESOURCE_PARENT_CONTEXT, parent_context );
132  if ( !ret.ok() ) {
133  return PASS(ret);
134  }
135 
136  std::string freespace;
137  ret = _resc->get_property< std::string >( irods::RESOURCE_FREESPACE, freespace );
138  if ( !ret.ok() ) {
139  return PASS(ret);
140  }
141 
142  int status = 0;
143  ret = _resc->get_property< int >( irods::RESOURCE_STATUS, status );
144  if ( !ret.ok() ) {
145  return PASS(ret);
146  }
147 
148  _entry["name"] = name;
149  _entry["type"] = type;
150  _entry["host_name"] = host_name;
151  _entry["vault_path"] = vault;
152  _entry["context_string"] = context;
153  _entry["parent_resource"] = parent;
154  _entry["parent_context"] = parent_context;
155  _entry["free_space"] = freespace;
156  _entry["status"] = (status != INT_RESC_STATUS_DOWN) ? "up" : "down";
157 
158  return SUCCESS();
159  }
160 
161 }; // namespace irods
irods::RESOURCE_LOCATION
const std::string RESOURCE_LOCATION("resource_property_location")
irods::RESOURCE_NAME
const std::string RESOURCE_NAME("resource_property_name")
irods::plugin_name_generator
Definition: irods_plugin_name_generator.hpp:15
irods::PLUGIN_TYPE_NETWORK
const std::string PLUGIN_TYPE_NETWORK("network")
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
irods::plugin_name_generator::plugin_list_t
std::vector< std::string > plugin_list_t
Definition: irods_plugin_name_generator.hpp:19
irods::RESOURCE_CONTEXT
const std::string RESOURCE_CONTEXT("resource_property_context")
irods::RESOURCE_PATH
const std::string RESOURCE_PATH("resource_property_path")
json
nlohmann::json json
Definition: group.cpp:5
generate_iadmin_commands_for_41_to_42_upgrade.name
name
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:23
irods::RESOURCE_STATUS
const std::string RESOURCE_STATUS("resource_property_status")
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::PLUGIN_TYPE_MICROSERVICE
const std::string PLUGIN_TYPE_MICROSERVICE("microservices")
irods::resolve_plugin_path
static error resolve_plugin_path(const std::string &_type, std::string &_path)
Definition: irods_load_plugin.hpp:33
irods::PLUGIN_TYPE_DATABASE
const std::string PLUGIN_TYPE_DATABASE("database")
irods::PLUGIN_TYPE_AUTHENTICATION
const std::string PLUGIN_TYPE_AUTHENTICATION("auth")
json
nlohmann::json json
Definition: irods_report_plugins_in_json.cpp:3
irods
Definition: apiHandler.hpp:35
irods::RESOURCE_TYPE
const std::string RESOURCE_TYPE("resource_property_type")
irods::add_plugin_type_to_json_array
error add_plugin_type_to_json_array(const std::string _plugin_type, const char *_type_name, nlohmann::json &_json_array)
Definition: irods_report_plugins_in_json.cpp:7
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
irods::get_plugin_array
error get_plugin_array(nlohmann::json &_plugins)
Definition: irods_report_plugins_in_json.cpp:42
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::RESOURCE_FREESPACE
const std::string RESOURCE_FREESPACE("resource_property_freespace")
SYS_NULL_INPUT
@ SYS_NULL_INPUT
Definition: rodsErrorTable.h:876
irods::log
void log(const error &)
Definition: irods_log.cpp:13
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
irods::plugin_name_generator::list_plugins
error list_plugins(const std::string &_dir_name, plugin_list_t &_list)
Definition: irods_plugin_name_generator.cpp:87
INT_RESC_STATUS_DOWN
#define INT_RESC_STATUS_DOWN
Definition: rodsDef.h:282
irods::serialize_resource_plugin_to_json
error serialize_resource_plugin_to_json(const resource_ptr &_resc, nlohmann::json &_entry)
Definition: irods_report_plugins_in_json.cpp:88
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
irods::PLUGIN_TYPE_API
const std::string PLUGIN_TYPE_API("api")
irods::RESOURCE_PARENT
const std::string RESOURCE_PARENT("resource_property_parent")
irods::PLUGIN_TYPE_RESOURCE
const std::string PLUGIN_TYPE_RESOURCE("resources")
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
type
int type
Definition: filesystem.cpp:103
irods_report_plugins_in_json.hpp
irods::RESOURCE_PARENT_CONTEXT
const std::string RESOURCE_PARENT_CONTEXT("resource_property_parent_context")