Module: Ropenstack::Image::Version1

Defined in:
lib/ropenstack/image/v1.rb

Overview

  • Name: ImageVersion1

  • Description: Implementation of the Glance V1.0 API Client in Ruby

  • Author: Sam ‘Tehsmash’ Betts, John Davidge

  • Date: 30/06/2014

Instance Method Summary collapse

Instance Method Details

#add_member(id, member_id, can_share, tenant_id) ⇒ Object

Adds a member to an image.

Parameters:

  • member_id

    The member to be added

  • can_share

    Optional boolean specifiying can_share value. Will default to false.



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ropenstack/image/v1.rb', line 69

def add_member(id, member_id, can_share, tenant_id)
  if can_share.nil?
    data = {
      :member => {:can_share => false}
    }
  else
    data = {
      :member => {:can_share => can_share}
    }
  end
  put_request(address(tenant_id, "images/" + id + "/members/" + member_id), data, @token)
end

#address(tenant_id, endpoint) ⇒ Object

Returns the v1 address location of an endpoint.



99
100
101
# File 'lib/ropenstack/image/v1.rb', line 99

def address(tenant_id, endpoint)
  address("/v1/#{tenant_id}/#{endpoint}")
end

#delete_member(id, member_id, tenant_id) ⇒ Object

Removes a member from an image



85
86
87
# File 'lib/ropenstack/image/v1.rb', line 85

def delete_member(id, member_id, tenant_id)
  delete_request(address(tenant_id, "images/" + id + "/members/" + member_id), @token)
end

#image_create(name, disk_format, container_format, create_image, tenant_id) ⇒ Object

Registers a virtual machine image.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ropenstack/image/v1.rb', line 25

def image_create(name, disk_format, container_format, create_image, tenant_id)
  data = { 
    :name => name,
    :disk_format => disk_format,
    :container_format => container_format
  }
  unless create_image.nil?
    data[:create_image] = create_image
  end

  post_request(address(tenant_id, "images"), data, @token)
end

#image_delete(id, tenant_id) ⇒ Object

Deletes the specified image.



49
50
51
# File 'lib/ropenstack/image/v1.rb', line 49

def image_delete(id, tenant_id)
  delete_request(address(tenant_id, "images/" + id), @token)
end

#image_update(id, tenant_id) ⇒ Object

Updates an image, uploads an image file, or updates metadata for an image. NOT IMPLEMENTED



42
43
44
# File 'lib/ropenstack/image/v1.rb', line 42

def image_update(id, tenant_id)
  raise Ropenstack::RopenstackError, "Update Method Not Implemented."
end

#images(id, tenant_id) ⇒ Object

No ID provided - Lists details for available images. ID provided - Shows the image details as headers and the image binary in the body.



14
15
16
17
18
19
20
# File 'lib/ropenstack/image/v1.rb', line 14

def images(id, tenant_id)
  if id.nil?
    return get_request(address(tenant_id, "images/detail"), @token)
  else
    return get_request(address(tenant_id, "images/" + id), @token)
  end
end

#replace_memberships(id, memberships, tenant_id) ⇒ Object

Replaces the membership list for an image.

Parameters:

  • memberships

    List of memberships in format [‘tenant1’, ‘can_share’: ‘false’]



57
58
59
60
61
62
# File 'lib/ropenstack/image/v1.rb', line 57

def replace_memberships(id, memberships, tenant_id)
  data = {
    :memberships => memberships
  }
  put_request(address(tenant_id, "images/" + id + "/members"), data, @token)
end

#shared_images(id, owner_id, tenant_id) ⇒ Object

Lists the images shared with a specified owner.



92
93
94
# File 'lib/ropenstack/image/v1.rb', line 92

def shared_images(id, owner_id, tenant_id)
  get_request(address(tenant_id, "shared-images/" + owner_id), @token)
end

#versionObject



103
104
105
# File 'lib/ropenstack/image/v1.rb', line 103

def version
  "V1"
end