Skip to content

Commit

Permalink
Use device_name for cdrom reconfigure.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed Aug 28, 2018
1 parent 0ca49d5 commit fc457e1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,29 +231,6 @@ ManageIQ.angular.app.controller('reconfigureFormController', ['$http', '$scope',
vm.reconfigureModel.vmRemoveNetworkAdapters.length > 0;
};

vm.updateCDRomsConnectDisconnect = function() {
vm.reconfigureModel.vmConnectCDRoms = [];
vm.reconfigureModel.vmDisconnectCDRoms = [];

angular.forEach(vm.reconfigureModel.vmCDRoms, function(cdRom) {
if (cdRom.connect_disconnect === 'disconnect') {
vm.reconfigureModel.vmDisconnectCDRoms.push({
name: cdRom.hdFilename,
});
}
if (cdRom.connect_disconnect === 'connect') {
vm.reconfigureModel.vmConnectCDRoms.push({
name: cdRom.name,
filename: cdRom.filename,
storage_id: cdRom.storage_id,
});
}
});
vm.cb_cdRoms = vm.reconfigureModel.vmConnectCDRoms.length > 0 ||
vm.reconfigureModel.vmDisconnectCDRoms.length > 0;
};


vm.resetAddValues = function() {
vm.reconfigureModel.hdType = vm.disk_default_type;
vm.reconfigureModel.hdMode = 'persistent';
Expand Down Expand Up @@ -441,8 +418,13 @@ ManageIQ.angular.app.controller('reconfigureFormController', ['$http', '$scope',
vm.cancelAddRemoveDisk(disk);
});

angular.forEach(vm.reconfigureModel.vmCDRoms, function(cd) {
vm.cancelCDRomConnectDisconnect(cd);
});

$scope.angularForm.$setPristine(true);
vm.updateDisksAddRemove();
vm.updateCDRomsConnectDisconnect();

miqService.miqFlash('warn', __('All changes have been reset'));
};
Expand Down Expand Up @@ -527,15 +509,15 @@ ManageIQ.angular.app.controller('reconfigureFormController', ['$http', '$scope',
angular.forEach(vm.reconfigureModel.vmCDRoms, function(cdRom) {
if (cdRom.connect_disconnect === 'connect') {
vm.reconfigureModel.vmConnectCDRoms.push(
{ name: cdRom.name,
{ device_name: cdRom.device_name,
filename: cdRom.filename,
storage_id: cdRom.storage_id,
}
);
}
if (cdRom.connect_disconnect === 'disconnect') {
vm.reconfigureModel.vmDisconnectCDRoms.push(
{ name: cdRom.name });
{ device_name: cdRom.device_name });
}
});
vm.cb_cdRoms = vm.reconfigureModel.vmConnectCDRoms.length > 0 ||
Expand Down Expand Up @@ -568,12 +550,9 @@ ManageIQ.angular.app.controller('reconfigureFormController', ['$http', '$scope',

vm.cancelCDRomConnectDisconnect = function(vmCDRom) {
var index = vm.reconfigureModel.vmCDRoms.indexOf(vmCDRom);
if (vmCDRom.connect_disconnect === "disconnect") {
vmCDRom.filename = vmCDRom.orgFilename;
}
vmCDRom.filename = vmCDRom.orgFilename;
vmCDRom.connect_disconnect = '';
vm.reconfigureModel.vmCDRoms[index].connect_disconnect = '';
vm.updateCDRomsConnectDisconnect();
};

init();
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/mixins/actions/vm_actions/reconfigure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,20 @@ def build_request_cdroms_list(cdroms)
connect_disconnect = ''
cdroms.map do |cd|
id = cd.id
name = cd.device_name
device_name = cd.device_name
type = cd.device_type
filename = cd.filename
storage_id = cd.storage_id
if cd.filename && @req.options[:cdrom_disconnect]&.find { |d_cd| d_cd[:name] == cd.device_name }
if cd.filename && @req.options[:cdrom_disconnect]&.find { |d_cd| d_cd[:device_name] == cd.device_name }
filename = ''
connect_disconnect = 'disconnect'
end
conn_cd = @req.options[:cdrom_connect]&.find { |c_cd| c_cd[:name] == cd.device_name }
conn_cd = @req.options[:cdrom_connect]&.find { |c_cd| c_cd[:device_name] == cd.device_name }
if cd.filename && conn_cd
filename = conn_cd[:filename]
connect_disconnect = 'connect'
end
vmcdroms << {:id => id, :name => name, :filename => filename, :type => type, :storage_id => storage_id, :connect_disconnect => connect_disconnect}
vmcdroms << {:id => id, :device_name => device_name, :filename => filename, :type => type, :storage_id => storage_id, :connect_disconnect => connect_disconnect}
end
vmcdroms
end
Expand Down Expand Up @@ -328,11 +328,11 @@ def build_vmcdrom_list(vm)
if cdroms.present?
cdroms.map do |cd|
id = cd.id
name = cd.device_name
device_name = cd.device_name
type = cd.device_type
filename = cd.filename
storage_id = cd.storage_id
vmcdroms << {:id => id, :name => name, :filename => filename, :type => type, :storage_id => storage_id}
filename = cd.filename.blank? || cd.filename == '[]' ? '' : cd.filename.to_s
storage_id = cd.storage_id || ''
vmcdroms << {:id => id, :device_name => device_name, :filename => filename, :type => type, :storage_id => storage_id}
end
vmcdroms
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/vm_common/_reconfigure.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
%tr{"ng-repeat" => "cdRom in vm.reconfigureModel.vmCDRoms",
"ng-class" => "{'danger': cdRom.connected_status == 'disconnected', 'active': cdRom.connected_status == 'connected'}"}
%td
{{cdRom.name}}
{{cdRom.device_name}}
%td{"ng-if" => "cdRom.connect_disconnect != 'connecting'"}
{{cdRom.filename}}
%td{"ng-if" => "cdRom.connect_disconnect == 'connecting'"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('reconfigureFormController', function() {
cores_per_socket_count: '3',
disks: [{hdFilename: "test_disk.vmdk", hdType: "thick", hdMode: "persistent", new_controller_type: "VirtualLsiLogicController", hdSize: "0", hdUnit: "MB", add_remove: ""}],
network_adapters: [{name: "Network adapter 1", vlan: "test_network", mac: "00:00:00:00:00:00", add_remove: ""}],
cdroms: [{name: "CDROM 1", filename: "test_filename.iso", storage_id: '5', connect_disconnect: ""}],
cdroms: [{device_name: "CDROM 1", filename: "test_filename.iso", storage_id: '5', connect_disconnect: ""}],
vm_vendor: 'vm-vendor',
vm_type: 'vm-type',
disk_default_type: 'disk-default-type'};
Expand Down

0 comments on commit fc457e1

Please sign in to comment.