CloudStack currently does not allow an easy way to add new guest OS types, for example, a standard way to add say, CentOS 6.5.
Part of the reason is since the OS to hypervisor-specific platform mappings are currently hard-coded into the code-base (e.g : https://github.com/apache/cloudstack/blob/master/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java)
To support such new OS addition, the current way is to manipulate the DB using upgrade scripts and make the necessary code changes.
This proposal aims to partially mitigate this issue by allowing the CloudStack admin the ability to add new OS in the list, and update the mapping to hypervisor-specific platform names, via APIs / UI. For now, the admin will be responsible for providing the mapping to hypervisor-specific platform names based on his knowledge, which may be enhanced in future.
At the core, the mappings will be stored in a table in DB.The table guest_os_hypervisor may be reused for this purpose (it is not being used elsewhere)
To accommodate Xen specifics (mappings are version specific in some cases), the hypervisor version will be stored in the table too.
Additionally, a table will be needed to store the available platform emulators for a hypervisor.
The admin is responsible for passing the right mapping.
The VM TO will contain an additional field to contain the platform emulator name (i.e. the mapping value). This change is implemented in the TO since the resource layer cannot talk to the DB, and TO is the only way to communicate the mapping.
In addition, the snapshot commands use this mapping too. The commands sent to the agent will contain the corresponding mapping needed.
In case a mapping is not found, we let the hypervisor take the decision to error out or not.
Since the OS and mappings are soft-deleted (i.e., use the "removed" column as standardized by the DAO layer), it will conform to the user-view of mappings while the command is being executed.
The APIs needed are :
The APIs will not allow for duplicate guest OS -> platform emulator mappings for a specific hypervisor.
All the APIs, other than list, shall be async APIs.
The APIs above are sufficient to implement a UI on top of this.
listOsMapping
{"count"=>1, "guestosmapping"=>[{"id"=>"3ef8e918-aa14-11e3-9293-8674b42bba24", "hypervisor"=>"XenServer", "hypervisorversion"=>"default", "ostypeid"=>"35b4370e-aa14-11e3-9293-8674b42bba24", "osdisplayname"=>"CentOS 4.5 (32-bit)", "osnameforhypervisor"=>"CentOS 4.5 (32-bit)"}}
addGuestOs
{"accountid"=>"acc29016-a947-11e3-9293-8674b42bba24", "userid"=>"acc2dfe4-a947-11e3-9293-8674b42bba24", "cmd"=>"org.apache.cloudstack.api.command.admin.guest.AddGuestOsCmd", "jobstatus"=>1, "jobprocstatus"=>0, "jobresultcode"=>0, "jobresulttype"=>"object", "jobresult"=>{"ostype"=>{"id"=>"8c6eaca7-6bd5-4600-8524-62d66e4a1913", "oscategoryid"=>"abdbfeee-a947-11e3-9293-8674b42bba24", "description"=>"amoghtestasync"}}, "created"=>"2014-03-11T15:09:57-0700", "jobid"=>"fcad9481-9de2-4443-b456-b26a94acd9f2"}
updateGuestOs
{"accountid"=>"acc29016-a947-11e3-9293-8674b42bba24", "userid"=>"acc2dfe4-a947-11e3-9293-8674b42bba24", "cmd"=>"org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsCmd", "jobstatus"=>1, "jobprocstatus"=>0, "jobresultcode"=>0, "jobresulttype"=>"object", "jobresult"=>{"ostype"=>{"id"=>"8c6eaca7-6bd5-4600-8524-62d66e4a1913", "oscategoryid"=>"abdbfeee-a947-11e3-9293-8674b42bba24", "description"=>"Windows XP SP2 (32-bitss)"}}, "created"=>"2014-03-11T15:11:09-0700", "jobid"=>"327c83a6-2af5-45bf-bbe2-b609762f42a8"}
removeGuestOs
{"accountid"=>"acc29016-a947-11e3-9293-8674b42bba24", "userid"=>"acc2dfe4-a947-11e3-9293-8674b42bba24", "cmd"=>"org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsCmd", "jobstatus"=>1, "jobprocstatus"=>0, "jobresultcode"=>0, "jobresulttype"=>"object", "jobresult"=>{"success"=>true}, "created"=>"2014-03-11T15:11:36-0700", "jobid"=>"00baa71f-0af5-40f5-884a-b60a6af1224a"}
addGuestOsMapping
{"accountid"=>"acc29016-a947-11e3-9293-8674b42bba24", "userid"=>"acc2dfe4-a947-11e3-9293-8674b42bba24", "cmd"=>"org.apache.cloudstack.api.command.admin.guest.AddGuestOsMappingCmd", "jobstatus"=>1, "jobprocstatus"=>0, "jobresultcode"=>0, "jobresulttype"=>"object", "jobresult"=>{"guestosmapping"=>{"id"=>"73bd536f-a5ee-4a9a-b14d-5d9bc9040be8", "hypervisor"=>"KVM", "hypervisorversion"=>"default", "ostypeid"=>"abe1a236-a947-11e3-9293-8674b42bba24", "osdisplayname"=>"CentOS 6.4 (64-bit)", "osnameforhypervisor"=>"amoghtestxen"}}, "created"=>"2014-03-11T15:13:06-0700", "jobid"=>"b7e444de-f998-42a5-885c-861a200ea229"}
updateGuestOsMapping
{"accountid"=>"acc29016-a947-11e3-9293-8674b42bba24", "userid"=>"acc2dfe4-a947-11e3-9293-8674b42bba24", "cmd"=>"org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsMappingCmd", "jobstatus"=>1, "jobprocstatus"=>0, "jobresultcode"=>0, "jobresulttype"=>"object", "jobresult"=>{"guestosmapping"=>{"id"=>"73bd536f-a5ee-4a9a-b14d-5d9bc9040be8", "hypervisor"=>"KVM", "hypervisorversion"=>"default", "ostypeid"=>"abe1a236-a947-11e3-9293-8674b42bba24", "osdisplayname"=>"CentOS 6.4 (64-bit)", "osnameforhypervisor"=>"amoghsname"}}, "created"=>"2014-03-11T15:14:51-0700", "jobid"=>"3abbcb0a-b9b4-46cf-aafd-bedc2b2f0399"}
removeGuestOsMapping
{"accountid"=>"acc29016-a947-11e3-9293-8674b42bba24", "userid"=>"acc2dfe4-a947-11e3-9293-8674b42bba24", "cmd"=>"org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsMappingCmd", "jobstatus"=>1, "jobprocstatus"=>0, "jobresultcode"=>0, "jobresulttype"=>"object", "jobresult"=>{"success"=>true}, "created"=>"2014-03-11T15:16:06-0700", "jobid"=>"d38b54b6-fec4-4eef-b1df-e0112c87389f"}
Schema shall be changed as :
ALTER TABLE `cloud`.`guest_os_hypervisor` ADD COLUMN `hypervisor_version` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Hypervisor version for this mapping'; ALTER TABLE `cloud`.`guest_os_hypervisor` ADD COLUMN `uuid` varchar(40) COMMENT 'UUID of the mapping'; ALTER TABLE `cloud`.`guest_os_hypervisor` ADD CONSTRAINT `uc_guest_os_hypervisor__uuid` UNIQUE (`uuid`); ALTER TABLE `cloud`.`guest_os_hypervisor` ADD COLUMN `created` datetime COMMENT 'Time when mapping was created'; ALTER TABLE `cloud`.`guest_os_hypervisor` ADD COLUMN `removed` datetime COMMENT 'Time when mapping was removed if deleted, else NULL'; UPDATE `cloud`.`guest_os_hypervisor` SET `uuid` = UUID(); UPDATE `cloud`.`guest_os_hypervisor` SET `created` = now();
GUEST_OS table changes :
ALTER TABLE `cloud`.`guest_os` ADD COLUMN `created` datetime COMMENT 'Time when Guest OS was created in system'; ALTER TABLE `cloud`.`guest_os` ADD COLUMN `removed` datetime COMMENT 'Time when Guest OS was removed if deleted, else NULL'; UPDATE `cloud`.`guest_os` SET `created` = now();
The ResourceBase / OsMapper files will load the mappings from DB, via the respective Gurus.
The dev mail thread is here :
7 Comments
Alex Huang
Today, it's hard-coded so it's actually much worse than stated.
Amogh Vasekar
Amogh Vasekar
1. If the existing entries can be deleted by admins or not. And what would happen if the admin deletes the default entries and then upgrades to a newer version.
– This is a good point. Will change the table to add additional field "isSystemDefined" to distinguish. Admin specified mappings will override the defaults
2. If the mapping is in code as supposed to DB, then how would these APIs / UI help?
-- The hypervisor Gurus are being changed to address this
3. I am assuming this would work for all Hypervisors but this is not mentioned in the FS.
– Correct
4. Can you update the FS if the UI is going to make it or not?
-- There are no plans for UI for initial implementation
manasa
Amogh Vasekar
Manan Shah
Can you add some clarity on the following 3 questions:
Amogh Vasekar