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

Add support to reset Windows passwords #495

Merged
merged 1 commit into from
Apr 10, 2020

Conversation

dvanbrug
Copy link
Contributor

These are a few small changes to add the ability to reset windows passwords as described in #494.

The majority of the code was modified from the Python-based Google provided example: https://github.com/GoogleCloudPlatform/compute-image-windows/blob/master/examples/windows_auth_python_sample.py

I have implemented everything as a Request, though I am not sure if this would be better added to the Server model. My thoughts in favor of the Server model are that the request does not match extremely closely to an API, rather is uses the API to set the Metadata values on an instance. However, the downside to adding it to the Server model is that not all Windows images would have this functionality so it might be more complicated to adjust the Server model.

Resolves #494

lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
lib/fog/compute/google/requests/reset_windows_password.rb Outdated Show resolved Hide resolved
Copy link
Member

@Temikus Temikus left a comment

Choose a reason for hiding this comment

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

Ok, done with first review pass, please address the linter and comments below.

Again, thank you so much for this! \o/

@Temikus
Copy link
Member

Temikus commented Mar 30, 2020

@dvanbrug PTAL. If anything is not clear - just let me know! :)

@dvanbrug
Copy link
Contributor Author

@Temikus, thanks, I'll work through these and post another commit.

@dvanbrug
Copy link
Contributor Author

dvanbrug commented Apr 1, 2020

@Temikus, as I was moving over to use the Sever model, I ran into a question about the following method.

def serial_port_output

Am I correct in understanding that it is only possible to get output from serial port 1 as that is the default for the request? The request method below allows for the ability to take a port.

def get_server_serial_port_output(identity, zone, port: nil, start: nil)

As Linux instances also have up to 4 serial ports, should I file a separate issue and pull request for this? It would appear based on this documentation that there are definetly use cases where someone would want to be able to interact with ports 2-4.

https://cloud.google.com/compute/docs/instances/interacting-with-serial-console

Thanks!

@dvanbrug
Copy link
Contributor Author

dvanbrug commented Apr 4, 2020

@Temikus I think I've addressed all of the comments and linter issues. Thank you for your patience as this has been my first in depth pass at building something in Ruby. Looking forward to your thoughts.

@Temikus
Copy link
Member

Temikus commented Apr 4, 2020

@dvanbrug Acknowledged, thanks for making the changes! I should have a solid chunk of time in the next 2 days to properly review.

Re: 3 - yes, this allowed to only read serial port 1 - you did the right thing by modifying it, thanks! :)

Copy link
Member

@Temikus Temikus left a comment

Choose a reason for hiding this comment

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

@dvanbrug This is really good, thank you so much \o/

Just a couple of minor things, PTAL. We should be good to merge after addressing those.

@dvanbrug
Copy link
Contributor Author

dvanbrug commented Apr 7, 2020

@Temikus I've addressed all you comments. Thank you again for all the help with this!

@Temikus
Copy link
Member

Temikus commented Apr 8, 2020

@dvanbrug I think I missed 2 of the earlier comments, so sorry about it. I've resolved all solved threads - can you take a look at the 3 open comments above^

Again, thank you so much for this! :)

@dvanbrug
Copy link
Contributor Author

dvanbrug commented Apr 9, 2020

@Temikus Ok, I've addressed the three comments. One question, as I've had a lot of changes since the start of the PR, should I squash them all into a single commit?

@Temikus
Copy link
Member

Temikus commented Apr 9, 2020

@dvanbrug Alright, this looks awesome, thank you so-so much for your contributions and patience :)
Yeah, please squash if you can.

I'll merge this after CI passes.

@codecov
Copy link

codecov bot commented Apr 9, 2020

Codecov Report

Merging #495 into master will increase coverage by 0.37%.
The diff coverage is 87.67%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #495      +/-   ##
==========================================
+ Coverage   87.51%   87.88%   +0.37%     
==========================================
  Files         311      341      +30     
  Lines        5167     5730     +563     
==========================================
+ Hits         4522     5036     +514     
- Misses        645      694      +49     
Impacted Files Coverage Δ
lib/fog/compute/google/models/images.rb 90.00% <ø> (+1.32%) ⬆️
.../compute/google/requests/reset_windows_password.rb 86.76% <86.76%> (ø)
lib/fog/compute/google.rb 100.00% <100.00%> (ø)
lib/fog/compute/google/models/server.rb 79.52% <100.00%> (+1.15%) ⬆️
lib/fog/google/models/sql/flags.rb 80.00% <0.00%> (-20.00%) ⬇️
lib/fog/google/models/sql/tiers.rb 80.00% <0.00%> (-20.00%) ⬇️
lib/fog/google/requests/sql/list_flags.rb 87.50% <0.00%> (-12.50%) ⬇️
lib/fog/google/requests/sql/list_tiers.rb 87.50% <0.00%> (-12.50%) ⬇️
lib/fog/compute/google/real.rb 100.00% <0.00%> (ø)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46d1bee...158e665. Read the comment docs.

@dvanbrug dvanbrug force-pushed the windows_password_reset_feature branch from bd22bd7 to 97ac311 Compare April 9, 2020 03:40
@dvanbrug
Copy link
Contributor Author

dvanbrug commented Apr 9, 2020

@Temikus Ok, squashed :-). Thanks again for all your help with this!

@Temikus
Copy link
Member

Temikus commented Apr 9, 2020

@dvanbrug All tests pass, just one tiiiny problem:

  test_reset_windows_password                                    ERROR (271.09s)
Minitest::UnexpectedError:         ArgumentError: wrong number of arguments (given 1, expected 0)
            /tmp/build/7e99fb29/src/fog-google/lib/fog/compute/google/models/server.rb:346:in `serial_port_output'
            /tmp/build/7e99fb29/src/fog-google/test/integration/compute/core_compute/test_servers.rb:144:in `test_reset_windows_password'

Can you fixup the argument in the method (it's still set to positional):
serial_output = server.serial_port_output(4)

Sorry for the hassle :)

@dvanbrug dvanbrug force-pushed the windows_password_reset_feature branch from 97ac311 to 158e665 Compare April 9, 2020 13:28
@dvanbrug
Copy link
Contributor Author

dvanbrug commented Apr 9, 2020

@Temikus Doh! There we go, fixed up to use the new keyword parameter.

@Temikus Temikus merged commit d4603bf into fog:master Apr 10, 2020
@Temikus
Copy link
Member

Temikus commented Apr 10, 2020

@dvanbrug awesome, merged! I’ll start prepping the release next week.

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.

Missing support to reset Windows Passwords
3 participants