Class: Fog::Image::OpenStack::V1::Real
- Inherits:
-
Object
- Object
- Fog::Image::OpenStack::V1::Real
show all
- Includes:
- OpenStack::Common, OpenStack::Core
- Defined in:
- lib/fog/openstack/image_v1.rb,
lib/fog/openstack/requests/image_v1/get_image.rb,
lib/fog/openstack/requests/image_v1/set_tenant.rb,
lib/fog/openstack/requests/image_v1/create_image.rb,
lib/fog/openstack/requests/image_v1/delete_image.rb,
lib/fog/openstack/requests/image_v1/update_image.rb,
lib/fog/openstack/requests/image_v1/get_image_by_id.rb,
lib/fog/openstack/requests/image_v1/get_image_members.rb,
lib/fog/openstack/requests/image_v1/get_shared_images.rb,
lib/fog/openstack/requests/image_v1/list_public_images.rb,
lib/fog/openstack/requests/image_v1/add_member_to_image.rb,
lib/fog/openstack/requests/image_v1/update_image_members.rb,
lib/fog/openstack/requests/image_v1/remove_member_from_image.rb,
lib/fog/openstack/requests/image_v1/list_public_images_detailed.rb
Instance Attribute Summary
#unscoped_token
#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_user_domain, #openstack_user_domain_id
Class Method Summary
collapse
Instance Method Summary
collapse
#request
#credentials, #initialize_identity, #reload
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/fog/openstack/image_v1.rb', line 109
def initialize(options={})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['image']
@openstack_service_name = options[:openstack_service_name]
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
@connection_options = options[:connection_options] || {}
authenticate
process_path @openstack_management_uri
unless @path.match(SUPPORTED_VERSIONS)
@path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
@openstack_management_uri,
@auth_token,
@connection_options)
end
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
|
Class Method Details
.not_found_class ⇒ Object
104
105
106
|
# File 'lib/fog/openstack/image_v1.rb', line 104
def self.not_found_class
Fog::Image::OpenStack::NotFound
end
|
Instance Method Details
#add_member_to_image(image_id, tenant_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/add_member_to_image.rb', line 6
def add_member_to_image(image_id, tenant_id)
request(
:expects => [200, 204],
:method => 'PUT',
:path => "images/#{image_id}/members/#{tenant_id}"
)
end
|
#create_image(attributes) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/fog/openstack/requests/image_v1/create_image.rb', line 6
def create_image(attributes)
data = {
'Content-Type' => 'application/octet-stream',
'x-image-meta-name' => attributes[:name],
'x-image-meta-disk-format' => attributes[:disk_format],
'x-image-meta-container-format' => attributes[:container_format],
'x-image-meta-size' => attributes[:size],
'x-image-meta-is-public' => attributes[:is_public],
'x-image-meta-min-ram' => attributes[:min_ram],
'x-image-meta-min-disk' => attributes[:min_disk],
'x-image-meta-checksum' => attributes[:checksum],
'x-image-meta-owner' => attributes[:owner],
'x-glance-api-copy-from' => attributes[:copy_from]
}.reject { |k, v| v.nil? }
body = String.new
if attributes[:location]
body = File.open(attributes[:location], "rb")
data['x-image-meta-size'] = File.size(body)
end
unless attributes[:properties].nil?
attributes[:properties].each do |key, value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:body => body,
:expects => 201,
:method => 'POST',
:path => "images"
)
ensure
body.close if body.respond_to?(:close)
end
|
#delete_image(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/delete_image.rb', line 6
def delete_image(image_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "images/#{image_id}"
)
end
|
#get_image(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/get_image.rb', line 6
def get_image(image_id)
request(
:expects => [200, 204],
:method => 'HEAD',
:path => "images/#{image_id}"
)
end
|
#get_image_by_id(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/get_image_by_id.rb', line 6
def get_image_by_id(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}"
)
end
|
#get_image_members(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/get_image_members.rb', line 6
def get_image_members(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}/members"
)
end
|
#get_shared_images(tenant_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/get_shared_images.rb', line 6
def get_shared_images(tenant_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "shared-images/#{tenant_id}"
)
end
|
#list_public_images(options = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/openstack/requests/image_v1/list_public_images.rb', line 6
def list_public_images(options = {})
request(
:expects => [200, 204],
:method => 'GET',
:path => 'images',
:query => options
)
end
|
#list_public_images_detailed(options = {}, query_deprecated = nil) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/fog/openstack/requests/image_v1/list_public_images_detailed.rb', line 6
def list_public_images_detailed(options = {}, query_deprecated = nil)
if options.is_a?(Hash)
query = options
elsif options
Fog::Logger.deprecation("Calling OpenStack[:glance].list_public_images_detailed(attribute, query) format"\
" is deprecated, call .list_public_images_detailed(attribute => query) instead")
query = {options => query_deprecated}
else
query = {}
end
request(
:expects => [200, 204],
:method => 'GET',
:path => 'images/detail',
:query => query
)
end
|
#process_path(uri) ⇒ Object
#remove_member_from_image(image_id, member_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/image_v1/remove_member_from_image.rb', line 6
def remove_member_from_image(image_id, member_id)
request(
:expects => [200, 204],
:method => 'DELETE',
:path => "images/#{image_id}/members/#{member_id}"
)
end
|
#set_tenant(tenant) ⇒ Object
6
7
8
9
10
|
# File 'lib/fog/openstack/requests/image_v1/set_tenant.rb', line 6
def set_tenant(tenant)
@openstack_must_reauthenticate = true
@openstack_tenant = tenant.to_s
authenticate
end
|
#update_image(attributes) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/fog/openstack/requests/image_v1/update_image.rb', line 6
def update_image(attributes)
data = {
'x-image-meta-name' => attributes[:name],
'x-image-meta-disk-format' => attributes[:disk_format],
'x-image-meta-container-format' => attributes[:container_format],
'x-image-meta-size' => attributes[:size],
'x-image-meta-is-public' => attributes[:is_public],
'x-image-meta-min-ram' => attributes[:min_ram],
'x-image-meta-min-disk' => attributes[:min_disk],
'x-image-meta-checksum' => attributes[:checksum],
'x-image-meta-owner' => attributes[:owner]
}.reject { |k, v| v.nil? }
unless attributes[:properties].nil?
attributes[:properties].each do |key, value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:expects => 200,
:method => 'PUT',
:path => "images/#{attributes[:id]}"
)
end
|
#update_image_members(image_id, members) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/fog/openstack/requests/image_v1/update_image_members.rb', line 6
def update_image_members(image_id, members)
data = {'memberships' => members}
request(
:body => Fog::JSON.encode(data),
:expects => [204],
:method => 'PUT',
:path => "images/#{image_id}/members"
)
end
|