Sha256: 0d908a49c01341b620e142532c856e8299b5cc0e07a2310e557988c5a373fd7c

Contents?: true

Size: 1.94 KB

Versions: 12

Compression:

Stored size: 1.94 KB

Contents

# encoding: UTF-8

# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

# HPCloud security groups
module HPSecurityGroups
  def self.query_sg(oNetworkConnect, sQuery)
    oNetworkConnect.security_groups.all(sQuery)
  end

  def self.create_sg(oNetwork, name, description)
    params = { :name => name }
    params[:description] = description if description
    oNetwork.security_groups.create(params)
  end

  def self.create_rule(oNetwork, hData)
    oNetwork.security_group_rules.create(hData)
  end

  def self.query_rule(oNetwork, sQuery)
    oNetwork.security_group_rules.all(sQuery)
  end

  def self.delete_rule(oNetwork, rule_id)
    oNetwork.security_group_rules.get(rule_id).destroy
  end
end

# HPCloud keypairs
module HPKeyPairs
  def self.query_keypair(oComputeConnect, sQuery)
    keypairs = oComputeConnect.key_pairs.all
    results = []
    keypairs.each do |sElem|
      is_selected = true
      attributes = sElem.instance_variable_get(:@attributes)
      sQuery.each do |key, value|
        if attributes[key] != value
          is_selected = false
          break
        end
      end
      results.push sElem if is_selected
    end
    results
  end

  def self.get_keypair(oComputeConnect, sId)
    oComputeConnect.key_pairs.get(sId)
  end

  def self.create_keypair(oComputeConnect, name, pubkey)
    oComputeConnect.key_pairs.create(:name => name, :public_key => pubkey)
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
lorj_cloud-0.1.3 lib/process/cloud/providers/hpcloud/security_groups.rb
lorj_cloud-0.1.2 lib/process/cloud/providers/hpcloud/security_groups.rb
lorj_cloud-0.1.1 lib/process/cloud/providers/hpcloud/security_groups.rb
lorj_cloud-0.1.0 lib/providers/hpcloud/security_groups.rb
lorj-1.0.9 lib/providers/hpcloud/security_groups.rb
lorj-1.0.8 lib/providers/hpcloud/security_groups.rb
lorj-1.0.7 lib/providers/hpcloud/security_groups.rb
lorj-1.0.6 lib/providers/hpcloud/security_groups.rb
lorj-1.0.5 lib/providers/hpcloud/security_groups.rb
lorj-1.0.4 lib/providers/hpcloud/security_groups.rb
lorj-1.0.3 lib/providers/hpcloud/security_groups.rb
lorj-1.0.2 lib/providers/hpcloud/security_groups.rb