-
Couldn't load subscription status.
- Fork 2.2k
{WIP}(PUP-7894) Add Scheduled Task V2 API functionality #6382
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
{WIP}(PUP-7894) Add Scheduled Task V2 API functionality #6382
Conversation
|
CLA signed by all contributors. |
dbfa648 to
1158718
Compare
This commit adds a new class which has the same interface as the older V1 Scheduled Tasks (puppet/util/windows/taskscheduler.rb). This facade class will implement the V1 methods but using the V2 API calls. This commit only adds the minimum required implementations, and the rest with NotImplementedErrors. These will be populated in later commits.
This commit adds a non-default provider for the Scheduled Task type but instead uses the V2 facade class. This provider is in essence a verbatim copy of the original provider (win32_taskscheduler) but changes the helper class to the V2 API facade object. This maintains backwards compatilbity and will allow the older V1 implementation to be deprecated and then removed easily.
This commit changes the unit tests for the scheduled_task provider by running the tests against both providers (win32_taskscheduler and taskscheduler_api2). This ensures that any behaviors are consistent in both providers. The concrete class which services each provider is refactored into the concrete_klass variable which is then used in the tests themselves.
1158718 to
aeacc2f
Compare
|
|
||
| class Puppet::Util::Windows::TaskScheduler2V1Task | ||
| # The error class raised if any task scheduler specific calls fail. | ||
| class Error < Puppet::Util::Windows::Error; end |
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.
I think there should be a require 'puppet/util/windows' here so that this is unnecessary...
| @task = nil | ||
|
|
||
| @tasksched.set_compatibility(@definition, Puppet::Util::Windows::TaskScheduler2::TASK_COMPATIBILITY_V1) | ||
| #@definition.compatibility = Puppet::Util::Windows::TaskScheduler2::TASK_COMPATIBILITY_V1 |
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.
Comment
|
|
||
| # Delete the specified task name. | ||
| # | ||
| def delete(task) |
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.
I think we determined delete should be used somewhere
|
|
||
| # Execute the current task. | ||
| # | ||
| def run |
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.
There are no callers for run anywhere, so not sure why it's here?
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.
Because it's in the original class and this is binary compatible.
aeacc2f to
5635e3a
Compare
Previously Puppet used the V1 API for scheduled tasks however this has been deprecated in favor of the V2 Win32OLE objects. This commit adds a module which can query and modify tasks with the V2 API. This module only implements the required methods for the existing Scheduled Task providers, for example it does implement methods to run, terminate tasks or get last run information or exit codes.
Previously a basic implementation of the V2 facade class was introduced. This commit actually implements the required methods for the Scheduled Task providers. Note that many methods still raise Not Implemented errors as these are not required by the Scheduled Task providers to manage state.
Previously the Scheduled Task API helpers did not have any tests to confirm their behaviour. This commit adds some basic tests to the Scheduled Task V2 module to ensure it can list, create, delete, and modify tasks on a Windows system. This commit also adds integration tests for the V2 facade class to confirm that tasks created in the V1 API appear in the V2 facade and vice versa.
5635e3a to
6b87f37
Compare
| # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383600(v=vs.85).aspx | ||
|
|
||
| # @api private | ||
| module Puppet::Util::Windows::TaskScheduler2 |
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.
Need to split this into component module statements as per @Iristyle recommendation
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.
I thought @DLuCJ ran into requiring things to be split, but the PR that got merged didn't have the changes I was referring to (https://github.com/puppetlabs/puppet/pull/5114/files and https://github.com/puppetlabs/puppet/pull/5098/files) - so I seem to be misremembering there.
The reason to do this is based on Ruby scoping rules - see https://github.com/bbatsov/ruby-style-guide#namespace-definition for the surprising behavior!
|
Leaving open for the moment, but this should close shortly for work to proceed in the new https://github.com/puppetlabs/puppetlabs-scheduled_task repo |
|
This has shipped in a different form in puppetlabs/puppetlabs-scheduled_task#6 |
TODO
Will supercede #6198