Class: Fog::Image::OpenStack::V2::Real
- Inherits:
-
Object
- Object
- Fog::Image::OpenStack::V2::Real
show all
- Includes:
- OpenStack::Core
- Defined in:
- lib/fog/image/openstack/v2.rb,
lib/fog/image/openstack/v2/requests/get_image.rb,
lib/fog/image/openstack/v2/requests/set_tenant.rb,
lib/fog/image/openstack/v2/requests/list_images.rb,
lib/fog/image/openstack/v2/requests/create_image.rb,
lib/fog/image/openstack/v2/requests/delete_image.rb,
lib/fog/image/openstack/v2/requests/update_image.rb,
lib/fog/image/openstack/v2/requests/upload_image.rb,
lib/fog/image/openstack/v2/requests/download_image.rb,
lib/fog/image/openstack/v2/requests/get_image_by_id.rb,
lib/fog/image/openstack/v2/requests/add_tag_to_image.rb,
lib/fog/image/openstack/v2/requests/deactivate_image.rb,
lib/fog/image/openstack/v2/requests/reactivate_image.rb,
lib/fog/image/openstack/v2/requests/get_image_members.rb,
lib/fog/image/openstack/v2/requests/get_shared_images.rb,
lib/fog/image/openstack/v2/requests/get_member_details.rb,
lib/fog/image/openstack/v2/requests/add_member_to_image.rb,
lib/fog/image/openstack/v2/requests/update_image_member.rb,
lib/fog/image/openstack/v2/requests/remove_tag_from_image.rb,
lib/fog/image/openstack/v2/requests/remove_member_from_image.rb
Instance Attribute Summary
#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_member_to_image(image_id, tenant_id) ⇒ Object
-
#add_tag_to_image(image_id, tag) ⇒ Object
-
#create_image(image) ⇒ Object
-
#deactivate_image(image_id) ⇒ Object
-
#delete_image(image_id) ⇒ Object
-
#download_image(image_id, _content_range = nil, params) ⇒ Object
TODO: implement content range handling.
-
#get_image(image_id) ⇒ Object
-
#get_image_by_id(image_id) ⇒ Object
-
#get_image_members(image_id) ⇒ Object
-
#get_member_details(image_id, member_id) ⇒ Object
-
#get_shared_images(tenant_id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
-
#list_images(options = {}) ⇒ Object
-
#reactivate_image(image_id) ⇒ Object
-
#remove_member_from_image(image_id, member_id) ⇒ Object
-
#remove_tag_from_image(image_id, tag) ⇒ Object
-
#set_api_path ⇒ Object
-
#set_tenant(tenant) ⇒ Object
-
#update_image(id, json_patch) ⇒ Object
-
#update_image_member(image_id, member) ⇒ Object
-
#upload_image(image_id, body, params = {}) ⇒ Object
#credentials, #initialize_identity, #reload
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/fog/image/openstack/v2.rb', line 113
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
set_api_path
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
|
Class Method Details
.not_found_class ⇒ Object
109
110
111
|
# File 'lib/fog/image/openstack/v2.rb', line 109
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
13
|
# File 'lib/fog/image/openstack/v2/requests/add_member_to_image.rb', line 6
def add_member_to_image(image_id, tenant_id)
request(
:expects => [200],
:method => 'POST',
:path => "images/#{image_id}/members",
:body => Fog::JSON.encode(:member => tenant_id)
)
end
|
#add_tag_to_image(image_id, tag) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/add_tag_to_image.rb', line 6
def add_tag_to_image(image_id, tag)
request(
:expects => [204],
:method => 'PUT',
:path => "images/#{image_id}/tags/#{tag}"
)
end
|
#create_image(image) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/fog/image/openstack/v2/requests/create_image.rb', line 6
def create_image(image)
location = image.delete :location
= {}
["Location"] = location if location
request(
:headers => ,
:expects => [201],
:method => 'POST',
:path => "images",
:body => Fog::JSON.encode(image)
)
end
|
#deactivate_image(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/deactivate_image.rb', line 6
def deactivate_image(image_id)
request(
:expects => 204,
:method => 'POST',
:path => "images/#{image_id}/actions/deactivate"
)
end
|
#delete_image(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/delete_image.rb', line 6
def delete_image(image_id)
request(
:expects => 204,
:method => 'DELETE',
:path => "images/#{image_id}"
)
end
|
#download_image(image_id, _content_range = nil, params) ⇒ Object
TODO: implement content range handling
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/fog/image/openstack/v2/requests/download_image.rb', line 6
def download_image(image_id, _content_range = nil, params) request_hash = {
:expects => [200, 204],
:method => 'GET',
:raw_body => true,
:path => "images/#{image_id}/file",
}
request_hash[:response_block] = params[:response_block] if params[:response_block]
request(request_hash).body
end
|
#get_image(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/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/image/openstack/v2/requests/get_image_by_id.rb', line 6
def get_image_by_id(image_id)
request(
:expects => [200],
:method => 'GET',
:path => "images/#{image_id}"
)
end
|
#get_image_members(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/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_member_details(image_id, member_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/get_member_details.rb', line 6
def get_member_details(image_id, member_id)
request(
:expects => [200],
:method => 'GET',
:path => "images/#{image_id}/members/#{member_id}"
).body
end
|
#get_shared_images(tenant_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/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_images(options = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/image/openstack/v2/requests/list_images.rb', line 6
def list_images(options = {})
request(
:expects => [200],
:method => 'GET',
:path => 'images',
:query => options
)
end
|
#reactivate_image(image_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/reactivate_image.rb', line 6
def reactivate_image(image_id)
request(
:expects => 204,
:method => 'POST',
:path => "images/#{image_id}/actions/reactivate"
)
end
|
#remove_member_from_image(image_id, member_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/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
|
#remove_tag_from_image(image_id, tag) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/image/openstack/v2/requests/remove_tag_from_image.rb', line 6
def remove_tag_from_image(image_id, tag)
request(
:expects => [204],
:method => 'DELETE',
:path => "images/#{image_id}/tags/#{tag}"
)
end
|
#set_tenant(tenant) ⇒ Object
6
7
8
9
10
|
# File 'lib/fog/image/openstack/v2/requests/set_tenant.rb', line 6
def set_tenant(tenant)
@openstack_must_reauthenticate = true
@openstack_tenant = tenant.to_s
authenticate
end
|
#update_image(id, json_patch) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/image/openstack/v2/requests/update_image.rb', line 6
def update_image(id, json_patch)
request(
:headers => {'Content-Type' => 'application/openstack-images-v2.1-json-patch'},
:expects => [200],
:method => 'PATCH',
:path => "images/#{id}",
:body => Fog::JSON.encode(json_patch)
)
end
|
#update_image_member(image_id, member) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/image/openstack/v2/requests/update_image_member.rb', line 6
def update_image_member(image_id, member)
request( :body => Fog::JSON.encode(member.select { |key, _value| key == 'status' }),
:expects => [200],
:method => 'PUT',
:path => "images/#{image_id}/members/#{member['member_id']}"
)
end
|
#upload_image(image_id, body, params = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/fog/image/openstack/v2/requests/upload_image.rb', line 6
def upload_image(image_id, body, params = {})
request_hash = {
:headers => {'Content-Type' => 'application/octet-stream'},
:expects => 204,
:method => 'PUT',
:path => "images/#{image_id}/file"
}
request_hash[:request_block] = params[:request_block] if params[:request_block]
request_hash[:body] = body if body
request(request_hash).body
ensure
body.close if body.respond_to?(:close)
end
|