Sha256: 4614ca8fb8b8dde3ec56e9d379dbcf9610856e3892ee52cc77e1ef657f29b8b4

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

module Fog
  module Compute
    class QingCloud
      class Real


        # Create a new security group
        def create_security_group(name = nil)
          request(
            'action'            => 'CreateSecurityGroup',
            'security_group_name'         => name
          )
        end

      end

      class Mock

        def create_security_group(name = nil)
          response = Excon::Response.new
          if self.data[:security_groups].length < self.data[:quota][:security_groups]
            data = {
              'is_applied'          => 1,
              'description'         => nil,
              'security_group_name' => name,
              'security_group_id'   => Fog::QingCloud::Mock.security_group_id,
              'is_default'          => 0,
              'create_time'         => Time.now,
              'resources'           => [],
              'rules'               => []
            }
            self.data[:security_groups][data['security_group_id']] = data
            response.body = {
              'action'   => 'CreateSecurityGroupResponse',
              'ret_code' => 0,
              'security_group_id' => data['security_group_id']
            }
            response
          else
            raise Fog::QingCloud::Errors::QuotaExceeded, "You can create #{self.data[:quota][:security_groups]} security groups."
          end
        end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ns-fog-1.22.11 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.10 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.9 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.8 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.7 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.6 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.4 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.3 lib/fog/qingcloud/requests/compute/create_security_group.rb
ns-fog-1.22.2 lib/fog/qingcloud/requests/compute/create_security_group.rb