Project

General

Profile

Actions

Feature #1923

closed

support converting bare metal hosts to/from VMs on compute resources

Added by Joshua Hoblitt over 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Compute resources
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

There is presently now way to convert a host in foreman from bare metal to a VM (or vise versa). This is needed for p2v and v2p. At my site we also have some older VMs managed by foreman that were provisioned as if they were bare metal. In order to convert these existing hosts we need a new mechanism for telling foreman which compute resource the VMs are already on. I don't believe it's possible to add a virtual host to foreman for a preexisting VM at all as it will automatically try to provision it.

Perhaps one way of addressing this would be to add a dialog for creating a foreman host for an unmanaged VM that's visible to foreman on an already managed compute resource.


Files

patch patch 2.3 KB Anonymous, 07/19/2013 01:29 AM

Related issues 3 (0 open3 closed)

Related to Foreman - Bug #3795: "Associate VM's" Doesn't Re-associate when compute resource changesClosedAdam RuzickaActions
Related to Foreman - Feature #4155: API for CR association and disassociationClosed01/21/2014Actions
Has duplicate Foreman - Feature #1666: Ability to map a vm on an compute ressource with a regular host on ForemanClosed05/31/2012Actions
Actions #1

Updated by Oliver Weinmann almost 11 years ago

+10 for this feature. ;)

Actions #2

Updated by Ohad Levy almost 11 years ago

it should actually not be that hard, it could start as a rake task to compare MAC addresses, and later on with a UI.. any takers? :)

Actions #3

Updated by Ohad Levy almost 11 years ago

here is an example patch, it does not include UI nor rake task, but gives an example:


diff --git a/app/models/compute_resource.rb b/app/models/compute_resource.rb
index 7da5982..3c4dea2 100644
--- a/app/models/compute_resource.rb
+++ b/app/models/compute_resource.rb
@@ -176,6 +176,25 @@ class ComputeResource < ActiveRecord::Base
     []
   end

+  def import hosts
+    #fetch all vms
+
+    logger.debug 'fetching all vms'
+    vms = self.vms
+    hosts.where(:compute_resource_id => nil).each do |host|
+      # find host based on mac
+      logger.debug "searching vms that match #{host}" 
+      vm = vms.detect {|vm| vm.mac == host.mac if vm.respond_to?(:mac)}
+      if vm.present?
+        logger.debug "found match Host:#{host}, VM: #{vm}" 
+        host.compute_resource_id = self.id
+        host.uuid                = vm.identity
+        host.save(:validate => false) # don't want to trigger callbacks
+      end
+    end
+    true
+  end
+

it currently assume there is a mac address (so both facts already exists on foreman and fog knows how to respond to mac).

to use within the console:

ComputeResource.all.each {|cr| cr.import Host }
Actions #4

Updated by Anonymous almost 11 years ago

This would do similar in the UI.

Navigate to More>Provisioning>Compute Resources
Select a compute resource
Click on the Virtual Machines tab
If you click on a virtual machine whose identity is not store in the uuid for any host AND there is a host with the same mac address you will get a 'Manage' button
Click on it and it should tie the VM to your host.

Tested against RHEV and it worked for me. Would be interested to know if it works for anyone else on vmware, etc.

Actions #5

Updated by Ohad Levy over 10 years ago

Jason, would you mind sending this as a PR?

I would assume we need both levels (on the CR level as a whole, and per VM).

thanks!

Actions #6

Updated by Anonymous over 10 years ago

https://github.com/theforeman/foreman/pull/803

I change the patch a bit and made it so you can do all at once at the CR level or individual at the CR_VM level, as you suggested.

I can 'update hosts set uuid=NULL where id=*; update hosts set compute_resource_id=NULL;' in mysql and see all my hosts pretty much looking like bare metal, without a vm page, and without console/power management capabilities, etc. I can then either one by one or all at once reassign the CRID/VMUUID back and get all that stuff back.

Actions #7

Updated by Dominic Cleal over 10 years ago

  • Description updated (diff)
  • Category set to Compute resources
  • Status changed from New to Ready For Testing
  • Target version set to 1.3.0
  • Assignee set to Anonymous
Actions #8

Updated by Anonymous over 10 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #9

Updated by Dominic Cleal over 10 years ago

  • Has duplicate Feature #1666: Ability to map a vm on an compute ressource with a regular host on Foreman added
Actions #10

Updated by Dominic Cleal over 10 years ago

  • Related to Bug #3795: "Associate VM's" Doesn't Re-associate when compute resource changes added
Actions #11

Updated by Dominic Cleal about 10 years ago

  • Related to Feature #4155: API for CR association and disassociation added
Actions

Also available in: Atom PDF