-
Notifications
You must be signed in to change notification settings - Fork 281
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
[OIL] Templatization of PS Remove-Xen* cmdlets. Refactoring of HTTP_actions.mustache #5554
Open
kc284
wants to merge
2
commits into
xapi-project:master
Choose a base branch
from
kc284:private/konstantin1/sdk-ps
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -100,7 +100,9 @@ let rec main () = | |||||||||||||||||||||||||||||||
let cmdlets = | ||||||||||||||||||||||||||||||||
classes |> List.filter generated |> List.map gen_cmdlets |> List.concat | ||||||||||||||||||||||||||||||||
in | ||||||||||||||||||||||||||||||||
List.iter (fun x -> write_file x.filename x.content) cmdlets | ||||||||||||||||||||||||||||||||
List.iter (fun x -> write_file x.filename x.content) cmdlets ; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
classes |> List.filter generated |> List.iter gen_destructor | ||||||||||||||||||||||||||||||||
Comment on lines
100
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
(****************) | ||||||||||||||||||||||||||||||||
(* Http actions *) | ||||||||||||||||||||||||||||||||
|
@@ -178,11 +180,6 @@ and gen_cmdlets obj = | |||||||||||||||||||||||||||||||
; content= | ||||||||||||||||||||||||||||||||
gen_constructor obj classname (List.filter is_constructor messages) | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
; { | ||||||||||||||||||||||||||||||||
filename= sprintf "Remove-Xen%s.cs" stem | ||||||||||||||||||||||||||||||||
; content= | ||||||||||||||||||||||||||||||||
gen_destructor obj classname (List.filter is_destructor messages) | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
; { | ||||||||||||||||||||||||||||||||
filename= sprintf "Remove-Xen%sProperty.cs" stem | ||||||||||||||||||||||||||||||||
; content= gen_remover obj classname (List.filter is_remover messages) | ||||||||||||||||||||||||||||||||
|
@@ -598,84 +595,35 @@ and convert_from_hashtable fname ty = | |||||||||||||||||||||||||||||||
(************************************) | ||||||||||||||||||||||||||||||||
(* Print function for Remove-XenFoo *) | ||||||||||||||||||||||||||||||||
(************************************) | ||||||||||||||||||||||||||||||||
and gen_destructor obj classname messages = | ||||||||||||||||||||||||||||||||
match messages with | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
and gen_destructor obj = | ||||||||||||||||||||||||||||||||
let {name= classname; messages; _} = obj in | ||||||||||||||||||||||||||||||||
let destructors = List.filter is_destructor messages in | ||||||||||||||||||||||||||||||||
match destructors with | ||||||||||||||||||||||||||||||||
| [] -> | ||||||||||||||||||||||||||||||||
"" | ||||||||||||||||||||||||||||||||
() | ||||||||||||||||||||||||||||||||
| [x] -> | ||||||||||||||||||||||||||||||||
let cut_message_name x = cut_msg_name (pascal_case x.msg_name) "Remove" in | ||||||||||||||||||||||||||||||||
let asyncMessages = | ||||||||||||||||||||||||||||||||
List.map cut_message_name (List.filter (fun x -> x.msg_async) messages) | ||||||||||||||||||||||||||||||||
let json = | ||||||||||||||||||||||||||||||||
`O | ||||||||||||||||||||||||||||||||
[ | ||||||||||||||||||||||||||||||||
("type", `String (qualified_class_name classname)) | ||||||||||||||||||||||||||||||||
; ("wire_class_name", `String (exposed_class_name classname)) | ||||||||||||||||||||||||||||||||
; ("class_name", `String (ocaml_class_to_csharp_class classname)) | ||||||||||||||||||||||||||||||||
; ("property", `String (ocaml_class_to_csharp_property classname)) | ||||||||||||||||||||||||||||||||
; ("type_local", `String (ocaml_class_to_csharp_local_var classname)) | ||||||||||||||||||||||||||||||||
; ("async", `Bool x.msg_async) | ||||||||||||||||||||||||||||||||
; ("has_uuid", `Bool (has_uuid obj)) | ||||||||||||||||||||||||||||||||
; ("has_name", `Bool (has_name obj)) | ||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||
in | ||||||||||||||||||||||||||||||||
sprintf | ||||||||||||||||||||||||||||||||
"%s\n\n\ | ||||||||||||||||||||||||||||||||
using System;\n\ | ||||||||||||||||||||||||||||||||
using System.Collections;\n\ | ||||||||||||||||||||||||||||||||
using System.Collections.Generic;\n\ | ||||||||||||||||||||||||||||||||
using System.Management.Automation;\n\ | ||||||||||||||||||||||||||||||||
using XenAPI;\n\n\ | ||||||||||||||||||||||||||||||||
namespace Citrix.XenServer.Commands\n\ | ||||||||||||||||||||||||||||||||
{\n\ | ||||||||||||||||||||||||||||||||
\ [Cmdlet(VerbsCommon.Remove, \"Xen%s\", SupportsShouldProcess = \ | ||||||||||||||||||||||||||||||||
true)]\n\ | ||||||||||||||||||||||||||||||||
\ [OutputType(typeof(%s))]%s\n\ | ||||||||||||||||||||||||||||||||
\ [OutputType(typeof(void))]\n\ | ||||||||||||||||||||||||||||||||
\ public class RemoveXen%s : XenServerCmdlet\n\ | ||||||||||||||||||||||||||||||||
\ {\n\ | ||||||||||||||||||||||||||||||||
\ #region Cmdlet Parameters\n\n\ | ||||||||||||||||||||||||||||||||
\ [Parameter]\n\ | ||||||||||||||||||||||||||||||||
\ public SwitchParameter PassThru { get; set; }\n\ | ||||||||||||||||||||||||||||||||
%s%s\n\ | ||||||||||||||||||||||||||||||||
\ #endregion\n\n\ | ||||||||||||||||||||||||||||||||
\ #region Cmdlet Methods\n\n\ | ||||||||||||||||||||||||||||||||
\ protected override void ProcessRecord()\n\ | ||||||||||||||||||||||||||||||||
\ {\n\ | ||||||||||||||||||||||||||||||||
\ GetSession();\n\n\ | ||||||||||||||||||||||||||||||||
\ string %s = Parse%s();\n\n\ | ||||||||||||||||||||||||||||||||
\ %s\n\n\ | ||||||||||||||||||||||||||||||||
\ UpdateSessions();\n\ | ||||||||||||||||||||||||||||||||
\ }\n\n\ | ||||||||||||||||||||||||||||||||
\ #endregion\n\n\ | ||||||||||||||||||||||||||||||||
\ #region Private Methods\n\ | ||||||||||||||||||||||||||||||||
%s%s\n\ | ||||||||||||||||||||||||||||||||
\ #endregion\n\ | ||||||||||||||||||||||||||||||||
\ }\n\ | ||||||||||||||||||||||||||||||||
}\n" | ||||||||||||||||||||||||||||||||
Licence.bsd_two_clause | ||||||||||||||||||||||||||||||||
(ocaml_class_to_csharp_class classname) | ||||||||||||||||||||||||||||||||
(qualified_class_name classname) | ||||||||||||||||||||||||||||||||
( if List.length asyncMessages > 0 then | ||||||||||||||||||||||||||||||||
"\n [OutputType(typeof(XenAPI.Task))]" | ||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||
"" | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
(ocaml_class_to_csharp_class classname) | ||||||||||||||||||||||||||||||||
(print_xenobject_params obj classname true true true) | ||||||||||||||||||||||||||||||||
( if List.length asyncMessages > 0 then | ||||||||||||||||||||||||||||||||
sprintf | ||||||||||||||||||||||||||||||||
"\n\ | ||||||||||||||||||||||||||||||||
\ protected override bool GenerateAsyncParam\n\ | ||||||||||||||||||||||||||||||||
\ {\n\ | ||||||||||||||||||||||||||||||||
\ get { return true; }\n\ | ||||||||||||||||||||||||||||||||
\ }\n" | ||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||
"" | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
(ocaml_class_to_csharp_local_var classname) | ||||||||||||||||||||||||||||||||
(ocaml_class_to_csharp_property classname) | ||||||||||||||||||||||||||||||||
(print_cmdlet_methods_remover classname x) | ||||||||||||||||||||||||||||||||
(print_parse_xenobject_private_method obj classname true) | ||||||||||||||||||||||||||||||||
(print_process_record_private_methods classname messages "Remove" | ||||||||||||||||||||||||||||||||
"asyncpassthru" | ||||||||||||||||||||||||||||||||
render_file | ||||||||||||||||||||||||||||||||
( "Remove-XenObject.mustache" | ||||||||||||||||||||||||||||||||
, sprintf "Remove-Xen%s.cs" (ocaml_class_to_csharp_class classname) | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
json templdir destdir | ||||||||||||||||||||||||||||||||
| _ -> | ||||||||||||||||||||||||||||||||
assert false | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
and print_cmdlet_methods_remover classname message = | ||||||||||||||||||||||||||||||||
let localVar = ocaml_class_to_csharp_local_var classname in | ||||||||||||||||||||||||||||||||
let cut_message_name x = cut_msg_name (pascal_case x.msg_name) "Remove" in | ||||||||||||||||||||||||||||||||
sprintf "ProcessRecord%s(%s);" (cut_message_name message) localVar | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
(*****************************************) | ||||||||||||||||||||||||||||||||
(* Print function for Remove-XenFoo -Bar *) | ||||||||||||||||||||||||||||||||
(*****************************************) | ||||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe below is little better: