Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation Jeffrey Snover.

Similar presentations


Presentation on theme: "1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation Jeffrey Snover."— Presentation transcript:

1 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Session Code: ARC-334

2 2 Make the connection Kernel Mode Framework Models Base Services Kernel Hardware Abstraction Layer Base Operating System Services CLR Health & Instrumentation Management Services System.Management.Instrumentation System.Management System.Diagnostics System.Diagnostics.Events System.Management.Monitoring Task & Automation System.Management.TaskScheduler System.Management.Automation System.Management.TaskScheduler.UI Settings & Configuration System.Configuration.Settings

3 3 Windows DSI Architecture (ARC230) Design for Operations Dynamic System Services SDM Store Dynamic Data Center STORAGESERVERSNETWORKING Settings ARC333 Tasks ARC334 Health ARC332 Hardware Managed Node Managed System Management Tools Dev Tools Local Node Mgmt System Level Management Remote Node Mgmt Your Application Your System Definition SDM Service

4 4 Task-Based Management Abstractions match activities of the user Add a user – canonical example Create account in AD Create home directory Add to Groups Customer-specific setup … Surfaced to enable automation Requires command line access! Abstractions match activities of the user Add a user – canonical example Create account in AD Create home directory Add to Groups Customer-specific setup … Surfaced to enable automation Requires command line access!

5 5 Introduction Weak cmd shell Weak language spotty coverage GUI focus Hard to automate SDK Focus Programmers Weak cmd shell Weak language spotty coverage GUI focus Hard to automate SDK Focus Programmers Foundation for task- based management Focused on power users and admins Provides: Interactive shell Cmdlets Utilities Scripting language Remote scripting Solution: MSH Problem

6 6 MSH Elements Core concepts Pipelines and utilities Parameters and confirmation Records and errors Navigation Core concepts Pipelines and utilities Parameters and confirmation Records and errors Navigation

7 7 Core Concepts Command line scripting language Best of sh/ksh, Perl/Ruby, DCL/CL Commands are classes (Cmdlets) Hosting model Command line scripting language Best of sh/ksh, Perl/Ruby, DCL/CL Commands are classes (Cmdlets) Hosting model

8 8 … using public class { public override void { (Process.GetProcesses()); } System.Management.Automation Commands Are Classes GetPs : Cmdlet [CmdletDeclaration("get", "ps")] WriteObjects StartProcessing()

9 9 Cmdlets Or … What Do I Get For 5 Lines Of Code? James Truher MSH Program Manager jimtru@microsoft.com

10 10 How It Works AutoRegistration Parser maps to your DLL MSH manages the DLL and Class lifecycle AutoRegistration Parser maps to your DLL MSH manages the DLL and Class lifecycle

11 11 Pipeline And Utilities Concepts  Pipelines are Cmdlets passing structured objects  Reflection-based utility Cmdlets  Pipelines are Cmdlets passing structured objects  Reflection-based utility Cmdlets

12 12 Pipeline & Utilities Or… Was That All I Got For 5 Lines Of Code? James Truher MSH Program Manager jimtru@microsoft.com

13 13 How It Works get/process | where “handlecount –gt 500” | sort handlecount | format/table GetProces s Class Common MSH Parser MSH Pipeline Processor Where Class Sort Class Format Class

14 14 CLIs And GUIs Not either/or Admins need more than GUIs typically deliver Planning & review Guaranteed consistency Massive productivity You need to support both Not either/or Admins need more than GUIs typically deliver Planning & review Guaranteed consistency Massive productivity You need to support both Background

15 15 Composable Management Traditional Model A | B | C Tight coupling between Parse, Get, Process, Output Relies on parsing text.NET allows us to do better Finer grain pipeline Objects instead of text Traditional Model A | B | C Tight coupling between Parse, Get, Process, Output Relies on parsing text.NET allows us to do better Finer grain pipeline Objects instead of text Background

16 16 Cost Benefits # of Functions Traditional Model Economics Costs: Dev Test Training MSH Common Engine combined with Utility Cmdlets New Model Background

17 17 Glide Path ShowScript Reflection Background GUI Cmd VS

18 18 MMC or… How Do GUIs Work With This? Mark Hong MMC Dev Lead markhong@microsoft.com

19 19 Parameter And Confirmation Concepts Common parser Driven by fields/properties + attributes Use Confirmation model Common parser Driven by fields/properties + attributes Use Confirmation model

20 20 Parameters And Confirmation [CommandDeclaration("stop", "ps")] public class StopPs: Cmdlet { public string ProcessName; public override void ProcessRecord() { Process [ ]ps; ps = Process.GetProcessesByName(ProcessName); foreach (Process p in ps) { p.Kill(); } [CommandDeclaration("stop", "ps")] public class StopPs: Cmdlet { public string ProcessName; public override void ProcessRecord() { Process [ ]ps; ps = Process.GetProcessesByName(ProcessName); foreach (Process p in ps) { p.Kill(); } [ParsingMandatoryParameter] [ParsingPromptString(“Name of the process")] if (ConfirmProcessing(p.ProcessName))

21 21 Parameters/Confirmation Or… So What Do Those 3 Lines Of Code Get Me? James Truher MSH Program Manager jimtru@microsoft.com

22 22 How It Works Parameter Attributes PrerequisiteMachineRole PrerequisiteUserRole PrerequisteScript PrerequisiteUIType ParsingParameter ParsingAllowPipelineInput ParsingParameterMapping ParsingVariableLengthParameterLi st ParsingInteraction PrerequisiteMachineRole PrerequisiteUserRole PrerequisteScript PrerequisiteUIType ParsingParameter ParsingAllowPipelineInput ParsingParameterMapping ParsingVariableLengthParameterLi st ParsingInteraction ParsingPasswordParameter ParsingPromptString ValidationRange ValidationLength ValidationCount ValidationFileAttributes ValidationNetworkAttribute ValidationPattern ExpandWildcards PredicatesParsing Data Validation Data GenerationData Presentation

23 23 How It Works public bool ConfirmProcessing(string Action) { } if (Confirm) { return Prompt(Action + “Continue [y/n/!]”); } if (Whatif) { WriteLine(“# “ + Action); return false } if (Confirm) { return Prompt(Action + “Continue [y/n/!]”); } if (Verbose) { Writeline(Action); return true; } if (Whatif) { WriteLine(“# “ + Action); return false } Pseudo-code

24 24 Records And Errors Concepts  MSH is Record oriented Records come from the Cmdline or the PipeLine Parameters define or contribute to a record Pipeline objects are processed into Records  Errors are first class citizens Policy driven error handling  MSH is Record oriented Records come from the Cmdline or the PipeLine Parameters define or contribute to a record Pipeline objects are processed into Records  Errors are first class citizens Policy driven error handling

25 25 [CommandDeclaration("format", "ps")] public class FormatPs: Command { public string ProcessName; public int HandleCount; public override void StartProcessing() { WriteObject(“Caution – data may be false”); } public override void EndProcessing() { WriteObject(“Done”)); } [CommandDeclaration("format", "ps")] public class FormatPs: Command { public string ProcessName; public int HandleCount; public override void StartProcessing() { WriteObject(“Caution – data may be false”); } public override void EndProcessing() { WriteObject(“Done”)); } Record Orientation public override void ProcessRecord() { WriteObject( ProcessName + “:” + HandleCount ); } public override void ProcessRecord() { WriteObject( ProcessName + “:” + HandleCount ); } if (record++ > 5 && record < 10) WriteErrorObject(CurrentPipelineObject, new Exception("Invalid record")); [ParsingAllowPipelineInput]

26 26 Records And Errors Or … Why This Isn’t Like Your Dad’s Shell James Truher MSH Program Manager jimtru@microsoft.com

27 27 How It Works StartProcessing() for each object Pipeline Convert object into a record Apply command line params ProcessRecord() EndProcessing() StartProcessing() for each object Pipeline Convert object into a record Apply command line params ProcessRecord() EndProcessing()

28 28 Ubiquitous Navigation FileSystems are easy to use Navigation and manipulation are universal Other stores are hard Require domain-specific utilties and concepts How do we make other stores easy? Interact with them like FileSystems FileSystems are easy to use Navigation and manipulation are universal Other stores are hard Require domain-specific utilties and concepts How do we make other stores easy? Interact with them like FileSystems

29 29 Navigation Provider Concepts  You Subclass and we provide the Cmdlets Dir, cd, pushd, popd, cat, delete, rename, copy, clear,  Providers need to be registered  Requests to providers are stateless and use absolute names  You Subclass and we provide the Cmdlets Dir, cd, pushd, popd, cat, delete, rename, copy, clear,  Providers need to be registered  Requests to providers are stateless and use absolute names

30 30 Navigation Provider [ProviderDeclaration("REG", "Registry", ProviderCapabilityFlags.None)] public class RegistryProvider : NavigationCmdletBase { protected override void GetItem(string path) { RegistryKey key = GetRegkeyForPath(path, false); if (key == null) { WriteErrorObject(path, new ArgumentException("does not exist")); } WriteObject(key); }.... } [ProviderDeclaration("REG", "Registry", ProviderCapabilityFlags.None)] public class RegistryProvider : NavigationCmdletBase { protected override void GetItem(string path) { RegistryKey key = GetRegkeyForPath(path, false); if (key == null) { WriteErrorObject(path, new ArgumentException("does not exist")); } WriteObject(key); }.... }

31 31 Navigation Provider – Or What Whackball Would Treat Registry Like A Filesystem? James Truher MSH Program Manager jimtru@microsoft.com

32 32 How It Works MSH Engine Core Command Base Classes Core Commands (get, set, rename, move, push, pop, …) FileSys Provider Cmdlet … Registry Provider AD Provider

33 33 Longhorn Command Shell (MSH) Preview Available on http://betaplace.com Use the guest account: mshPDChttp://betaplace.com Logon and password emailed within 24 hours Download bits, SDK, samples, private newsgroup and a feedback/bug reporting environment. Available on http://betaplace.com Use the guest account: mshPDChttp://betaplace.com Logon and password emailed within 24 hours Download bits, SDK, samples, private newsgroup and a feedback/bug reporting environment.

34 34 Call To Action  Write managed code interfaces to your services and objects  Design your task model  Write Cmdlets for invariant actions  Write MSH scripts for actions which vary between customers  Write Navigation providers to expose namespaces  Write managed code interfaces to your services and objects  Design your task model  Write Cmdlets for invariant actions  Write MSH scripts for actions which vary between customers  Write Navigation providers to expose namespaces

35 35 HAPPY BIRTHDAY To JIM TRUHER

36 36 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

37


Download ppt "1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation Jeffrey Snover."

Similar presentations


Ads by Google