Class: Azure::Images
- Inherits:
-
Object
- Object
- Azure::Images
- Defined in:
- lib/azure/service_management/image.rb
Instance Method Summary collapse
- #all ⇒ Object
- #exists?(name) ⇒ Boolean
- #find(name) ⇒ Object
-
#get_images(img_type) ⇒ Object
img_type = OSImages or VMImage.
-
#initialize(connection) ⇒ Images
constructor
A new instance of Images.
- #is_os_image(image_name) ⇒ Object
- #is_vm_image(image_name) ⇒ Object
- #load ⇒ Object
Constructor Details
#initialize(connection) ⇒ Images
Returns a new instance of Images.
21 22 23 |
# File 'lib/azure/service_management/image.rb', line 21 def initialize(connection) @connection=connection end |
Instance Method Details
#all ⇒ Object
33 34 35 |
# File 'lib/azure/service_management/image.rb', line 33 def all self.load.values end |
#exists?(name) ⇒ Boolean
69 70 71 |
# File 'lib/azure/service_management/image.rb', line 69 def exists?(name) self.all.detect {|img| img.name == name} ? true : false end |
#find(name) ⇒ Object
73 74 75 |
# File 'lib/azure/service_management/image.rb', line 73 def find(name) self.load[name] end |
#get_images(img_type) ⇒ Object
img_type = OSImages or VMImage
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/azure/service_management/image.rb', line 38 def get_images(img_type) images = Hash.new if(img_type == "OSImage") response = @connection.query_azure('images') elsif(img_type == "VMImage") response = @connection.query_azure('vmimages') end unless response.to_s.empty? osimages = response.css(img_type) osimages.each do |image| item = Image.new(image) images[item.name] = item end end images end |
#is_os_image(image_name) ⇒ Object
59 60 61 62 |
# File 'lib/azure/service_management/image.rb', line 59 def is_os_image(image_name) os_images = self.get_images("OSImage").values os_images.detect {|img| img.name == image_name} ? true : false end |
#is_vm_image(image_name) ⇒ Object
64 65 66 67 |
# File 'lib/azure/service_management/image.rb', line 64 def is_vm_image(image_name) vm_images = self.get_images("VMImage").values vm_images.detect {|img| img.name == image_name} ? true : false end |
#load ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/azure/service_management/image.rb', line 24 def load @images ||= begin osimages = self.get_images("OSImage") #get OSImages vmimages = self.get_images("VMImage") #get VMImages all_images = osimages.merge(vmimages) end end |