diff --git a/app/controllers/api/base_controller/parameters.rb b/app/controllers/api/base_controller/parameters.rb index 8b1fd860365..ba095dfc669 100644 --- a/app/controllers/api/base_controller/parameters.rb +++ b/app/controllers/api/base_controller/parameters.rb @@ -35,16 +35,6 @@ def search_option?(what) search_options.map(&:downcase).include?(what.to_s) end - def decorator_selection - params['decorators'].to_s.split(",") - end - - def decorator_selection_for(collection) - decorator_selection.collect do |attr| - /\A#{collection}\.(?.*)\z/.match(attr) { |m| m[:name] } - end.compact - end - def attribute_selection if !@req.attributes.empty? || @additional_attributes @req.attributes | Array(@additional_attributes) | ID_ATTRS diff --git a/app/controllers/api/subcollections/vms.rb b/app/controllers/api/subcollections/vms.rb index 93cd6d3fc91..cc8a28f7895 100644 --- a/app/controllers/api/subcollections/vms.rb +++ b/app/controllers/api/subcollections/vms.rb @@ -23,6 +23,16 @@ def vms_query_resource(object) private + def decorator_selection + params['decorators'].to_s.split(",") + end + + def decorator_selection_for(collection) + decorator_selection.collect do |attr| + /\A#{collection}\.(?.*)\z/.match(attr) { |m| m[:name] } + end.compact + end + def create_vm_attributes_hash(vm_attrs, vm) vm_attrs.each_with_object({}) do |attr, hash| hash[attr] = vm.public_send(attr.to_sym) if vm.respond_to?(attr.to_sym) @@ -30,9 +40,14 @@ def create_vm_attributes_hash(vm_attrs, vm) end def create_vm_decorators_hash(vm_decorators, vm) - vm_decorators.each_with_object({}) do |name, hash| - hash[name] = vm.decorate.public_send(name.to_sym) if vm.decorate.respond_to?(name.to_sym) - end.compact + hash = {} + if vm_decorators.include? 'supports_console?' + hash['supports_console?'] = vm.supports_console? + end + if vm_decorators.include? 'supports_cockpit?' + hash['supports_cockpit?'] = vm.supports_launch_cockpit? + end + hash end end end diff --git a/app/models/mixins/supports_feature_mixin.rb b/app/models/mixins/supports_feature_mixin.rb index e9c35db0c1f..acc680a2f23 100644 --- a/app/models/mixins/supports_feature_mixin.rb +++ b/app/models/mixins/supports_feature_mixin.rb @@ -75,6 +75,7 @@ module SupportsFeatureMixin :create_host_aggregate => 'Host Aggregate Creation', :create_network_router => 'Network Router Creation', :create_security_group => 'Security Group Creation', + :console => 'Remote Console', :external_logging => 'Launch External Logging UI', :swift_service => 'Swift storage service', :delete => 'Deletion', diff --git a/app/models/vm_or_template.rb b/app/models/vm_or_template.rb index 9cfe9be3649..d0ac1b223e9 100644 --- a/app/models/vm_or_template.rb +++ b/app/models/vm_or_template.rb @@ -1835,6 +1835,12 @@ def tenant_identity user end + supports :console do + unless console_supported?('spice') || console_supported?('vnc') + unsupported_reason_add(:console, N_("Console not supported")) + end + end + private def set_tenant_from_group