Class: Fog::Compute::QingCloud::SecurityGroups
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::QingCloud::SecurityGroups
- Defined in:
- lib/fog/qingcloud/models/compute/security_groups.rb
Instance Method Summary collapse
-
#all(filters = filters) ⇒ Object
Returns an array of all security groups that have been created.
-
#get(group_id) ⇒ Object
Used to retrieve a security group group id is required to get the associated flavor information.
-
#get_by_name(group_name) ⇒ Object
Used to retrieve a security group group name is required to get the associated flavor information.
-
#initialize(attributes) ⇒ SecurityGroups
constructor
Creates a new security group.
- #new(attributes = {}) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ SecurityGroups
Creates a new security group
QingCloud.security_groups.new
19 20 21 22 |
# File 'lib/fog/qingcloud/models/compute/security_groups.rb', line 19 def initialize(attributes) self.filters ||= {} super end |
Instance Method Details
#all(filters = filters) ⇒ Object
Returns an array of all security groups that have been created
QingCloud.security_groups.all
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/qingcloud/models/compute/security_groups.rb', line 28 def all(filters = filters) unless filters.is_a?(Hash) Fog::Logger.deprecation("all with #{filters.class} param is deprecated, use all('group-name' => []) instead [light_black](#{caller.first})[/]") filters = {'group-name' => [*filters]} end self.filters = filters data = service.describe_security_groups(filters).body load(data['security_group_set']) if server self.replace(self.select do |sg| sg.resources.select {|r| r['resource_type'] == 'instance' && r['resource_id'] == server.id}.any? end ) end self end |
#get(group_id) ⇒ Object
Used to retrieve a security group group id is required to get the associated flavor information.
You can run the following command to get the details: QingCloud.security_groups.get_by_id(“sg-aaaaaaaa”)
64 65 66 67 68 |
# File 'lib/fog/qingcloud/models/compute/security_groups.rb', line 64 def get(group_id) if group_id self.class.new(:service => service).all('group-id' => group_id).first end end |
#get_by_name(group_name) ⇒ Object
Used to retrieve a security group group name is required to get the associated flavor information.
You can run the following command to get the details: QingCloud.security_groups.get(“default”)
52 53 54 55 56 |
# File 'lib/fog/qingcloud/models/compute/security_groups.rb', line 52 def get_by_name(group_name) if group_name self.class.new(:service => service).all('group-name' => group_name).first end end |
#new(attributes = {}) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/fog/qingcloud/models/compute/security_groups.rb', line 70 def new(attributes = {}) if server super({ :server => server }.merge!(attributes)) else super end end |