MCPcopy Create free account
hub / github.com/Icinga/icinga2 / DisableFeatures

Method DisableFeatures

lib/cli/featureutility.cpp:118–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118int FeatureUtility::DisableFeatures(const std::vector<std::string>& features)
119{
120 String features_enabled_dir = GetFeaturesEnabledPath();
121
122 if (!Utility::PathExists(features_enabled_dir) ) {
123 Log(LogCritical, "cli")
124 << "Cannot disable features. Path '" << features_enabled_dir << "' does not exist.";
125 return 0;
126 }
127
128 std::vector<std::string> errors;
129
130 for (auto& feature : features) {
131 String target = features_enabled_dir + "/" + feature + ".conf";
132
133 if (!Utility::PathExists(target) ) {
134 Log(LogWarning, "cli")
135 << "Feature '" << feature << "' already disabled.";
136 continue;
137 }
138
139 if (unlink(target.CStr()) < 0) {
140 Log(LogCritical, "cli")
141 << "Cannot disable feature '" << feature << "'. Unlinking target file '" << target
142 << "' failed with error code " << errno << ", \"" + Utility::FormatErrorNumber(errno) << "\".";
143 errors.push_back(feature);
144 continue;
145 }
146
147 std::cout << "Disabling feature " << ConsoleColorTag(Console_ForegroundMagenta | Console_Bold) << feature
148 << ConsoleColorTag(Console_Normal) << ". Make sure to restart Icinga 2 for these changes to take effect.\n";
149 }
150
151 if (!errors.empty()) {
152 Log(LogCritical, "cli")
153 << "Cannot disable feature(s): " << boost::algorithm::join(errors, " ");
154 errors.clear();
155 return 1;
156 }
157
158 return 0;
159}
160
161int FeatureUtility::ListFeatures(std::ostream& os)
162{

Callers

nothing calls this directly

Calls 7

PathExistsFunction · 0.85
LogClass · 0.85
ConsoleColorTagClass · 0.85
CStrMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected