bool RGWLifecycleConfiguration::_add_rule(const LCRule& rule)
{
- lc_op op;
+ lc_op op(rule.get_id());
op.status = rule.is_enabled();
if (rule.get_expiration().has_days()) {
op.expiration = rule.get_expiration().get_days();
|| !op.noncur_transitions.empty()));
}
+static inline bool has_all_tags(const lc_op& rule_action,
+ const RGWObjTags& object_tags)
+{
+ for (const auto& tag : object_tags.get_tags()) {
+
+ if (! rule_action.obj_tags)
+ return false;
+
+ const auto& rule_tags = rule_action.obj_tags->get_tags();
+ const auto& iter = rule_tags.find(tag.first);
+
+ if ((iter == rule_tags.end()) ||
+ (iter->second != tag.second))
+ return false;
+ }
+ /* all tags matched */
+ return true;
+}
+
class LCObjsLister {
RGWRados *store;
RGWBucketInfo& bucket_info;
return -EIO;
}
- if (!includes(dest_obj_tags.get_tags().begin(),
- dest_obj_tags.get_tags().end(),
- op.obj_tags->get_tags().begin(),
- op.obj_tags->get_tags().end())){
+ if (! has_all_tags(op, dest_obj_tags)) {
ldout(oc.cct, 20) << __func__ << "() skipping obj " << oc.obj << " as tags do not match" << dendl;
return 0;
}
}
-
int RGWLC::bucket_lc_process(string& shard_id)
{
RGWLifecycleConfiguration config(cct);
}
RGWRados::Bucket target(store, bucket_info);
- LCObjsLister ol(store, bucket_info);
map<string, bufferlist>::iterator aiter = bucket_attrs.find(RGW_ATTR_LC);
if (aiter == bucket_attrs.end())
} else {
pre_marker = next_marker;
}
+
+ LCObjsLister ol(store, bucket_info);
ol.set_prefix(prefix_iter->first);
ret = ol.init();
ldpp_dout(this, 20) << __func__ << "(): key=" << o.key << dendl;
int ret = orule.process(o, this);
if (ret < 0) {
- ldpp_dout(this, 20) << "ERROR: orule.process() returned ret=" << ret << dendl;
+ ldpp_dout(this, 20) << "ERROR: orule.process() returned ret="
+ << ret
+ << dendl;
}
if (going_down()) {
transition_action() : days(0) {}
};
+/* XXX why not LCRule? */
struct lc_op
{
+ string id;
bool status{false};
bool dm_expiration{false};
int expiration{0};
boost::optional<RGWObjTags> obj_tags;
map<string, transition_action> transitions;
map<string, transition_action> noncur_transitions;
-
+
+ /* ctors are nice */
+ lc_op() = delete;
+
+ lc_op(const std::string id) : id(id)
+ {}
+
void dump(Formatter *f) const;
};