# radosgw-admin script-package add --package={package name} [--allow-compilation]
+To add a specific version of a package to the allowlist:
+
+::
+
+ # radosgw-admin script-package add --package='{package name} {package version}' [--allow-compilation]
+
+
+* When adding a diffrent version of a package which already exists in the list, the newly
+ added version will override the existing one.
+
+* When adding a package without a version specified, the latest version of the package
+ will be added.
+
+
To remove a package from the allowlist:
::
# radosgw-admin script-package rm --package={package name}
+To remove a specific version of a package from the allowlist:
+
+::
+
+ # radosgw-admin script-package rm --package='{package name} {package version}'
+
+
+* When removing a package without a version specified, any existing versions of the
+ package will be removed.
+
+
To print the list of packages in the allowlist:
::
return -EINVAL;
}
+ //replace previous versions of the package
+ const std::string package_name_no_version = package_name.substr(0, package_name.find(" "));
+ ret = remove_package(dpp, store, y, package_name_no_version);
+ if (ret < 0) {
+ return ret;
+ }
+
// add package to list
const bufferlist empty_bl;
std::map<std::string, bufferlist> new_package{{package_name, empty_bl}};
int remove_package(const DoutPrefixProvider *dpp, rgw::sal::Store* store, optional_yield y, const std::string& package_name) {
librados::ObjectWriteOperation op;
- op.omap_rm_keys(std::set<std::string>({package_name}));
- const auto ret = rgw_rados_operate(dpp, *(static_cast<rgw::sal::RadosStore*>(store)->getRados()->get_lc_pool_ctx()),
- PACKAGE_LIST_OBJECT_NAME, &op, y);
-
- if (ret < 0) {
+ size_t pos = package_name.find(" ");
+ if (pos != string::npos) {
+ // remove specfic version of the the package
+ op.omap_rm_keys(std::set<std::string>({package_name}));
+ auto ret = rgw_rados_operate(dpp, *(static_cast<rgw::sal::RadosStore*>(store)->getRados()->get_lc_pool_ctx()),
+ PACKAGE_LIST_OBJECT_NAME, &op, y);
+ if (ret < 0) {
+ return ret;
+ }
+ return 0;
+ }
+ // otherwise, remove any existing versions of the package
+ packages_t packages;
+ auto ret = list_packages(dpp, store, y, packages);
+ if (ret < 0 && ret != -ENOENT) {
return ret;
}
-
+ for(const auto& package : packages) {
+ const std::string package_no_version = package.substr(0, package.find(" "));
+ if (package_no_version.compare(package_name) == 0) {
+ op.omap_rm_keys(std::set<std::string>({package}));
+ ret = rgw_rados_operate(dpp, *(static_cast<rgw::sal::RadosStore*>(store)->getRados()->get_lc_pool_ctx()),
+ PACKAGE_LIST_OBJECT_NAME, &op, y);
+ if (ret < 0) {
+ return ret;
+ }
+ }
+ }
return 0;
}
// the lua rocks install dir will be created by luarocks the first time it is called
for (const auto& package : packages) {
bp::ipstream is;
- bp::child c(p, "install", "--lua-version", CEPH_LUA_VERSION, "--tree", luarocks_path, "--deps-mode", "one", package,
- bp::std_in.close(),
- (bp::std_err & bp::std_out) > is);
+ const auto cmd = p.string() + " install --lua-version " + CEPH_LUA_VERSION + " --tree " + luarocks_path + " --deps-mode one " + package;
+ bp::child c(cmd, bp::std_in.close(), (bp::std_err & bp::std_out) > is);
// once package reload is supported, code should yield when reading output
- std::string line = "CMD: luarocks install --lua-version " + std::string(CEPH_LUA_VERSION) + std::string(" --tree ") +
- luarocks_path + " --deps-mode one " + package;
+ std::string line = std::string("CMD: ") + cmd;
do {
if (!line.empty()) {