-
Notifications
You must be signed in to change notification settings - Fork 56
Linux Service module #454
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
Merged
Merged
Linux Service module #454
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
resources/Microsoft.DSC.Experimental/0.0.1/Microsoft.DSC.Experimental.Systemctl.psm1
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| using namespace System.Collections.Generic | ||
|
|
||
| [DscResource()] | ||
| class SystemctlService | ||
| { | ||
| [DscProperty(Key)] | ||
| [string] $Unit | ||
|
|
||
| [DscProperty()] | ||
| [string] $Load | ||
|
|
||
| [DscProperty()] | ||
| [string] $Active | ||
|
|
||
| [DscProperty()] | ||
| [string] $Sub | ||
|
|
||
| [DscProperty()] | ||
| [string] $Description | ||
|
|
||
| [void] Set() | ||
| { | ||
| } | ||
|
|
||
| [bool] Test() | ||
| { | ||
| return $false | ||
| } | ||
|
|
||
| [SystemctlService] Get() | ||
| { | ||
|
|
||
| return [SystemctlService]::GetAll() | Where-Object {$_.Unit -eq $this.Unit } | ||
| } | ||
|
|
||
| static [SystemctlService[]] Export() | ||
| { | ||
| return [SystemctlService]::GetAll() | ||
| } | ||
|
|
||
| static [SystemctlService[]] GetAll() | ||
| { | ||
| $out = systemctl -l --type service --all | ||
| $resultList = [List[SystemctlService]]::new() | ||
| $out | select-object -skip 1 | select-object -skiplast 7 | %{ | ||
| $arr = $_.split(" ", [System.StringSplitOptions]::RemoveEmptyEntries) | ||
|
|
||
| if ($arr[2] -ne 'not-found') { | ||
| $obj = New-Object SystemctlService | ||
| $obj.Unit = $arr[0] | ||
| $obj.Load = $arr[1] | ||
| $obj.Active = $arr[2] | ||
| $obj.Sub = $arr[3] | ||
| $obj.Description = ($arr | select-object -last ($arr.Count - 4)) -join " " | ||
|
|
||
| $resultList.Add($obj) | ||
| } | ||
| } | ||
| return $resultList.ToArray() | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
resources/Microsoft.DSC.Experimental/0.0.1/Microsoft.DSC.Experimental.psd1
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| @{ | ||
|
|
||
| # Script module or binary module file associated with this manifest. | ||
| RootModule = 'Microsoft.DSC.Experimental.Systemctl.psm1' | ||
|
|
||
| # Version number of this module. | ||
| ModuleVersion = '0.0.1' | ||
|
|
||
| # ID used to uniquely identify this module | ||
| GUID = 'b267fa32-e77d-48e6-9248-676cc6f232ab' | ||
|
|
||
| # Author of this module | ||
| Author = 'Microsoft' | ||
|
|
||
| # Company or vendor of this module | ||
| CompanyName = 'Microsoft Corporation' | ||
|
|
||
| # Copyright statement for this module | ||
| Copyright = '(c) Microsoft. All rights reserved.' | ||
|
|
||
| # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. | ||
| FunctionsToExport = @() | ||
|
|
||
| # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. | ||
| CmdletsToExport = '*' | ||
|
|
||
| # Variables to export from this module | ||
| VariablesToExport = @() | ||
|
|
||
| # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. | ||
| AliasesToExport = @() | ||
|
|
||
| # DSC resources to export from this module | ||
| DscResourcesToExport = 'SystemctlService' | ||
|
|
||
| # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
| PrivateData = @{ | ||
| PSData = @{ | ||
| DscCapabilities = @( | ||
| 'Get' | ||
| 'Export' | ||
| ) | ||
anmenaga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.