Skip to content

Commit

Permalink
F #6723: Remove onehost importvm (#3231)
Browse files Browse the repository at this point in the history
* Remove vm_import table from DB
* Remove imported vms actions
* Fix fsck for image and network
* onedb fsck fix running_vms only for non-backup images
  • Loading branch information
paczerny authored Nov 21, 2024
1 parent f4616d0 commit fa73142
Show file tree
Hide file tree
Showing 40 changed files with 68 additions and 1,300 deletions.
10 changes: 0 additions & 10 deletions include/DispatchManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ class DispatchManager : public Listener
int deploy(std::unique_ptr<VirtualMachine> vm,
const RequestAttributes& request);

/**
* Sets an imported VM to RUNNING state, a history record MUST be added,
* and the VM MUST be locked.
* @param vm pointer to a VirtualMachine with its mutex locked.
* @param ra information about the API call request
* @return 0 on success
*/
int import(std::unique_ptr<VirtualMachine> vm,
const RequestAttributes& ra);

/**
* Migrates a VM. The following actions must be performed before calling
* this function:
Expand Down
10 changes: 0 additions & 10 deletions include/OneDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ namespace one_db

extern const char * vm_template_table;

// -------------------------------------------------------------------------
// Virtual Machine ID - Deploy ID index for imported VMs
// The index is managed by the VirtualMachinePool
// -------------------------------------------------------------------------
extern const char * vm_import_table;

extern const char * vm_import_db_names;

extern const char * vm_import_db_bootstrap;

/* ---------------------------------------------------------------------- */
/* Cluster tables */
/* ---------------------------------------------------------------------- */
Expand Down
20 changes: 0 additions & 20 deletions include/VirtualMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -1191,26 +1191,6 @@ class VirtualMachine : public PoolObjectSQL
*/
void release_vmgroup();

// ------------------------------------------------------------------------
// Imported VM interface
// ------------------------------------------------------------------------
/**
* Check if the VM is imported
*/
bool is_imported() const;

/**
* Return state of the VM right before import
*/
std::string get_import_state() const;

/**
* Checks if the current VM MAD supports the given action for imported VMs
* @param action VM action to check
* @return true if the current VM MAD supports the given action for imported VMs
*/
bool is_imported_action_supported(VMActions::Action action) const;

// ------------------------------------------------------------------------
// Virtual Router related functions
// ------------------------------------------------------------------------
Expand Down
18 changes: 0 additions & 18 deletions include/VirtualMachineManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@ class VirtualMachineManager :
*/
int load_drivers(const std::vector<const VectorAttribute*>& _mads);

/**
* Check if action is supported for imported VMs
* @param mad name of the driver
* @param action
* @return True if it is supported
*/
bool is_imported_action_supported(const std::string& mad, VMActions::Action action)
{
const VirtualMachineManagerDriver * vmd = get(mad);

if ( vmd == nullptr )
{
return false;
}

return vmd->is_imported_action_supported(action);
}

/**
* Updates firewall rules of a VM
* @param vm pointer to VM, needs to be locked
Expand Down
19 changes: 0 additions & 19 deletions include/VirtualMachineManagerDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ class VirtualMachineManagerDriver : public Driver<vm_msg_t>
return 0;
}

/**
* Check if action is supported for imported VMs
* @param action
* @return True if it is supported
*/
bool is_imported_action_supported(VMActions::Action action) const
{
return imported_actions.is_set(action);
}

/**
* @return true if system snapshots are preserved
*/
Expand Down Expand Up @@ -264,20 +254,11 @@ class VirtualMachineManagerDriver : public Driver<vm_msg_t>
private:
friend class VirtualMachineManager;

static const std::string imported_actions_default;
static const std::string imported_actions_default_public;

/**
* Configuration file for the driver
*/
Template driver_conf;

/**
* List of available actions for imported VMs. Each bit is an action
* as defined in History.h, 1=supported and 0=not supported
*/
ActionSet<VMActions::Action> imported_actions;

/**
* Set to true if the hypervisor can keep system snapshots across
* create/delete cycles and live migrations.
Expand Down
37 changes: 1 addition & 36 deletions include/VirtualMachinePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ class VirtualMachinePool : public PoolSQL
*/
int update(PoolObjectSQL * objsql) override;

/**
* Gets a VM ID by its deploy_id, the dedploy_id - VM id mapping is keep
* in the import_table.
* @param deploy_id to search the id for
* @return -1 if not found or VMID
*
*/
int get_vmid(const std::string& deploy_id);

/**
* Function to get the IDs of running VMs
* @param oids a vector that contains the IDs
Expand Down Expand Up @@ -237,13 +228,7 @@ class VirtualMachinePool : public PoolSQL
*/
static int bootstrap(SqlDB * _db)
{
int rc;
std::ostringstream oss_import(one_db::vm_import_db_bootstrap);

rc = VirtualMachine::bootstrap(_db);
rc += _db->exec_local_wr(oss_import);

return rc;
return VirtualMachine::bootstrap(_db);
};

/**
Expand Down Expand Up @@ -421,12 +406,6 @@ class VirtualMachinePool : public PoolSQL
*/
void delete_attach_nic(std::unique_ptr<VirtualMachine> vm);

/**
* Deletes an entry in the HV-2-vmid mapping table for imported VMs
* @param deploy_id of the VM
*/
void drop_index(const std::string& deploy_id);

private:
/**
* Factory method to produce VM objects
Expand Down Expand Up @@ -457,20 +436,6 @@ class VirtualMachinePool : public PoolSQL
* note: datastore cost is always counted in poweroff and suspended state
*/
bool _showback_only_running;

/**
* Callback used to get an int in the DB it is used by VM Pool in:
* - calculate_showback (min_stime)
* - get_vmid (vmid)
*/
int db_int_cb(void * _min_stime, int num, char **values, char **names);

/**
* Insert deploy_id - vmid index.
* @param replace will replace and not insert
* @return 0 on success
*/
int insert_index(const std::string& deploy_id, int vm_id, bool replace);
};

#endif /*VIRTUAL_MACHINE_POOL_H_*/
1 change: 0 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,6 @@ VMM_EXEC_LIB_VCENTER_FILES="src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb
src/vmm_mad/remotes/lib/vcenter_driver/vm_template.rb \
src/vmm_mad/remotes/lib/vcenter_driver/network.rb \
src/vmm_mad/remotes/lib/vcenter_driver/vm_folder.rb \
src/vmm_mad/remotes/lib/vcenter_driver/vmm_importer.rb \
src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine_device/vm_device.rb \
src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine_device/vm_disk.rb \
src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine_device/vm_nic.rb \
Expand Down
1 change: 0 additions & 1 deletion share/doc/xsd/opennebula_configuration.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@
<xs:element name="ARGUMENTS" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="DEFAULT" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="EXECUTABLE" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="IMPORTED_VMS_ACTIONS" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="NAME" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="SUNSTONE_NAME" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="TYPE" type="xs:string" minOccurs="0" maxOccurs="1"/>
Expand Down
64 changes: 4 additions & 60 deletions share/etc/oned.conf
Original file line number Diff line number Diff line change
Expand Up @@ -418,46 +418,6 @@ IM_MAD = [
# live_resize: [yes|no] Hypervisor supports hotplug VCPU and memory
#
# support_shareable: [yes|no] Hypervisor supports shareable disks
#
# imported_vms_actions : comma-separated list of actions supported
# for imported vms. The available actions are:
# migrate
# live-migrate
# terminate
# terminate-hard
# undeploy
# undeploy-hard
# hold
# release
# stop
# suspend
# resume
# delete
# delete-recreate
# reboot
# reboot-hard
# resched
# unresched
# poweroff
# poweroff-hard
# disk-attach
# disk-detach
# nic-attach
# nic-detach
# disk-snapshot-create
# disk-snapshot-delete
# disk-snapshot-rename
# disk-snapshot-revert
# disk-resize
# disk-saveas
# resize
# update
# updateconf
# snapshot-create
# snapshot-delete
# snapshot-revert
# recover
# retry
#*******************************************************************************

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -486,11 +446,7 @@ VM_MAD = [
TYPE = "kvm",
KEEP_SNAPSHOTS = "yes",
LIVE_RESIZE = "yes",
SUPPORT_SHAREABLE = "yes",
IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend,
resume, delete, reboot, reboot-hard, resched, unresched, disk-attach,
disk-detach, nic-attach, nic-detach, snapshot-create, snapshot-delete,
resize, updateconf, update"
SUPPORT_SHAREABLE = "yes"
]

# This variant should be used for nested virtualization
Expand All @@ -503,11 +459,7 @@ VM_MAD = [
TYPE = "qemu",
KEEP_SNAPSHOTS = "yes",
LIVE_RESIZE = "yes",
SUPPORT_SHAREABLE = "yes",
IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend,
resume, delete, reboot, reboot-hard, resched, unresched, disk-attach,
disk-detach, nic-attach, nic-detach, snapshot-create, snapshot-delete,
resize, updateconf, update"
SUPPORT_SHAREABLE = "yes"
]
#-------------------------------------------------------------------------------

Expand All @@ -533,10 +485,7 @@ VM_MAD = [
ARGUMENTS = "-t 15 -r 0 lxc",
# DEFAULT = "vmm_exec/vmm_exec_lxc.conf",
TYPE = "xml",
KEEP_SNAPSHOTS = "no",
IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, reboot, reboot-hard,
poweroff, poweroff-hard, suspend, resume, stop, delete, nic-attach,
nic-detach, resize, updateconf, update"
KEEP_SNAPSHOTS = "no"
]
#-------------------------------------------------------------------------------

Expand All @@ -557,12 +506,7 @@ VM_MAD = [
# KEEP_SNAPSHOTS = "yes",
# DS_LIVE_MIGRATION = "yes",
# COLD_NIC_ATTACH = "yes",
# LIVE_RESIZE = "yes",
# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend,
# resume, delete, reboot, reboot-hard, resched, unresched, poweroff,
# poweroff-hard, disk-attach, disk-detach, disk-resize, nic-attach,
# nic-detach, snapshot-create, snapshot-delete, snapshot-revert, migrate,
# live-migrate, resize, updateconf, update, recover"
# LIVE_RESIZE = "yes"
#]
#-------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions share/shell/bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,14 @@ _onehost() {
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete enable disable offline update sync list show top flush
rename importvm forceupdate monitoring"
rename forceupdate monitoring"
cmd=onehost
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|disable|offline|update|sync|show|flush|rename|importvm| \
delete|disable|offline|update|sync|show|flush|rename| \
forceupdate|monitoring)
_complete $cmd
;;
Expand Down
7 changes: 4 additions & 3 deletions src/cli/one_helper/onehost_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def format_resource(host, _options = {})

format = '%-30.30s %36s %4s %10s'
CLIHelper.print_header(format(format, 'NAME',
'IMPORT_ID', 'CPU', 'MEMORY'),
'DEPLOY_ID', 'CPU', 'MEMORY'),
true)

wilds.each do |wild|
Expand All @@ -718,8 +718,9 @@ def format_resource(host, _options = {})
line[/CPU/]
end[0].split('=')[1].tr('"', ' ').strip
else
name = wild['DEPLOY_ID']
import = memory = cpu = '-'
name = wild['VM_NAME']
import = wild['DEPLOY_ID']
memory = cpu = '-'
end

puts format(format, name, import, cpu, memory)
Expand Down
17 changes: 0 additions & 17 deletions src/cli/onehost
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,6 @@ CommandParser::CmdParser.new(ARGV) do
end
end

importvm_desc = <<-EOT.unindent
Import VM to OpenNebula
EOT

command :importvm,
importvm_desc,
:hostid,
:name,
:options => [IPV4, IPV6] do
helper.perform_action(args[0], options, 'imported') do |o|
rc = o.info
next rc if OpenNebula.is_error?(rc)

o.import_wild(args[1], options[:ipv4], options[:ipv6])
end
end

forceupdate_desc = <<-EOT.unindent
Forces host monitoring update
Examples:
Expand Down
2 changes: 1 addition & 1 deletion src/cli/onevcenter
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ CommandParser::CmdParser.new(ARGV) do
vmid = args[0]
remove_str = "\n onevm recover --delete-db #{vmid}" \
"\n\nAfter a monitoring cycle, the VM will appear "\
'as a Wild VM for reimport.'
'as a Wild VM.'

print 'Extracting information from VM ' + vmid

Expand Down
Loading

0 comments on commit fa73142

Please sign in to comment.