Skip to content

Commit

Permalink
Merge pull request #366 from Temikus/fix_server_save
Browse files Browse the repository at this point in the history
Fixing Fog::Server user/sshkey workflow
  • Loading branch information
Temikus authored Jun 23, 2018
2 parents 317ed93 + ee550ff commit 7cc35b7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
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

0 comments on commit 7cc35b7

Please sign in to comment.