Resolve domain_name overwrite on startup issue

This commit is contained in:
William Brown 2019-12-01 15:16:56 +10:00
parent 7fcb0e6069
commit 646261ebf7
2 changed files with 12 additions and 8 deletions

View file

@ -456,8 +456,7 @@ pub static JSON_DOMAIN_INFO_V1: &'static str = r#"{
"class": ["object", "domain_info", "system"], "class": ["object", "domain_info", "system"],
"name": ["domain_local"], "name": ["domain_local"],
"uuid": ["00000000-0000-0000-0000-ffffff000025"], "uuid": ["00000000-0000-0000-0000-ffffff000025"],
"description": ["This local domain's info and metadata object."], "description": ["This local domain's info and metadata object."]
"domain_name": ["example.com"]
} }
}"#; }"#;

View file

@ -34,12 +34,17 @@ impl Plugin for Domain {
) -> Result<(), OperationError> { ) -> Result<(), OperationError> {
audit_log!(au, "Entering base pre_create_transform"); audit_log!(au, "Entering base pre_create_transform");
cand.iter_mut().for_each(|e| { cand.iter_mut().for_each(|e| {
if e.attribute_value_pres("class", &PVCLASS_DOMAIN_INFO) if e.attribute_value_pres("class", &PVCLASS_DOMAIN_INFO) {
&& !e.attribute_pres("domain_uuid") if !e.attribute_pres("domain_uuid") {
{ let u = Value::new_uuid(Uuid::new_v4());
let u = Value::new_uuid(Uuid::new_v4()); e.set_avas("domain_uuid", vec![u]);
e.set_avas("domain_uuid", vec![u]); audit_log!(au, "plugin_domain: Applying uuid transform");
audit_log!(au, "plugin_domain: Applying uuid transform"); }
if !e.attribute_pres("domain_name") {
let n = Value::new_iutf8s("example.com");
e.set_avas("domain_name", vec![n]);
audit_log!(au, "plugin_domain: Applying domain_name transform");
}
audit_log!(au, "{:?}", e); audit_log!(au, "{:?}", e);
} }
}); });