egi-fedcloud-cloudhound 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53b9e447d5ff5c639e1ed13116b39f2d3d86dd77
4
- data.tar.gz: 6019140b5a86e42f0f6c70e5cbe96991582fe1cc
3
+ metadata.gz: 9d6d1e60e2fbc93b5e6d6747ea4373ffe878d9fc
4
+ data.tar.gz: b17621e8590fe41fef073fd3751b200ce49c00ce
5
5
  SHA512:
6
- metadata.gz: b0d2c1a3919ea1625bafbfb04e7e04b467482ce6d4cb2b24fd72000b6e551aac46fef1e138885b104447238bd26ce9144527e97d03d3e44baf9840eede2bf41e
7
- data.tar.gz: c5902b4cae877356fa73948b00bea14ac51af3c944d52a71505daec59d1531d78dd92be6152844a87ce838398d7c8e8ca0a62ea012977095b333fc5519d376f8
6
+ metadata.gz: 63b816bef03b604dcf574a783480e1bab4a52af61d0cda94fb4f91c0e0fc23946b945ed0f81ee25d6e3860814eb0ea3c1a169966b48bce9fb83aefbc6632e7b9
7
+ data.tar.gz: 7a61a4cd04db86768da65fbbdb59f14cb8b41e629e67b9a1c736b202d2cf559afe5bb7ae8ff35d901c1f037357649a25ec5ccf5266e12f00f7e9dadcec22a566
@@ -22,6 +22,29 @@ require 'egi-fedcloud-cloudhound'
22
22
  class EgiFedcloudCloudhound < Thor
23
23
  include Thor::Actions
24
24
 
25
+ desc "all", "Prints information for all available cloud sites"
26
+ method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
27
+ :aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
28
+ method_option :password, :type => :string, :default => nil,
29
+ :aliases => '-p', :desc => 'PEM private key password'
30
+ method_option :ca_path, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.ca_path,
31
+ :aliases => '-x', :desc => 'Directory path to all trusted CA certificates'
32
+ method_option :gocdb_base_url, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.gocdb_base_url,
33
+ :aliases => '-g', :desc => 'GOCDB endpoint URL'
34
+ method_option :appdb_base_url, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.appdb_base_url,
35
+ :aliases => '-a', :desc => 'AppDB API endpoint URL'
36
+ method_option :debug, :type => :boolean, :default => Egi::Fedcloud::Cloudhound::Settings.debug,
37
+ :aliases => '-d', :desc => 'Enable debugging'
38
+ def all
39
+ init_log options[:debug]
40
+
41
+ $stdout.puts Egi::Fedcloud::Cloudhound::Formatter.as_table(
42
+ Egi::Fedcloud::Cloudhound::Extractor.find_all(
43
+ options
44
+ )
45
+ )
46
+ end
47
+
25
48
  desc "ip IP_ADDRESS", "Prints information based on the provided IP address or IP address range"
26
49
  method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
27
50
  :aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
@@ -16,6 +16,20 @@ class Egi::Fedcloud::Cloudhound::Extractor
16
16
  @@appdb ||= Egi::Fedcloud::Cloudhound::Appdb.new(options, password)
17
17
  end
18
18
 
19
+ #
20
+ def find_all(options = {})
21
+ init options
22
+
23
+ Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Searching for all cloud-related contacts"
24
+
25
+ sites = @@gocdb.cloud_sites
26
+ sites.compact!
27
+
28
+ Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Found #{sites.count} cloud sites"
29
+
30
+ sites.collect { |site| site.contacts }
31
+ end
32
+
19
33
  #
20
34
  def find_by_ip(ip, options = {})
21
35
  init options
@@ -3,6 +3,7 @@ require 'ox'
3
3
  #
4
4
  class Egi::Fedcloud::Cloudhound::Gocdb < Egi::Fedcloud::Cloudhound::Connector
5
5
 
6
+ GOCDB_SERVICE_ENDPOINT = '/gocdbpi/public/?method=get_service_endpoint'
6
7
  GOCDB_SITES_URL = '/gocdbpi/private/?method=get_site'
7
8
  GOCDB_PROD_SITES_URL = "#{GOCDB_SITES_URL}&production_status=Production"
8
9
  GOCDB_CERT_PROD_SITES_URL = "#{GOCDB_PROD_SITES_URL}&certification_status=Certified"
@@ -10,8 +11,8 @@ class Egi::Fedcloud::Cloudhound::Gocdb < Egi::Fedcloud::Cloudhound::Connector
10
11
  CLOUD_SERVICE_TYPES = [
11
12
  "eu.egi.cloud.vm-management.occi",
12
13
  "eu.egi.cloud.storage-management.cdmi",
13
- "eu.egi.cloud.accounting",
14
- "eu.egi.cloud.information.bdii",
14
+ # "eu.egi.cloud.accounting",
15
+ # "eu.egi.cloud.information.bdii",
15
16
  "eu.egi.cloud.vm.metadata-vmcatcher",
16
17
  ]
17
18
 
@@ -37,6 +38,21 @@ class Egi::Fedcloud::Cloudhound::Gocdb < Egi::Fedcloud::Cloudhound::Connector
37
38
  get_and_parse GOCDB_CERT_PROD_SITES_URL, 'cert_prod_sites'
38
39
  end
39
40
 
41
+ #
42
+ def cloud_sites
43
+ sites.select { |site| cloud_site_names.include?(site.name) }
44
+ end
45
+
46
+ #
47
+ def production_cloud_sites
48
+ production_sites.select { |site| cloud_site_names.include?(site.name) }
49
+ end
50
+
51
+ #
52
+ def certified_production_cloud_sites
53
+ certified_production_sites.select { |site| cloud_site_names.include?(site.name) }
54
+ end
55
+
40
56
  private
41
57
 
42
58
  #
@@ -50,4 +66,22 @@ class Egi::Fedcloud::Cloudhound::Gocdb < Egi::Fedcloud::Cloudhound::Connector
50
66
 
51
67
  results
52
68
  end
69
+
70
+ #
71
+ def cloud_site_names
72
+ return @cached_cloud_site_names if instance_variable_defined?('@cached_cloud_site_names')
73
+ site_names = Set.new
74
+
75
+ Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Pulling service endpoints from #{GOCDB_SERVICE_ENDPOINT.inspect}"
76
+ xmldoc_service_endpoints = Ox.parse retrieve(GOCDB_SERVICE_ENDPOINT)
77
+ xmldoc_service_endpoints.locate("results/*").each do |service_endpoint|
78
+ service_endpoint.locate("SERVICE_TYPE").each do |service_type|
79
+ next unless service_type && CLOUD_SERVICE_TYPES.include?(service_type.text)
80
+ service_endpoint.locate("SITENAME").each { |service_site_name| site_names << service_site_name.text }
81
+ end
82
+ end
83
+ instance_variable_set('@cached_cloud_site_names', site_names.to_a)
84
+
85
+ @cached_cloud_site_names
86
+ end
53
87
  end
@@ -2,7 +2,7 @@ module Egi
2
2
  module Fedcloud
3
3
  module Cloudhound
4
4
  # Versioning constant
5
- VERSION = "0.0.1" unless defined?(::Egi::Fedcloud::Cloudhound::VERSION)
5
+ VERSION = "0.0.2" unless defined?(::Egi::Fedcloud::Cloudhound::VERSION)
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egi-fedcloud-cloudhound
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Parak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport