Skip to content

Commit 38c0e28

Browse files
authored
Merge pull request xapi-project#4472 from xapi-project/private/linl/perf
CP-37549: Address subject-add performance issue
2 parents 2a708ac + bdfb5c7 commit 38c0e28

13 files changed

+314
-94
lines changed

ocaml/tests/test_extauth_plugin_ADwinbind.ml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ module ExtractOuConfig = Generic.MakeStateless (struct
3737
; ("service-name", "conappada.local")
3838
; ("ou", "TOU")
3939
]
40-
, ([("ou", "TOU")], ["createcomputer=TOU"]) )
40+
, ([("ou", "TOU")], ["createcomputer=TOU"])
41+
)
4142
]
4243
end)
4344

@@ -83,7 +84,8 @@ module ParseValueFromPbis = Generic.MakeStateless (struct
8384
`QuickAndAutoDocumented
8485
[
8586
( "X'58005200540055004B002D00300032002D003000330024000000'"
86-
, "XRTUK-02-03" )
87+
, "XRTUK-02-03"
88+
)
8789
; ("X'4C004F00430041004C0048004F0053005400320024000000'", "LOCALHOST2")
8890
]
8991
end)
@@ -135,7 +137,8 @@ let test_parse_wbinfo_uid_info =
135137
; uid= 3000003
136138
; gid= 3000174
137139
; gecos= {|ladmin|}
138-
} )
140+
}
141+
)
139142
; ( {|CONNAPP\locked:*:3000004:3000174::/home/CONNAPP/locked:/bin/bash|}
140143
, Ok
141144
{user_name= {|CONNAPP\locked|}; uid= 3000004; gid= 3000174; gecos= ""}
@@ -342,7 +345,8 @@ msDS-SupportedEncryptionTypes: 0|}
342345
; account_expired= false
343346
; account_locked= false
344347
; password_expired= false
345-
} )
348+
}
349+
)
346350
; ( stdout_locked
347351
, Ok
348352
{
@@ -353,7 +357,8 @@ msDS-SupportedEncryptionTypes: 0|}
353357
; account_expired= false
354358
; account_locked= true
355359
; password_expired= false
356-
} )
360+
}
361+
)
357362
; ( stdout_expired
358363
, Ok
359364
{
@@ -364,7 +369,8 @@ msDS-SupportedEncryptionTypes: 0|}
364369
; account_expired= true
365370
; account_locked= false
366371
; password_expired= false
367-
} )
372+
}
373+
)
368374
; ( stdout_krbtgt
369375
, Ok
370376
{
@@ -375,10 +381,12 @@ msDS-SupportedEncryptionTypes: 0|}
375381
; account_locked= false
376382
; account_expired= false
377383
; account_disabled= true
378-
} )
384+
}
385+
)
379386
; ("Got 0 replies", Error "ldap parsing failed ': got 0 replies'")
380387
; ( "complete garbage"
381-
, Error "ldap parsing failed 'unexpected header: string'" )
388+
, Error "ldap parsing failed 'unexpected header: string'"
389+
)
382390
]
383391
in
384392
matrix |> List.map @@ fun (inp, exp) -> ("<omit inp>", `Quick, check inp exp)
@@ -403,7 +411,8 @@ let test_wbinfo_exception_of_stderr =
403411
[
404412
( "failed to call wbcLookupName: WBC_ERR_DOMAIN_NOT_FOUND\x0ACould not \
405413
lookup name [email protected]\x0A"
406-
, Some (Auth_service_error (E_GENERIC, "WBC_ERR_DOMAIN_NOT_FOUND")) )
414+
, Some (Auth_service_error (E_GENERIC, "WBC_ERR_DOMAIN_NOT_FOUND"))
415+
)
407416
; ("garbage", None)
408417
]
409418
in
@@ -418,5 +427,6 @@ let tests =
418427
; ("ADwinbind:test_parse_wbinfo_uid_info", test_parse_wbinfo_uid_info)
419428
; ("ADwinbind:test_parse_ldap_stdout", test_parse_ldap_stdout)
420429
; ( "ADwinbind:test_wbinfo_exception_of_stderr"
421-
, test_wbinfo_exception_of_stderr )
430+
, test_wbinfo_exception_of_stderr
431+
)
422432
]

ocaml/tests/test_xapi_cmd_result.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module XapiCmdResult = Generic.MakeStateless (struct
3131
`QuickAndAutoDocumented
3232
[
3333
( (':', "Pre-Win2k Domain", "Pre-Win2k Domain: CONNAPP\nsome:other")
34-
, Some "CONNAPP" )
34+
, Some "CONNAPP"
35+
)
3536
; ((':', "Pre-Win2k Domain", "Not import msg"), None)
3637
]
3738
end)

ocaml/xapi-cli-server/cli_operations.ml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7088,15 +7088,10 @@ let subject_add printer rpc session_id params =
70887088
let subject_identifier =
70897089
Client.Auth.get_subject_identifier ~rpc ~session_id ~subject_name
70907090
in
7091-
(* obtains a list of name-value pairs with info about the subject from the external directory *)
7092-
let subject_info =
7093-
Client.Auth.get_subject_information_from_identifier ~rpc ~session_id
7094-
~subject_identifier
7095-
in
7096-
(* now we've got enough information to create our new subject in the pool *)
7091+
(* now we've got enough information to create our new subject in the pool
7092+
* Subject.create will query subject information basing on the subject identifier *)
70977093
let subject_ref =
7098-
Client.Subject.create ~rpc ~session_id ~subject_identifier
7099-
~other_config:subject_info
7094+
Client.Subject.create ~rpc ~session_id ~subject_identifier ~other_config:[]
71007095
in
71017096
let subject_uuid = Client.Subject.get_uuid rpc session_id subject_ref in
71027097
printer (Cli_printer.PList [subject_uuid])

ocaml/xapi/extauth.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module Ext_auth = struct
4747
(* the external authentication plugin *)
4848
| "AD" ->
4949
(*windows active directory*)
50-
Extauth_ad.methods()
50+
Extauth_ad.methods ()
5151
(* if no other auth_type fits, then we don't know what to do *)
5252
| _ as uat ->
5353
(*error*)
@@ -87,7 +87,11 @@ let get_event_params ~__context host =
8787
let service_name =
8888
Db.Host.get_external_auth_service_name ~__context ~self:host
8989
in
90-
[("auth_type", auth_type); ("service_name", service_name); ("ad_backend", !Xapi_globs.extauth_ad_backend)]
90+
[
91+
("auth_type", auth_type)
92+
; ("service_name", service_name)
93+
; ("ad_backend", !Xapi_globs.extauth_ad_backend)
94+
]
9195

9296
(* allows extauth hook script to be called only under specific conditions *)
9397
let can_execute_extauth_hook_script ~__context host event_name =

ocaml/xapi/extauth_ad.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ let init_service ~__context =
6969
|> AD_type.of_string
7070
|> AD.init_service ~__context
7171

72-
let methods() =
72+
let methods () =
7373
match !Xapi_globs.extauth_ad_backend |> AD_type.of_string with
7474
| Pbis ->
7575
Extauth_plugin_ADpbis.AuthADlw.methods

ocaml/xapi/extauth_plugin_ADpbis.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ let lwsmd_service = "lwsmd"
2727
module Lwsmd = struct
2828
let is_ad_enabled ~__context =
2929
( Helpers.get_localhost ~__context |> fun self ->
30-
Db.Host.get_external_auth_type ~__context ~self )
30+
Db.Host.get_external_auth_type ~__context ~self
31+
)
3132
|> fun x -> x = Xapi_globs.auth_type_AD
3233

3334
let enable_nsswitch () =
@@ -119,7 +120,9 @@ let start_damon () =
119120
raise
120121
(Auth_signature.Auth_service_error
121122
( Auth_signature.E_GENERIC
122-
, Printf.sprintf "Failed to start %s" lwsmd_service ))
123+
, Printf.sprintf "Failed to start %s" lwsmd_service
124+
)
125+
)
123126

124127
module AuthADlw : Auth_signature.AUTH_MODULE = struct
125128
(*

0 commit comments

Comments
 (0)