Class: OCCI::Backend::OpenNebula::OpenNebula

Inherits:
Object
  • Object
show all
Includes:
Compute, Network, Storage
Defined in:
lib/occi/backend/opennebula/opennebula.rb

Overview


Constant Summary

INFO_ACL =

The ACL level to be used when querying resource in OpenNebula: - INFO_ALL returns all resources and works only when running under the oneadmin account - INFO_GROUP returns the resources of the account + his group (= default) - INFO_MINE returns only the resources of the account

OpenNebula::Pool::INFO_GROUP
OPERATIONS =

Operation mappings

{}

Constants included from Storage

Storage::TEMPLATESTORAGERAWFILE

Constants included from Network

Network::TEMPLATENETWORKRAWFILE

Constants included from Compute

Compute::TEMPLATECOMPUTERAWFILE

Instance Method Summary (collapse)

Methods included from Storage

#storage_action_dummy, #storage_backup, #storage_delete, #storage_deploy, #storage_offline, #storage_online, #storage_parse_backend_object, #storage_register_all_instances, #storage_resize, #storage_set_state, #storage_snapshot

Methods included from Network

#network_action_dummy, #network_delete, #network_deploy, #network_down, #network_parse_backend_object, #network_register_all_instances, #network_set_state, #network_up

Methods included from Compute

#compute_action_dummy, #compute_delete, #compute_deploy, #compute_parse_backend_object, #compute_parse_links, #compute_register_all_instances, #compute_register_all_objects, #compute_register_all_templates, #compute_restart, #compute_set_state, #compute_start, #compute_stop, #compute_suspend

Constructor Details

- (OpenNebula) initialize(user, password)




141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/occi/backend/opennebula/opennebula.rb', line 141

def initialize(user, password)

  # TODO: create mixins from existing templates

  # initialize OpenNebula connection
  OCCI::Log.debug("### Initializing connection with OpenNebula")

  # TODO: check for error!
  #       @one_client = Client.new(OCCI::Server.config['one_user'] + ':' + OCCI::Server.config['one_password'], OCCI::Server.config['one_xmlrpc'])
  @one_client = Client.new(user + ':' + password, OCCI::Server.config['one_xmlrpc'])

end

Instance Method Details

- (Object) check_rc(rc)




121
122
123
124
125
126
# File 'lib/occi/backend/opennebula/opennebula.rb', line 121

def check_rc(rc)
  if rc.class == Error
    raise OCCI::BackendError, "Error message from OpenNebula: #{rc.to_str}"
    # TODO: return failed!
  end
end

- (Object) generate_occi_id(kind, seed_id)


Generate a new occi id for resources created directly in OpenNebula using a seed id and the kind identifier



130
131
132
133
134
# File 'lib/occi/backend/opennebula/opennebula.rb', line 130

def generate_occi_id(kind, seed_id)
  # Use strings as kind ids
  kind = kind.type_identifier if kind.kind_of?(OCCI::Core::Kind)
  return UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, "#{kind}:#{seed_id}").to_s
end

- (Object) os_template_register




170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/occi/backend/opennebula/opennebula.rb', line 170

def os_template_register
  backend_object_pool=TemplatePool.new(@one_client, INFO_ACL)
  backend_object_pool.info
  backend_object_pool.each do |backend_object|
    related = OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure#os_tpl')
    term = backend_object['NAME'].downcase.chomp.gsub(/\W/, '_')
    # TODO: implement correct schema for service provider
    scheme = "http://schemas.opennebula.org/occi/infrastructure/os_tpl#"
    title = backend_object['NAME']
    mixin = OCCI::Core::Mixin.new(:related => related, :term=>term, :scheme=>scheme,:title=>title)
    OCCI::CategoryRegistry.register(mixin)
  end
end

- (Object) register_existing_resources




155
156
157
158
159
160
161
162
# File 'lib/occi/backend/opennebula/opennebula.rb', line 155

def register_existing_resources
  # get all compute objects
  resource_template_register
  os_template_register
  compute_register_all_instances
  network_register_all_instances
  storage_register_all_instances
end

- (Object) resource_template_register




165
166
167
# File 'lib/occi/backend/opennebula/opennebula.rb', line 165

def resource_template_register
  # currently not directly supported by OpenNebula
end