mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[cloudstack|security_group] fix rule revoke mock
This commit is contained in:
parent
8e3ee75555
commit
c47ba29b39
5 changed files with 11 additions and 10 deletions
|
@ -7,8 +7,8 @@ module Fog
|
||||||
|
|
||||||
attribute :security_group_id, :type => :string
|
attribute :security_group_id, :type => :string
|
||||||
attribute :protocol, :type => :string
|
attribute :protocol, :type => :string
|
||||||
attribute :start_port, :type => :integer
|
attribute :start_port, :type => :integer, :aliases => 'startport'
|
||||||
attribute :end_port, :type => :integer
|
attribute :end_port, :type => :integer, :aliases => 'endport'
|
||||||
attribute :cidr, :type => :string
|
attribute :cidr, :type => :string
|
||||||
attribute :direction, :type => :string
|
attribute :direction, :type => :string
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ module Fog
|
||||||
job.successful?
|
job.successful?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def port_range
|
||||||
|
(self.start_port..self.end_port)
|
||||||
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
requires :security_group_id, :cidr, :direction
|
requires :security_group_id, :cidr, :direction
|
||||||
|
|
||||||
|
@ -36,6 +40,7 @@ module Fog
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
requires :id, :security_group_id, :cidr
|
requires :id, :security_group_id, :cidr
|
||||||
|
|
||||||
merge_attributes(security_group.rules.get(self.id))
|
merge_attributes(security_group.rules.get(self.id))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data[:jobs][job_id]= job
|
self.data[:jobs][job_id]= job
|
||||||
self.data[:security_groups][security_group_id] = security_group
|
|
||||||
|
|
||||||
{ "authorizesecuritygroupegressresponse" => { "jobid" => job_id } }
|
{ "authorizesecuritygroupegressresponse" => { "jobid" => job_id } }
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,7 +62,6 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data[:jobs][job_id]= job
|
self.data[:jobs][job_id]= job
|
||||||
self.data[:security_groups][security_group_id] = security_group
|
|
||||||
|
|
||||||
{ "authorizesecuritygroupingressresponse" => { "jobid" => job_id } }
|
{ "authorizesecuritygroupingressresponse" => { "jobid" => job_id } }
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,8 +16,8 @@ module Fog
|
||||||
raise Fog::Compute::Cloudstack::BadRequest.new('Unable to execute API command missing parameter id')
|
raise Fog::Compute::Cloudstack::BadRequest.new('Unable to execute API command missing parameter id')
|
||||||
end
|
end
|
||||||
|
|
||||||
security_group_id, security_group = self.data[:security_groups].find do |id,group|
|
security_group = self.data[:security_groups].values.find do |group|
|
||||||
group['egressrule'] && group['egressrule'].delete_if { |r| r['id'] == security_group_rule_id }
|
(rule = (group['egressrule'] || []).find{|r| r['ruleid'] == security_group_rule_id}) && group['egressrule'].delete(rule)
|
||||||
end
|
end
|
||||||
|
|
||||||
job_id = Fog::Cloudstack.uuid
|
job_id = Fog::Cloudstack.uuid
|
||||||
|
@ -33,7 +33,6 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data[:jobs][job_id]= job
|
self.data[:jobs][job_id]= job
|
||||||
self.data[:security_groups][security_group_id] = security_group
|
|
||||||
|
|
||||||
{"revokesecuritygroupegress" => { "jobid" => job_id }}
|
{"revokesecuritygroupegress" => { "jobid" => job_id }}
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,8 @@ module Fog
|
||||||
raise Fog::Compute::Cloudstack::BadRequest.new('Unable to execute API command missing parameter id')
|
raise Fog::Compute::Cloudstack::BadRequest.new('Unable to execute API command missing parameter id')
|
||||||
end
|
end
|
||||||
|
|
||||||
security_group_id, security_group = self.data[:security_groups].find do |id,group|
|
security_group = self.data[:security_groups].values.find do |group|
|
||||||
group['ingressrule'] && group['ingressrule'].delete_if { |r| r['id'] == security_group_rule_id }
|
(rule = (group['ingressrule'] || []).find{|r| r['ruleid'] == security_group_rule_id}) && group['ingressrule'].delete(rule)
|
||||||
end
|
end
|
||||||
|
|
||||||
job_id = Fog::Cloudstack.uuid
|
job_id = Fog::Cloudstack.uuid
|
||||||
|
@ -36,7 +36,6 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data[:jobs][job_id]= job
|
self.data[:jobs][job_id]= job
|
||||||
self.data[:security_groups][security_group_id] = security_group
|
|
||||||
|
|
||||||
{"revokesecuritygroupingress" => { "jobid" => job_id }}
|
{"revokesecuritygroupingress" => { "jobid" => job_id }}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue