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

Fixing Fog::Server user/sshkey workflow #366

Merged
merged 4 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
All notable changes to this project will be documented in this file.
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Next release (1.6.0)

### User-facing

#### Added

- \#361 `Fog::Compute::Google::Server` now recognises `network_ip` attribute to specify internal IP [mattimatti]

#### Fixed

- \#359 Fix whitespace escaping in XML Storage methods [temikus]
- \#366 Fixing `Server` model to properly accept `:private_key_path` and `:public_key_path` attributes again. [temikus]

### Development changes

#### Fixed

- \#363 Fixed flaky Monitoring tests [temikus]

## 1.5.0

### User-facing
Expand Down
5 changes: 5 additions & 0 deletions lib/fog/compute/google/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ def save(username: nil, public_key: nil)
requires :disks
requires :zone

generate_ssh_key_metadata(self.username, self.public_key) if self.public_key

# XXX HACK This is a relic of 1.0 change that for some reason added those arguments
# to `save` method. This is left in place to keep things backwards-compatible
# TODO(2.0): Remove arguments from save
generate_ssh_key_metadata(username, public_key) if public_key

options = attributes.reject { |_, v| v.nil? }
Expand Down
7 changes: 3 additions & 4 deletions lib/fog/compute/google/models/servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ def get(identity, zone = nil)
end

def bootstrap(public_key_path: nil, **opts)
user = ENV["USER"]
public_key = get_public_key(public_key_path)

name = "fog-#{Time.now.to_i}"
zone_name = "us-central1-f"

Expand All @@ -69,7 +66,9 @@ def bootstrap(public_key_path: nil, **opts)
data = opts.merge(
:name => name,
:zone => zone_name,
:disks => disks
:disks => disks,
:public_key_path => get_public_key(public_key_path),
:username => ENV["USER"]
)
data[:machine_type] = "n1-standard-1" unless data[:machine_type]

Expand Down
28 changes: 28 additions & 0 deletions test/unit/compute/test_server.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "helpers/test_helper"

class UnitTestServer < MiniTest::Test
def setup
Fog.mock!
@client = Fog::Compute.new(:provider => "Google", :google_project => "foo")
end

def teardown
Fog.unmock!
end

def test_if_server_accepts_ssh_keys
key = "ssh-rsa IAMNOTAREALSSHKEYAMA== [email protected]"

File.stub :read, key do
server = Fog::Compute::Google::Server.new(
:name => "foo",
:machine_type => "bar",
:disks => ["baz"],
:zone => "foo",
:public_key_path => key
)
assert_equal(server.public_key, key,
"Fog::Compute::Google::Server loads public_key properly")
end
end
end
2 changes: 1 addition & 1 deletion test/unit/storage/test_xml_requests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "helpers/test_helper"

class UnitTestServer < MiniTest::Test
class UnitTestXMLRequests < MiniTest::Test
def setup
Fog.mock!
@client = Fog::Storage.new(provider: "google",
Expand Down