Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add model and collection for security group rules * add mock data for networks * returns address in create_server mock * proper security group rule mocks * proper security group mocks
- Loading branch information
Showing
18 changed files
with
261 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
require 'fog/core/model' | |||
|
|||
module Fog | |||
module Compute | |||
class OpenStack | |||
class SecurityGroupRule < Fog::Model | |||
identity :id | |||
|
|||
attribute :from_port | |||
attribute :group | |||
attribute :ip_protocol | |||
attribute :to_port | |||
attribute :parent_group_id | |||
attribute :ip_range | |||
|
|||
def save | |||
requires :ip_protocol, :from_port, :to_port, :parent_group_id | |||
cidr = ip_range && ip_range["cidr"] | |||
if rule = service.create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group).data[:body] | |||
merge_attributes(rule["security_group_rule"]) | |||
end | |||
end | |||
|
|||
def destroy | |||
requires :id | |||
service.delete_security_group_rule(id) | |||
true | |||
end | |||
end | |||
end | |||
end | |||
end |
This file contains 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
require 'fog/core/collection' | |||
require 'fog/openstack/models/compute/security_group_rule' | |||
|
|||
module Fog | |||
module Compute | |||
class OpenStack | |||
class SecurityGroupRules < Fog::Collection | |||
|
|||
model Fog::Compute::OpenStack::SecurityGroupRule | |||
|
|||
def get(security_group_rule_id) | |||
if security_group_rule_id | |||
body = service.get_security_group_rule(security_group_rule_id).body | |||
new(body['security_group_rule']) | |||
end | |||
rescue Fog::Compute::OpenStack::NotFound | |||
nil | |||
end | |||
end | |||
end | |||
end | |||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
38 changes: 38 additions & 0 deletions
38
lib/fog/openstack/requests/compute/get_security_group_rule.rb
This file contains 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,38 @@ | |||
module Fog | |||
module Compute | |||
class OpenStack | |||
class Real | |||
def get_security_group_rule(security_group_rule_id) | |||
request( | |||
:expects => [200], | |||
:method => 'GET', | |||
:path => "os-security-group-rules/#{security_group_rule_id}" | |||
) | |||
end | |||
end | |||
|
|||
class Mock | |||
def get_security_group_rule(security_group_rule_id) | |||
security_group_rule = nil | |||
self.data[:security_groups].detect{|id, sg| security_group_rule = sg["rules"].detect{ |sgr| sgr["id"].to_s == security_group_rule_id.to_s }} | |||
response = Excon::Response.new | |||
if security_group_rule | |||
response.status = 200 | |||
response.headers = { | |||
"X-Compute-Request-Id" => "req-63a90344-7c4d-42e2-936c-fd748bced1b3", | |||
"Content-Type" => "application/json", | |||
"Content-Length" => "167", | |||
"Date" => Date.new | |||
} | |||
response.body = { | |||
"security_group_rule" => security_group_rule | |||
} | |||
else | |||
raise Fog::Compute::OpenStack::NotFound, "Security group rule #{security_group_rule_id} does not exist" | |||
end | |||
response | |||
end | |||
end # mock | |||
end # openstack | |||
end #compute | |||
end #fog |
Oops, something went wrong.
0192e53
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.
@burns you are correct. We're using string keys for the security group mock data now. So that seed data does need to change.
0192e53
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.
@burns master seems to be green. Let me know if you want me to look into a specific failure. https://travis-ci.org/fog/fog/builds/15552477
0192e53
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.
Yeah, any insight would be awesome (I was just trying to look in to it and nothing was jumping out at me as obvious in terms of why it would sometimes be failing on us).
0192e53
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.
Just did a bit of work around it here: b056df5
Not sure it will fix it (since I'm not sure why it was breaking), but it at least streamlines and removes some of the failure vectors.
0192e53
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.
Looks like it might be fixed, fwiw. Now a different error is breaking the build anyway. Will continue to monitor.