Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK fixes including CP-53003 #6210

Merged
merged 3 commits into from
Jan 13, 2025
Merged

SDK fixes including CP-53003 #6210

merged 3 commits into from
Jan 13, 2025

Conversation

kc284
Copy link
Contributor

@kc284 kc284 commented Jan 6, 2025

Commits best reviewed separately.

  • CP-53003: Use JsonRpc v1.0 by default and switch to v2.0 once the API version is known.
  • Removal of deprecated methods and unused internal methods.
  • Refactoring to fix some inefficiencies when loading and saving certificates in PS.

kc284 added 3 commits January 6, 2025 12:43
Signed-off-by: Konstantina Chremmou <[email protected]>
- Moved certificate methods to the Connect-XenServer cmdlet and refactored them to avoid multiple loads of the global variable KnownServerCertificatesFilePath.
- Fixed accessibility of CommonCmdletFunctions members.

Signed-off-by: Konstantina Chremmou <[email protected]>
… version is known.

Signed-off-by: Konstantina Chremmou <[email protected]>
/// Return a positive number if the given session's API version is greater than the given
/// API_version, negative if it is less, and 0 if they are equal.
/// </summary>
internal static int APIVersionCompare(Session session, API_Version v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove those functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are not visible outside the library because they are internal. Inside the library they are not used, which means they are not needed.
Now, if someone has implemented the SDK in the way XenCenter has, the methods might be in use, however, XC's design is not ideal and should not be encouraged because it leads to complicated code.


if (JsonRpcClient != null)
{
if (APIVersion == API_Version.API_2_6)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the default value is already "JsonRpcVersion.v1", do we need re-setting here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically someone could create the session object, change the JsonRpcVersion, and then call login_with_password which calls this method. In reality it's highly unlikely someone would do that, but I put the code there to be defensive.

@kc284 kc284 added this pull request to the merge queue Jan 13, 2025
Merged via the queue into xapi-project:master with commit 8c9b754 Jan 13, 2025
15 checks passed
edwintorok added a commit that referenced this pull request Jan 13, 2025
Continuing from #6208

The conflict resolution can be reviewed with:
`git log --remerge-diff -1 8b8af63`

```diff
diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/scheduler.ml b/ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/scheduler.ml
remerge CONFLICT (content): Merge conflict in ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/scheduler.ml
index 7bace30dae..27cf306995 100644
--- a/ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/scheduler.ml
+++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/scheduler.ml
@@ -33,49 +33,8 @@ let (queue : t Ipq.t) = Ipq.create 50 queue_default

 let lock = Mutex.create ()

-<<<<<<< 6589d9a (Xapi thread classification - part 2 (#6154))
 let add_to_queue_span name ty start_span newfunc =
   let ( ++ ) = Mtime.Span.add in
-||||||| 4f3f08f
-module Clock = struct
-  let span s = Mtime.Span.of_uint64_ns (Int64.of_float (s *. 1e9))
-
-  let span_to_s span =
-    Mtime.Span.to_uint64_ns span |> Int64.to_float |> fun ns -> ns /. 1e9
-
-  let add_span clock secs =
-    (* return mix or max available value if the add overflows *)
-    match Mtime.add_span clock (span secs) with
-    | Some t ->
-        t
-    | None when secs > 0. ->
-        Mtime.max_stamp
-    | None ->
-        Mtime.min_stamp
-end
-
-let add_to_queue name ty start newfunc =
-  let ( ++ ) = Clock.add_span in
-=======
-module Clock = struct
-  let span s = Mtime.Span.of_uint64_ns (Int64.of_float (s *. 1e9))
-
-  let span_to_s span = Mtime.Span.to_float_ns span |> fun ns -> ns /. 1e9
-
-  let add_span clock secs =
-    (* return mix or max available value if the add overflows *)
-    match Mtime.add_span clock (span secs) with
-    | Some t ->
-        t
-    | None when secs > 0. ->
-        Mtime.max_stamp
-    | None ->
-        Mtime.min_stamp
-end
-
-let add_to_queue name ty start newfunc =
-  let ( ++ ) = Clock.add_span in
->>>>>>> 8c9b754 (SDK fixes including CP-53003 (#6210))
   let item =
     {
       Ipq.ev= {func= newfunc; ty; name}
```

This code got deleted in `feature/perf`
6b02474, where `span_to_s` got replaced
with `Clock.Timer.span_to_s`, and changed in master by
e68cda7.
Both achieve the same result: `span_to_s` uses `Mtime.Span.to_float_ns`,
except the commit on feature/perf also removes code duplication by
reusing the other clock module.
@kc284 kc284 deleted the maintenance branch January 13, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants