fog-openstack 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/examples/container_infra/basics.rb +61 -0
  4. data/examples/identity/basics_v3.rb +83 -0
  5. data/lib/fog/container_infra/openstack.rb +163 -0
  6. data/lib/fog/container_infra/openstack/models/base.rb +19 -0
  7. data/lib/fog/container_infra/openstack/models/bay.rb +56 -0
  8. data/lib/fog/container_infra/openstack/models/bay_model.rb +62 -0
  9. data/lib/fog/container_infra/openstack/models/bay_models.rb +23 -0
  10. data/lib/fog/container_infra/openstack/models/bays.rb +23 -0
  11. data/lib/fog/container_infra/openstack/models/certificate.rb +20 -0
  12. data/lib/fog/container_infra/openstack/models/certificates.rb +25 -0
  13. data/lib/fog/container_infra/openstack/models/cluster.rb +56 -0
  14. data/lib/fog/container_infra/openstack/models/cluster_template.rb +61 -0
  15. data/lib/fog/container_infra/openstack/models/cluster_templates.rb +24 -0
  16. data/lib/fog/container_infra/openstack/models/clusters.rb +24 -0
  17. data/lib/fog/container_infra/openstack/requests/create_bay.rb +27 -0
  18. data/lib/fog/container_infra/openstack/requests/create_bay_model.rb +56 -0
  19. data/lib/fog/container_infra/openstack/requests/create_certificate.rb +29 -0
  20. data/lib/fog/container_infra/openstack/requests/create_cluster.rb +27 -0
  21. data/lib/fog/container_infra/openstack/requests/create_cluster_template.rb +56 -0
  22. data/lib/fog/container_infra/openstack/requests/delete_bay.rb +24 -0
  23. data/lib/fog/container_infra/openstack/requests/delete_bay_model.rb +24 -0
  24. data/lib/fog/container_infra/openstack/requests/delete_cluster.rb +24 -0
  25. data/lib/fog/container_infra/openstack/requests/delete_cluster_template.rb +24 -0
  26. data/lib/fog/container_infra/openstack/requests/get_bay.rb +51 -0
  27. data/lib/fog/container_infra/openstack/requests/get_bay_model.rb +55 -0
  28. data/lib/fog/container_infra/openstack/requests/get_certificate.rb +27 -0
  29. data/lib/fog/container_infra/openstack/requests/get_cluster.rb +41 -0
  30. data/lib/fog/container_infra/openstack/requests/get_cluster_template.rb +55 -0
  31. data/lib/fog/container_infra/openstack/requests/list_bay_models.rb +69 -0
  32. data/lib/fog/container_infra/openstack/requests/list_bays.rb +55 -0
  33. data/lib/fog/container_infra/openstack/requests/list_cluster_templates.rb +59 -0
  34. data/lib/fog/container_infra/openstack/requests/list_clusters.rb +37 -0
  35. data/lib/fog/container_infra/openstack/requests/update_bay.rb +27 -0
  36. data/lib/fog/container_infra/openstack/requests/update_bay_model.rb +56 -0
  37. data/lib/fog/container_infra/openstack/requests/update_cluster.rb +27 -0
  38. data/lib/fog/container_infra/openstack/requests/update_cluster_template.rb +56 -0
  39. data/lib/fog/key_manager/openstack.rb +103 -0
  40. data/lib/fog/key_manager/openstack/models/container.rb +44 -0
  41. data/lib/fog/key_manager/openstack/models/containers.rb +25 -0
  42. data/lib/fog/key_manager/openstack/models/secret.rb +53 -0
  43. data/lib/fog/key_manager/openstack/models/secrets.rb +25 -0
  44. data/lib/fog/key_manager/openstack/requests/create_container.rb +19 -0
  45. data/lib/fog/key_manager/openstack/requests/create_secret.rb +19 -0
  46. data/lib/fog/key_manager/openstack/requests/delete_container.rb +18 -0
  47. data/lib/fog/key_manager/openstack/requests/delete_secret.rb +18 -0
  48. data/lib/fog/key_manager/openstack/requests/get_container.rb +18 -0
  49. data/lib/fog/key_manager/openstack/requests/get_secret.rb +18 -0
  50. data/lib/fog/key_manager/openstack/requests/get_secret_metadata.rb +18 -0
  51. data/lib/fog/key_manager/openstack/requests/get_secret_payload.rb +21 -0
  52. data/lib/fog/key_manager/openstack/requests/list_containers.rb +19 -0
  53. data/lib/fog/key_manager/openstack/requests/list_secrets.rb +19 -0
  54. data/lib/fog/network/openstack.rb +50 -1
  55. data/lib/fog/network/openstack/requests/create_lbaas_healthmonitor.rb +57 -0
  56. data/lib/fog/network/openstack/requests/create_lbaas_listener.rb +55 -0
  57. data/lib/fog/network/openstack/requests/create_lbaas_loadbalancer.rb +52 -0
  58. data/lib/fog/network/openstack/requests/create_lbaas_pool.rb +53 -0
  59. data/lib/fog/network/openstack/requests/create_lbaas_pool_member.rb +49 -0
  60. data/lib/fog/network/openstack/requests/delete_lbaas_healthmonitor.rb +28 -0
  61. data/lib/fog/network/openstack/requests/delete_lbaas_listener.rb +28 -0
  62. data/lib/fog/network/openstack/requests/delete_lbaas_loadbalancer.rb +28 -0
  63. data/lib/fog/network/openstack/requests/delete_lbaas_pool.rb +28 -0
  64. data/lib/fog/network/openstack/requests/delete_lbaas_pool_member.rb +28 -0
  65. data/lib/fog/network/openstack/requests/get_lbaas_healthmonitor.rb +28 -0
  66. data/lib/fog/network/openstack/requests/get_lbaas_listener.rb +28 -0
  67. data/lib/fog/network/openstack/requests/get_lbaas_loadbalancer.rb +28 -0
  68. data/lib/fog/network/openstack/requests/get_lbaas_pool.rb +28 -0
  69. data/lib/fog/network/openstack/requests/get_lbaas_pool_member.rb +28 -0
  70. data/lib/fog/network/openstack/requests/list_lbaas_healthmonitors.rb +25 -0
  71. data/lib/fog/network/openstack/requests/list_lbaas_listeners.rb +25 -0
  72. data/lib/fog/network/openstack/requests/list_lbaas_loadbalancers.rb +25 -0
  73. data/lib/fog/network/openstack/requests/list_lbaas_pool_members.rb +25 -0
  74. data/lib/fog/network/openstack/requests/list_lbaas_pools.rb +25 -0
  75. data/lib/fog/network/openstack/requests/update_lbaas_healthmonitor.rb +43 -0
  76. data/lib/fog/network/openstack/requests/update_lbaas_listener.rb +45 -0
  77. data/lib/fog/network/openstack/requests/update_lbaas_loadbalancer.rb +41 -0
  78. data/lib/fog/network/openstack/requests/update_lbaas_pool.rb +40 -0
  79. data/lib/fog/network/openstack/requests/update_lbaas_pool_member.rb +39 -0
  80. data/lib/fog/openstack.rb +10 -0
  81. data/lib/fog/openstack/version.rb +7 -1
  82. metadata +78 -2
@@ -0,0 +1,59 @@
1
+ module Fog
2
+ module ContainerInfra
3
+ class OpenStack
4
+ class Real
5
+ def list_cluster_templates
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "clustertemplates/detail"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def list_cluster_templates
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.body = {
19
+ "clustertemplates" => [
20
+ {
21
+ "insecure_registry" => nil,
22
+ "http_proxy" => "http://10.164.177.169:8080",
23
+ "updated_at" => nil,
24
+ "floating_ip_enabled" => true,
25
+ "fixed_subnet" => nil,
26
+ "master_flavor_id" => nil,
27
+ "uuid" => "0562d357-8641-4759-8fed-8173f02c9633",
28
+ "no_proxy" => "10.0.0.0/8,172.0.0.0/8,192.0.0.0/8,localhost",
29
+ "https_proxy" => "http://10.164.177.169:8080",
30
+ "tls_disabled" => false,
31
+ "keypair_id" => "kp",
32
+ "public" => false,
33
+ "labels" => {},
34
+ "docker_volume_size" => 3,
35
+ "server_type" => "vm",
36
+ "external_network_id" => "public",
37
+ "cluster_distro" => "fedora-atomic",
38
+ "image_id" => "fedora-atomic-latest",
39
+ "volume_driver" => "cinder",
40
+ "registry_enabled" => false,
41
+ "docker_storage_driver" => "devicemapper",
42
+ "apiserver_port" => nil,
43
+ "name" => "k8s-bm",
44
+ "created_at" => "2016-08-26T09:34:41+00:00",
45
+ "network_driver" => "flannel",
46
+ "fixed_network" => nil,
47
+ "coe" => "kubernetes",
48
+ "flavor_id" => "m1.small",
49
+ "master_lb_enabled" => false,
50
+ "dns_nameserver" => "8.8.8.8"
51
+ }
52
+ ]
53
+ }
54
+ response
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module ContainerInfra
3
+ class OpenStack
4
+ class Real
5
+ def list_clusters
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "clusters/detail"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def list_clusters
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.body = {
19
+ "clusters" => [
20
+ {
21
+ "status" => "CREATE_IN_PROGRESS",
22
+ "cluster_template_id" => "0562d357-8641-4759-8fed-8173f02c9633",
23
+ "uuid" => "731387cf-a92b-4c36-981e-3271d63e5597",
24
+ "stack_id" => "31c1ee6c-081e-4f39-9f0f-f1d87a7defa1",
25
+ "master_count" => 1,
26
+ "create_timeout" => 60,
27
+ "node_count" => 1,
28
+ "name" => "k8s"
29
+ }
30
+ ]
31
+ }
32
+ response
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module ContainerInfra
3
+ class OpenStack
4
+ class Real
5
+ def update_bay(uuid_or_name, params)
6
+ request(
7
+ :expects => [202, 200],
8
+ :method => 'PATCH',
9
+ :path => "bays/#{uuid_or_name}",
10
+ :body => Fog::JSON.encode(params)
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def update_bay(_uuid_or_name, _params)
17
+ response = Excon::Response.new
18
+ response.status = 202
19
+ response.body = {
20
+ "uuid" => "746e779a-751a-456b-a3e9-c883d734946f"
21
+ }
22
+ response
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ module Fog
2
+ module ContainerInfra
3
+ class OpenStack
4
+ class Real
5
+ def update_bay_model(uuid_or_name, params)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'PATCH',
9
+ :path => "baymodels/#{uuid_or_name}",
10
+ :body => Fog::JSON.encode(params)
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def update_bay_model(_uuid_or_name, _params)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ response.body = {
20
+ "insecure_registry" => nil,
21
+ "http_proxy" => "http://10.164.177.169:8080",
22
+ "updated_at" => nil,
23
+ "floating_ip_enabled" => true,
24
+ "fixed_subnet" => nil,
25
+ "master_flavor_id" => nil,
26
+ "uuid" => "085e1c4d-4f68-4bfd-8462-74b9e14e4f39",
27
+ "no_proxy" => "10.0.0.0/8,172.0.0.0/8,192.0.0.0/8,localhost",
28
+ "https_proxy" => "http://10.164.177.169:8080",
29
+ "tls_disabled" => false,
30
+ "keypair_id" => "kp",
31
+ "public" => false,
32
+ "labels" => {},
33
+ "docker_volume_size" => 3,
34
+ "server_type" => "vm",
35
+ "external_network_id" => "public",
36
+ "cluster_distro" => "fedora-atomic",
37
+ "image_id" => "fedora-atomic-latest",
38
+ "volume_driver" => "cinder",
39
+ "registry_enabled" => false,
40
+ "docker_storage_driver" => "devicemapper",
41
+ "apiserver_port" => nil,
42
+ "name" => "rename-test-bay-model",
43
+ "created_at" => "2016-08-29T02:08:08+00:00",
44
+ "network_driver" => "flannel",
45
+ "fixed_network" => nil,
46
+ "coe" => "kubernetes",
47
+ "flavor_id" => "m1.small",
48
+ "master_lb_enabled" => true,
49
+ "dns_nameserver" => "8.8.8.8",
50
+ }
51
+ response
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module ContainerInfra
3
+ class OpenStack
4
+ class Real
5
+ def update_cluster(uuid_or_name, params)
6
+ request(
7
+ :expects => [202, 200],
8
+ :method => 'PATCH',
9
+ :path => "clusters/#{uuid_or_name}",
10
+ :body => Fog::JSON.encode(params)
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def update_cluster(_uuid_or_name, _params)
17
+ response = Excon::Response.new
18
+ response.status = 202
19
+ response.body = {
20
+ "uuid" => "746e779a-751a-456b-a3e9-c883d734946f"
21
+ }
22
+ response
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ module Fog
2
+ module ContainerInfra
3
+ class OpenStack
4
+ class Real
5
+ def update_cluster_template(uuid_or_name, params)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'PATCH',
9
+ :path => "clustertemplates/#{uuid_or_name}",
10
+ :body => Fog::JSON.encode(params)
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def update_cluster_template(_uuid_or_name, _params)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ response.body = {
20
+ "insecure_registry" => nil,
21
+ "http_proxy" => "http://10.164.177.169:8080",
22
+ "updated_at" => nil,
23
+ "floating_ip_enabled" => true,
24
+ "fixed_subnet" => nil,
25
+ "master_flavor_id" => nil,
26
+ "uuid" => "085e1c4d-4f68-4bfd-8462-74b9e14e4f39",
27
+ "no_proxy" => "10.0.0.0/8,172.0.0.0/8,192.0.0.0/8,localhost",
28
+ "https_proxy" => "http://10.164.177.169:8080",
29
+ "tls_disabled" => false,
30
+ "keypair_id" => "kp",
31
+ "public" => false,
32
+ "labels" => {},
33
+ "docker_volume_size" => 3,
34
+ "server_type" => "vm",
35
+ "external_network_id" => "public",
36
+ "cluster_distro" => "fedora-atomic",
37
+ "image_id" => "fedora-atomic-latest",
38
+ "volume_driver" => "cinder",
39
+ "registry_enabled" => false,
40
+ "docker_storage_driver" => "devicemapper",
41
+ "apiserver_port" => nil,
42
+ "name" => "rename-test-cluster-template",
43
+ "created_at" => "2016-08-29T02:08:08+00:00",
44
+ "network_driver" => "flannel",
45
+ "fixed_network" => nil,
46
+ "coe" => "kubernetes",
47
+ "flavor_id" => "m1.small",
48
+ "master_lb_enabled" => true,
49
+ "dns_nameserver" => "8.8.8.8"
50
+ }
51
+ response
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,103 @@
1
+ module Fog
2
+ module KeyManager
3
+ class OpenStack < Fog::Service
4
+ SUPPORTED_VERSIONS = /v1(\.0)*/
5
+
6
+ requires :openstack_auth_url
7
+ recognizes :openstack_auth_token, :openstack_management_url,
8
+ :persistent, :openstack_service_type, :openstack_service_name,
9
+ :openstack_tenant, :openstack_tenant_id, :openstack_userid,
10
+ :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
11
+ :current_user, :current_tenant, :openstack_region,
12
+ :openstack_endpoint_type, :openstack_auth_omit_default_port,
13
+ :openstack_project_name, :openstack_project_id,
14
+ :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
15
+ :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
16
+ :openstack_identity_prefix, :openstack_temp_url_key, :openstack_cache_ttl
17
+
18
+
19
+ ## MODELS
20
+ #
21
+ model_path 'fog/key_manager/openstack/models'
22
+ model :secret
23
+ collection :secrets
24
+ model :container
25
+ collection :containers
26
+
27
+ ## REQUESTS
28
+
29
+ # secrets
30
+ request_path 'fog/key_manager/openstack/requests'
31
+ request :create_secret
32
+ request :list_secrets
33
+ request :get_secret
34
+ request :get_secret_payload
35
+ request :get_secret_metadata
36
+ request :delete_secret
37
+
38
+ # containers
39
+ request :create_container
40
+ request :get_container
41
+ request :list_containers
42
+ request :delete_container
43
+
44
+ class Real
45
+ include Fog::OpenStack::Core
46
+
47
+ def self.not_found_class
48
+ Fog::KeyManager::OpenStack::NotFound
49
+ end
50
+
51
+ def initialize(options = {})
52
+ initialize_identity options
53
+
54
+ @openstack_service_type = options[:openstack_service_type] || ['key-manager']
55
+ @openstack_service_name = options[:openstack_service_name]
56
+ @connection_options = options[:connection_options] || {}
57
+
58
+ authenticate
59
+ set_api_path
60
+
61
+ @persistent = options[:persistent] || false
62
+ @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
63
+ end
64
+
65
+ def set_api_path
66
+ @path.sub!(%r{/$}, '')
67
+ unless @path.match(SUPPORTED_VERSIONS)
68
+ @path = supported_version(SUPPORTED_VERSIONS, @openstack_management_uri, @auth_token, @connection_options)
69
+ end
70
+ end
71
+
72
+ def supported_version(supported_versions, uri, auth_token, connection_options = {})
73
+ connection = Fog::Core::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, connection_options)
74
+ response = connection.request({ :expects => [200, 204, 300],
75
+ :headers => {'Content-Type' => 'application/json',
76
+ 'Accept' => 'application/json',
77
+ 'X-Auth-Token' => auth_token},
78
+ :method => 'GET'
79
+ })
80
+
81
+ body = Fog::JSON.decode(response.body)
82
+ version = nil
83
+
84
+ versions = body.fetch('versions',{}).fetch('values',[])
85
+ versions.each do |v|
86
+ if v.fetch('id', "").match(supported_versions) &&
87
+ ['current', 'supported', 'stable'].include?(v.fetch('status','').downcase)
88
+ version = v['id']
89
+ end
90
+ end
91
+
92
+ if version.blank?
93
+ raise Fog::OpenStack::Errors::ServiceUnavailable.new(
94
+ "OpenStack service only supports API versions #{supported_versions.inspect}")
95
+ end
96
+
97
+ version
98
+ end
99
+
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,44 @@
1
+ require 'fog/openstack/models/model'
2
+ require 'uri'
3
+
4
+ module Fog
5
+ module KeyManager
6
+ class OpenStack
7
+
8
+ class Container < Fog::OpenStack::Model
9
+ identity :container_ref
10
+
11
+ attribute :uuid
12
+ attribute :name
13
+ attribute :type
14
+ attribute :status
15
+ attribute :creator_id
16
+
17
+ attribute :secret_refs
18
+ attribute :consumers
19
+
20
+ attribute :created
21
+ attribute :updated
22
+
23
+ def uuid
24
+ URI(self.container_ref).path.split('/').last
25
+ rescue
26
+ nil
27
+ end
28
+
29
+ def create
30
+ merge_attributes(service.create_container(attributes).body)
31
+ self
32
+ end
33
+
34
+ def destroy
35
+ requires :container_ref
36
+ service.delete_container(uuid)
37
+ true
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/key_manager/openstack/models/container'
3
+
4
+ module Fog
5
+ module KeyManager
6
+ class OpenStack
7
+ class Containers < Fog::OpenStack::Collection
8
+ model Fog::KeyManager::OpenStack::Container
9
+
10
+ def all(options = {})
11
+ load_response(service.list_containers(options), 'containers')
12
+ end
13
+
14
+ def get(secret_ref)
15
+ if secret = service.get_container(secret_ref).body
16
+ new(secret)
17
+ end
18
+ rescue Fog::Compute::OpenStack::NotFound
19
+ nil
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,53 @@
1
+ require 'fog/openstack/models/model'
2
+ require 'uri'
3
+
4
+ module Fog
5
+ module KeyManager
6
+ class OpenStack
7
+
8
+ class Secret < Fog::OpenStack::Model
9
+ identity :secret_ref
10
+
11
+ # create
12
+ attribute :uuid
13
+ attribute :name
14
+ attribute :expiration
15
+ attribute :bit_length, type: Integer
16
+ attribute :algorithm
17
+ attribute :mode
18
+ attribute :secret_type
19
+
20
+ attribute :content_types
21
+ attribute :created
22
+ attribute :creator_id
23
+ attribute :status
24
+ attribute :updated
25
+
26
+ attribute :payload
27
+ attribute :payload_content_type
28
+ attribute :payload_content_encoding
29
+
30
+ attribute :metadata
31
+
32
+ def uuid
33
+ URI(self.secret_ref).path.split('/').last
34
+ rescue
35
+ nil
36
+ end
37
+
38
+ def create
39
+ merge_attributes(service.create_secret(attributes).body)
40
+ self
41
+ end
42
+
43
+ def destroy
44
+ requires :secret_ref
45
+ service.delete_secret(uuid)
46
+ true
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
53
+ end