amfconfig.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*
  2. * Copyright (c) 2002-2005 MontaVista Software, Inc.
  3. * Author: Steven Dake (sdake@mvista.com)
  4. *
  5. * Copyright (c) 2006 Ericsson AB.
  6. * Author: Hans Feldt
  7. * Description: Reworked to match AMF B.02 information model
  8. *
  9. * All rights reserved.
  10. * This software licensed under BSD license, the text of which follows:
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * - Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  21. * contributors may be used to endorse or promote products derived from this
  22. * software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  34. * THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #include <limits.h>
  37. #include "../include/saAis.h"
  38. #include "../include/saAmf.h"
  39. #include "../include/list.h"
  40. #include "aispoll.h"
  41. #ifndef AMFCONFIG_H_DEFINED
  42. #define AMFCONFIG_H_DEFINED
  43. enum escalation_levels {
  44. ESCALATION_LEVEL_NO_ESCALATION = 1, /* execute component restart */
  45. ESCALATION_LEVEL_ONE = 2, /* escalate to service unit restart */
  46. ESCALATION_LEVEL_TWO = 3, /* escalate to service unit failover */
  47. ESCALATION_LEVEL_THREE = 4 /* escalate to node failover */
  48. };
  49. enum clc_component_types {
  50. clc_component_sa_aware = 0, /* sa aware */
  51. clc_component_proxied_pre = 1, /* proxied, pre-instantiable */
  52. clc_component_proxied_non_pre = 2, /* proxied, non pre-instantiable */
  53. clc_component_non_proxied_non_sa_aware = 3 /* non-proxied, non sa aware */
  54. };
  55. struct amf_si_assignment;
  56. struct amf_csi_assignment;
  57. struct amf_healthcheck;
  58. struct amf_cluster {
  59. /* Configuration Attributes */
  60. SaNameT name;
  61. int saAmfClusterStartupTimeout;
  62. SaNameT saAmfClusterClmCluster;
  63. /* Runtime Attributes */
  64. SaAmfAdminStateT saAmfClusterAdminState;
  65. /* Relations */
  66. struct amf_node *node_head;
  67. struct amf_application *application_head;
  68. /* Implementation */
  69. poll_timer_handle timeout_handle;
  70. };
  71. struct amf_node {
  72. /* Configuration Attributes */
  73. SaNameT name;
  74. SaNameT saAmfNodeClmNode;
  75. int saAmfNodeSuFailOverProb;
  76. SaUint32T saAmfNodeSuFailoverMax;
  77. SaBoolT saAmfNodeAutoRepair;
  78. SaBoolT saAmfNodeRebootOnInstantiationFailure;
  79. SaBoolT saAmfNodeRebootOnTerminationFailure;
  80. /* Runtime Attributes */
  81. SaAmfAdminStateT saAmfNodeAdminState;
  82. SaAmfOperationalStateT saAmfNodeOperState;
  83. /* Relations */
  84. struct amf_cluster *cluster;
  85. /* Implementation */
  86. struct amf_node *next;
  87. };
  88. struct amf_application {
  89. /* Configuration Attributes */
  90. SaNameT name;
  91. /* Runtime Attributes */
  92. SaAmfAdminStateT saAmfApplicationAdminState;
  93. SaUint32T saAmfApplicationCurrNumSG;
  94. /* Relations */
  95. struct amf_cluster *cluster;
  96. struct amf_sg *sg_head;
  97. struct amf_si *si_head;
  98. /* Implementation */
  99. char clccli_path[PATH_MAX];
  100. char binary_path[PATH_MAX];
  101. struct amf_application *next;
  102. };
  103. struct amf_sg {
  104. /* Configuration Attributes */
  105. SaNameT name;
  106. saAmfRedundancyModelT saAmfSGRedundancyModel;
  107. SaBoolT saAmfSGAutoAdjust;
  108. SaUint32T saAmfSGNumPrefActiveSUs;
  109. SaUint32T saAmfSGNumPrefStandbySUs;
  110. SaUint32T saAmfSGNumPrefInserviceSUs;
  111. SaUint32T saAmfSGNumPrefAssignedSUs;
  112. SaUint32T saAmfSGMaxActiveSIsperSUs;
  113. SaUint32T saAmfSGMaxStandbySIsperSUs;
  114. SaTimeT saAmfSGCompRestartProb;
  115. SaUint32T saAmfSGCompRestartMax;
  116. SaTimeT saAmfSGSuRestartProb;
  117. SaUint32T saAmfSGSuRestartMax;
  118. SaTimeT saAmfSGAutoAdjustProb;
  119. SaBoolT saAmfSGAutoRepair;
  120. /* Runtime Attributes */
  121. SaAmfAdminStateT saAmfSGAdminState;
  122. SaUint32T saAmfSGNumCurrAssignedSUs;
  123. SaUint32T saAmfSGNumCurrNonInstantiatedSpareSUs;
  124. SaUint32T saAmfSGNumCurrInstantiatedSpareSUs;
  125. /* Relations */
  126. struct amf_application *application;
  127. struct amf_su *su_head;
  128. /* Implementation */
  129. char clccli_path[PATH_MAX];
  130. char binary_path[PATH_MAX];
  131. struct amf_sg *next;
  132. };
  133. struct amf_su {
  134. /* Configuration Attributes */
  135. SaNameT name;
  136. SaUint32T saAmfSURank;
  137. SaUint32T saAmfSUNumComponents;
  138. SaBoolT saAmfSUIsExternal;
  139. SaBoolT saAmfSUFailover;
  140. /* Runtime Attributes */
  141. SaBoolT saAmfSUPreInstantiable;
  142. SaAmfOperationalStateT saAmfSUOperState;
  143. SaAmfAdminStateT saAmfSUAdminState;
  144. SaAmfReadinessStateT saAmfSUReadinessState;
  145. SaAmfPresenceStateT saAmfSUPresenceState;
  146. SaNameT saAmfSUAssignedSIs;
  147. SaNameT saAmfSUHostedByNode;
  148. SaUint32T saAmfSUNumCurrActiveSIs;
  149. SaUint32T saAmfSUNumCurrStandbySIs;
  150. SaUint32T saAmfSURestartCount;
  151. /* Relations */
  152. struct amf_sg *sg;
  153. struct amf_comp *comp_head;
  154. struct amf_si_assignment *assigned_sis;
  155. /* Implementation */
  156. int is_local;
  157. char clccli_path[PATH_MAX];
  158. char binary_path[PATH_MAX];
  159. SaUint32T su_failover_cnt; /* missing in SAF specs? */
  160. enum escalation_levels escalation_level;
  161. struct amf_su *next;
  162. };
  163. struct amf_comp {
  164. /* Configuration Attributes */
  165. SaNameT name;
  166. SaNameT **saAmfCompCsTypes;
  167. saAmfCompCategoryT saAmfCompCategory;
  168. saAmfCompCapabilityModelT saAmfCompCapability;
  169. SaUint32T saAmfCompNumMaxActiveCsi;
  170. SaUint32T saAmfCompNumMaxStandbyCsi;
  171. SaStringT *saAmfCompCmdEnv;
  172. int saAmfCompDefaultClcCliTimeout;
  173. int saAmfCompDefaultCallbackTimeOut;
  174. SaStringT saAmfCompInstantiateCmd;
  175. SaStringT saAmfCompInstantiateCmdArgv;
  176. int saAmfCompInstantiateTimeout;
  177. SaUint32T saAmfCompInstantiationLevel;
  178. SaUint32T saAmfCompNumMaxInstantiateWithoutDelay;
  179. SaUint32T saAmfCompNumMaxInstantiateWithDelay;
  180. int saAmfCompDelayBetweenInstantiateAttempts;
  181. SaStringT saAmfCompTerminateCmd;
  182. int saAmfCompTerminateTimeout;
  183. SaStringT saAmfCompTerminateCmdArgv;
  184. SaStringT saAmfCompCleanupCmd;
  185. int saAmfCompCleanupTimeout;
  186. SaStringT saAmfCompCleanupCmdArgv;
  187. SaStringT saAmfCompAmStartCmd;
  188. int saAmfCompAmStartTimeout;
  189. SaStringT saAmfCompAmStartCmdArgv;
  190. SaUint32T saAmfCompNumMaxAmStartAttempt;
  191. SaStringT saAmfCompAmStopCmd;
  192. int saAmfCompAmStopTimeout;
  193. SaStringT saAmfCompAmStopCmdArgv;
  194. SaUint32T saAmfCompNumMaxAmStopAttempt;
  195. int saAmfCompTerminateCallbackTimeout;
  196. int saAmfCompCSISetCallbackTimeout;
  197. int saAmfCompQuiescingCompleteTimeout;
  198. int saAmfCompCSIRmvCallbackTimeout;
  199. SaAmfRecommendedRecoveryT saAmfCompRecoveryOnError;
  200. SaBoolT saAmfCompDisableRestart;
  201. SaNameT saAmfCompProxyCsi;
  202. /* Runtime Attributes */
  203. SaAmfOperationalStateT saAmfCompOperState;
  204. SaAmfReadinessStateT saAmfCompReadinessState;
  205. SaAmfPresenceStateT saAmfCompPresenceState;
  206. SaUint32T saAmfCompRestartCount;
  207. SaUint32T saAmfCompNumCurrActiveCsi;
  208. SaUint32T saAmfCompNumCurrStandbyCsi;
  209. SaNameT saAmfCompAssignedCsi;
  210. SaNameT saAmfCompCurrProxyName;
  211. SaNameT saAmfCompCurrProxiedNames;
  212. /* Relations */
  213. struct amf_comp *proxy_comp;
  214. struct amf_su *su;
  215. struct amf_csi_assignment *assigned_csis;
  216. /* Implementation */
  217. char clccli_path[PATH_MAX];
  218. char binary_path[PATH_MAX];
  219. struct amf_comp *next;
  220. void *conn;
  221. enum clc_component_types comptype;
  222. struct amf_healthcheck *healthcheck_head;
  223. };
  224. struct amf_healthcheck {
  225. /* Configuration Attributes */
  226. SaAmfHealthcheckKeyT safHealthcheckKey;
  227. int saAmfHealthcheckMaxDuration;
  228. int saAmfHealthcheckPeriod;
  229. /* Relations */
  230. struct amf_comp *comp;
  231. /* Implementation */
  232. struct amf_healthcheck *next;
  233. SaAmfHealthcheckInvocationT invocationType;
  234. poll_timer_handle timer_handle_duration;
  235. poll_timer_handle timer_handle_period;
  236. int active;
  237. };
  238. struct amf_si {
  239. /* Configuration Attributes */
  240. SaNameT name;
  241. SaNameT saAmfSIProtectedbySG;
  242. SaUint32T saAmfSIRank;
  243. SaUint32T saAmfSINumCSIs;
  244. SaUint32T saAmfSIPrefActiveAssignments;
  245. SaUint32T saAmfSIPrefStandbyAssignments;
  246. /* Runtime Attributes */
  247. SaAmfAdminStateT saAmfSIAdminState;
  248. SaAmfAssignmentStateT saAmfSIAssignmentState;
  249. SaUint32T saAmfSINumCurrActiveAssignments;
  250. SaUint32T saAmfSINumCurrStandbyAssignments;
  251. /* Relations */
  252. struct amf_application *application;
  253. struct amf_csi *csi_head;
  254. struct amf_si_assignment *si_assignments;
  255. struct amf_si_dependency *depends_on;
  256. struct amf_si_ranked_su *ranked_sus;
  257. /* Implementation */
  258. struct amf_si *next;
  259. };
  260. struct amf_si_ranked_su {
  261. /* Configuration Attributes */
  262. SaNameT name;
  263. SaUint32T saAmfRank;
  264. /* Relations */
  265. struct amf_si *si;
  266. struct amf_su *su;
  267. /* Implementation */
  268. struct amf_si_ranked_su *su_next;
  269. struct amf_si_ranked_su *si_next;
  270. };
  271. struct amf_si_dependency {
  272. /* Configuration Attributes */
  273. SaNameT name;
  274. int saAmfToleranceTime;
  275. /* Relations */
  276. /* Implementation */
  277. struct amf_si_dependency *next;
  278. };
  279. struct amf_si_assignment {
  280. /* Runtime Attributes */
  281. SaNameT name;
  282. SaAmfHAStateT saAmfSISUHAState;
  283. /* Relations */
  284. struct amf_si *si;
  285. /* Implementation */
  286. struct amf_si_assignment *next;
  287. };
  288. struct amf_csi {
  289. /* Configuration Attributes */
  290. SaNameT name;
  291. SaNameT saAmfCSTypeName;
  292. SaNameT **saAmfCSIDependencies;
  293. /* Relations */
  294. struct amf_si *si;
  295. struct amf_csi_assignment *csi_assignments;
  296. struct amf_csi_attribute *attributes_head;
  297. /* Implementation */
  298. struct amf_csi *next;
  299. int pg_set;
  300. };
  301. struct amf_csi_attribute {
  302. /* Configuration Attributes */
  303. SaStringT name;
  304. SaStringT *value;
  305. /* Implementation */
  306. struct amf_csi_attribute *next;
  307. };
  308. struct amf_csi_assignment {
  309. /* Runtime Attributes */
  310. SaNameT name;
  311. SaAmfHAStateT saAmfCSICompHASate;
  312. /* Relations */
  313. struct amf_csi *csi;
  314. struct amf_comp *comp;
  315. /* Implementation */
  316. struct amf_csi_assignment *comp_next;
  317. struct amf_csi_assignment *csi_next;
  318. };
  319. extern struct amf_comp *amf_find_comp (struct amf_cluster *cluster, SaNameT *name);
  320. extern struct amf_healthcheck *amf_find_healthcheck (struct amf_comp *comp, SaAmfHealthcheckKeyT *key);
  321. extern int amf_config_read (struct amf_cluster *cluster, char **error_string);
  322. #endif /* AMFCONFIG_H_DEFINED */