summaryrefslogtreecommitdiffstats
path: root/src/include/usr/targeting/common/associationmanager.H
blob: 306d6f79abe6969fbc8ca7ba252f6345599731fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/targeting/common/associationmanager.H $       */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef ASSOCIATIONMANAGER_H
#define ASSOCIATIONMANAGER_H

#include <targeting/common/error.H>
#include <targeting/common/target.H>
#include <targeting/common/targetservice.H>

namespace TARGETING
{

class AssociationManager
{
    public:

    /**
     *  @brief Links system targets to node targets via associations, and vice
     *       versa
     *
     *  @par Detailed Description:
     *      Links system targets to node targets via associations, and vice
     *      versa.  Should be called any time targeting is brought up, as well
     *      as whenever the master system target changes.  Any existing
     *      associations between system and node targets (any variety) are
     *      first discarded.  Should only be attempted when other targeting
     *      operations are quiesced (i.e. exclusive mode).
     *
     *  @return Error log handle indicating the status of the request
     *
     *  @retval nullptr Relinked node and system targets with associations
     *  @retval !nullptr Failed to relink the node and system targets with
     *      associations.
     *
     *      Error log handle points to a valid error log object whose
     *      primary SRC reason code (pError->getSRC()->reasonCode())
     *      indicates the type of error.  This API may return one
     *      of the following "special" reason codes:
     *          N/A
     *
     *  @note It is up to the caller to change the severity of the
     *      returned error based on what it decides to do with it.  By
     *      default any returned error created by this function will
     *      be a non-reported tracing event error log.
     */
    static errlHndl_t reconnectSyAndNodeTargets();

    private:

    /**
     *  @brief Clears assocations of requested type from a system or node target
     *
     *  @par Detailed Description:
     *      For the specified target and association type, clears all
     *      association links that are configured.  Used to clear association
     *      entries in preparation for cross linking nodes to the master system
     *      target (and vice versa).  Relies on association data being
     *      copy-on-write memory mapped.   Any input error will assert, as this
     *      is designed to be used in a well controlled way as a helper
     *      function.  All other errors will return error log handles.
     *
     *  @param[in] i_assocType
     *      Type of association link to clear from input target (supports parent
     *      by containment and parent by affinity for node input targets, and
     *      child by affinity and child by containment for system input
     *      targets).  Asserts if unsupported association type/target combo
     *      specified.
     *  @param[in] i_pSourceSysOrNodeTarget
     *      Pointer to target to clear the associations from.  Must not be
     *      nullptr (asserts in that case).  Must be a node (any variety) or
     *      system target.
     *
     *  @return Error log handle indicating the status of the request
     *
     *  @retval nullptr Cleared the associations from the source target
     *  @retval !nullptr Failed to clear the associations from the source target
     *
     *      Error log handle points to a valid error log object whose
     *      primary SRC reason code (pError->getSRC()->reasonCode())
     *      indicates the type of error.  This API may return one
     *      of the following "special" reason codes:
     *          N/A
     *
     *  @note It is up to the caller to change the severity of the
     *      returned error based on what it decides to do with it.  By
     *      default any returned error created by this function will
     *      be a non-reported tracing event error log.
     *
     *  @pre Should only be called by reconnectSysAndNodeTargets function
     *  @pre Assumes changed memory area is in a copy-on-write memory mapping
     */
    static errlHndl_t _clearAssocsOfTypeFromSysOrNodeTarget(
        const TargetService::ASSOCIATION_TYPE i_assocType,
              Target* const                   i_pSourceSysOrNodeTarget);

    /**
     *  @brief Adds an association of a given type to a source target, pointing
     *      to a given destination target
     *
     *  @par Detailed Description:
     *      Adds an association of a given type to a source target, pointing to
     *      a given destination target.  A common pointer to the destination
     *      target is registered in the association list of the given type, for
     *      the given source target.  Only node and system targets can be linked
     *      in this fashion, and source/destination must be different types.
     *      Any input error will assert, as this is designed to be used in a
     *      well controlled way as a helper function.  All other errors will
     *      return error log handles.
     *
     *  @param[in] i_assocType
     *      Type of association link to add to input target (supports parent by
     *      containment and parent by affinity for node input targets, and child
     *      by affinity and child by containment for system input targets).
     *      Asserts if unsupported association type/target combo specified.
     *  @param[in] i_pSourceSysOrNodeTarget
     *      Pointer to target to add the associations to.  Must not be nullptr
     *      (asserts in that case).  Must be a node (any variety) or system
     *      target. If node target, the i_pDestTarget must refer to a system
     *      target. If system target, the i_pDestTarget must refer to a node
     *      target.
     *  @param[in] i_pDestSysOrNodeTarget
     *      Pointer to target to be linked to.  Must not be nullptr
     *      (asserts in that case).  Must be a node (any variety) or system
     *      target.  If node target, the source target must refer to a system
     *      target.  If system target, the source target must refer to a node
     *      target.
     *
     *  @return Error log handle indicating the status of the request
     *
     *  @retval nullptr Added the association to the source target (points to
     *      destination target)
     *  @retval !nullptr Failed to add the association
     *
     *      Error log handle points to a valid error log object whose
     *      primary SRC reason code (pError->getSRC()->reasonCode())
     *      indicates the type of error.  This API may return one
     *      of the following "special" reason codes:
     *          N/A
     *
     *  @note It is up to the caller to change the severity of the
     *      returned error based on what it decides to do with it.  By
     *      default any returned error created by this function will
     *      be a non-reported tracing event error log.
     *
     *  @pre Should only be called by reconnectSysAndNodeTargets function
     *  @pre Assumes changed memory area is in a copy-on-write memory mapping
     */
    static errlHndl_t _addAssocToSysOrNodeTarget(
        const TargetService::ASSOCIATION_TYPE i_assocType,
              Target* const                   i_pSourceSysOrNodeTarget,
        const Target* const                   i_pDestSysOrNodeTarget);

    // Disable copy constructor
    AssociationManager(const AssociationManager& i_other);

    // Disable assignment operator
    AssociationManager& operator=(const AssociationManager& i_other);

    // Disable CTOR
    AssociationManager();

    // Disable DTOR
    ~AssociationManager();
};

} //End namespace TARGETING
#endif //ASSOCIATIONMANAGER_H
OpenPOWER on IntegriCloud