validateImages: function()

in cloud-vmware-server/src/main/resources/buildServerResources/vmware-settings.js [856:899]


        validateImages: function () {
            var updateIcon = function (imageId, type, title, symbol) {
                var $icon = this.$imagesTable.find(this.selectors.imagesTableRow + '[data-image-id=' + imageId + '] .sourceIcon');

                $icon.removeClass().addClass('sourceIcon').removeAttr('title');

                switch (type) {
                    case 'error':
                        $icon
                            .addClass('sourceIcon_error')
                            .text(symbol || '!')
                            .attr('title', title);
                        break;
                    case 'info':
                        $icon
                            .text(symbol)
                            .attr('title', title);
                        break;
                    default:
                        $icon
                            .addClass('sourceIcon_unknown')
                            .text('?');
                }
            }.bind(this);

            Object.keys(this.imagesData).forEach(function (imageId) {
                var machine = this.imagesData[imageId],
                    name = machine.sourceVmName,
                    $machine = this._getSourceByName(name);

                if (! $machine.length) {
                    return updateIcon(imageId, 'error', 'Nonexistent source');
                }

                if (this._isTemplate($machine) && this.imagesData[imageId].behaviour === START_STOP) {
                    return updateIcon(imageId, 'error', this._errors.templateStart);
                }

                if (! machine.behaviour || (machine.behaviour !== START_STOP && ! machine.maxInstances)) {
                    return updateIcon(imageId, 'error', this._errors.badParam);
                }
                updateIcon(imageId, 'info', this._isTemplate($machine) ? 'Template' : 'Machine', this._isTemplate($machine) ? 'T' : 'M');
            }.bind(this));
        },