class ServiceUISerializer(ServiceDetailSerializer): actions = serializers.SerializerMethodField() components = serializers.SerializerMethodField() name = serializers.CharField(read_only=True) version = serializers.SerializerMethodField() action = CommonAPIURL(view_name='object-action') config = CommonAPIURL(view_name='object-config') concerns = ConcernItemUISerializer(many=True, read_only=True) main_info = serializers.SerializerMethodField() def get_actions(self, obj): act_set = Action.objects.filter(prototype=obj.prototype) self.context['object'] = obj self.context['service_id'] = obj.id actions = filter_actions(obj, act_set) acts = ActionShort(actions, many=True, context=self.context) return acts.data def get_components(self, obj): comps = ServiceComponent.objects.filter(service=obj, cluster=obj.cluster) return ComponentUISerializer(comps, many=True, context=self.context).data def get_version(self, obj): return obj.prototype.version def get_main_info(self, obj): return get_main_info(obj)
class ServiceDetailSerializer(ServiceSerializer): prototype_id = serializers.IntegerField(read_only=True) description = serializers.CharField(read_only=True) bundle_id = serializers.IntegerField(read_only=True) status = serializers.SerializerMethodField() monitoring = serializers.CharField(read_only=True) action = CommonAPIURL(read_only=True, view_name='object-action') config = CommonAPIURL(read_only=True, view_name='object-config') component = ObjectURL(read_only=True, view_name='component') imports = ObjectURL(read_only=True, view_name='service-import') bind = ObjectURL(read_only=True, view_name='service-bind') prototype = serializers.HyperlinkedIdentityField( view_name='service-type-details', lookup_field='prototype_id', lookup_url_kwarg='prototype_id', ) multi_state = StringListSerializer(read_only=True) concerns = ConcernItemSerializer(many=True, read_only=True) locked = serializers.BooleanField(read_only=True) group_config = GroupConfigsHyperlinkedIdentityField( view_name='group-config-list') def get_status(self, obj): return status_api.get_service_status(obj)
class AdcmDetailSerializer(AdcmSerializer): prototype_version = serializers.SerializerMethodField() bundle_id = serializers.IntegerField(read_only=True) config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') def get_prototype_version(self, obj): return obj.prototype.version
class AdcmDetailSerializer(AdcmSerializer): prototype_version = serializers.SerializerMethodField() bundle_id = serializers.IntegerField(read_only=True) config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') multi_state = StringListSerializer(read_only=True) concerns = ConcernItemSerializer(many=True, read_only=True) locked = serializers.BooleanField(read_only=True) def get_prototype_version(self, obj): return obj.prototype.version
class ServiceComponentDetailSerializer(ServiceComponentSerializer): constraint = serializers.JSONField(read_only=True) requires = serializers.JSONField(read_only=True) bound_to = serializers.JSONField(read_only=True) monitoring = serializers.CharField(read_only=True) status = serializers.SerializerMethodField() config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') def get_status(self, obj): return cm.status_api.get_component_status(obj.id)
class HostDetailSerializer(HostSerializer): bundle_id = serializers.IntegerField(read_only=True) status = serializers.SerializerMethodField() config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') prototype = hlink('host-type-details', 'prototype_id', 'prototype_id') multi_state = StringListSerializer(read_only=True) concerns = ConcernItemSerializer(many=True, read_only=True) locked = serializers.BooleanField(read_only=True) def get_status(self, obj): return cm.status_api.get_host_status(obj)
class ProviderDetailSerializer(ProviderSerializer): issue = serializers.SerializerMethodField() edition = serializers.CharField(read_only=True) license = serializers.CharField(read_only=True) bundle_id = serializers.IntegerField(read_only=True) prototype = hlink('provider-type-details', 'prototype_id', 'prototype_id') config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') upgrade = hlink('provider-upgrade', 'id', 'provider_id') host = hlink('provider-host', 'id', 'provider_id') def get_issue(self, obj): return cm.issue.get_issue(obj)
class ClusterHostDetailSerializer(ClusterHostSerializer): issue = serializers.SerializerMethodField() cluster_url = hlink('cluster-details', 'cluster_id', 'cluster_id') status = serializers.SerializerMethodField() monitoring = serializers.CharField(read_only=True) host_url = hlink('host-details', 'id', 'host_id') config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') def get_issue(self, obj): return cm.issue.get_issue(obj) def get_status(self, obj): return cm.status_api.get_host_status(obj.id)
class HostDetailSerializer(HostSerializer): # stack = serializers.JSONField(read_only=True) issue = serializers.SerializerMethodField() bundle_id = serializers.IntegerField(read_only=True) status = serializers.SerializerMethodField() config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') prototype = hlink('host-type-details', 'prototype_id', 'prototype_id') def get_issue(self, obj): return cm.issue.get_issue(obj) def get_status(self, obj): return cm.status_api.get_host_status(obj.id)
class ComponentDetailSerializer(ComponentSerializer): constraint = serializers.JSONField(read_only=True) requires = serializers.JSONField(read_only=True) bound_to = serializers.JSONField(read_only=True) bundle_id = serializers.IntegerField(read_only=True) monitoring = serializers.CharField(read_only=True) status = serializers.SerializerMethodField() action = CommonAPIURL(read_only=True, view_name='object-action') config = CommonAPIURL(read_only=True, view_name='object-config') prototype = hlink('component-type-details', 'prototype_id', 'prototype_id') multi_state = StringListSerializer(read_only=True) concerns = ConcernItemSerializer(many=True, read_only=True) locked = serializers.BooleanField(read_only=True) group_config = GroupConfigsHyperlinkedIdentityField( view_name='group-config-list') def get_status(self, obj): return status_api.get_component_status(obj)
class ClusterServiceDetailSerializer(ClusterServiceSerializer): prototype_id = serializers.IntegerField(read_only=True) # stack = serializers.JSONField(read_only=True) description = serializers.CharField(read_only=True) bundle_id = serializers.IntegerField(read_only=True) issue = serializers.SerializerMethodField() status = serializers.SerializerMethodField() monitoring = serializers.CharField(read_only=True) config = CommonAPIURL(view_name='object-config') action = CommonAPIURL(view_name='object-action') component = ClusterServiceUrlField(read_only=True, view_name='cluster-service-component') imports = ClusterServiceUrlField(read_only=True, view_name='cluster-service-import') bind = ClusterServiceUrlField(read_only=True, view_name='cluster-service-bind') prototype = hlink('service-type-details', 'prototype_id', 'prototype_id') def get_issue(self, obj): return cm.issue.get_issue(obj) def get_status(self, obj): return cm.status_api.get_service_status(obj.cluster.id, obj.id)
class ServiceDetailSerializer(ServiceSerializer): prototype_id = serializers.IntegerField(read_only=True) description = serializers.CharField(read_only=True) bundle_id = serializers.IntegerField(read_only=True) issue = serializers.SerializerMethodField() status = serializers.SerializerMethodField() monitoring = serializers.CharField(read_only=True) action = CommonAPIURL(read_only=True, view_name='object-action') config = CommonAPIURL(read_only=True, view_name='object-config') component = ServiceObjectUrlField(read_only=True, view_name='service-component') imports = ServiceObjectUrlField(read_only=True, view_name='service-import') bind = ServiceObjectUrlField(read_only=True, view_name='service-bind') prototype = serializers.HyperlinkedIdentityField( view_name='service-type-details', lookup_field='prototype_id', lookup_url_kwarg='prototype_id') def get_issue(self, obj): return issue.get_issue(obj) def get_status(self, obj): return status_api.get_service_status(obj.cluster.id, obj.id)
class ClusterDetailSerializer(ClusterSerializer): bundle_id = serializers.IntegerField(read_only=True) edition = serializers.CharField(read_only=True) license = serializers.CharField(read_only=True) action = CommonAPIURL(view_name='object-action') service = ObjectURL(view_name='service') host = ObjectURL(view_name='host') hostcomponent = hlink('host-component', 'id', 'cluster_id') status = serializers.SerializerMethodField() status_url = hlink('cluster-status', 'id', 'cluster_id') config = CommonAPIURL(view_name='object-config') serviceprototype = hlink('cluster-service-prototype', 'id', 'cluster_id') upgrade = hlink('cluster-upgrade', 'id', 'cluster_id') imports = hlink('cluster-import', 'id', 'cluster_id') bind = hlink('cluster-bind', 'id', 'cluster_id') prototype = hlink('cluster-type-details', 'prototype_id', 'prototype_id') multi_state = StringListSerializer(read_only=True) concerns = ConcernItemSerializer(many=True, read_only=True) locked = serializers.BooleanField(read_only=True) group_config = GroupConfigsHyperlinkedIdentityField( view_name='group-config-list') def get_status(self, obj): return cm.status_api.get_cluster_status(obj)
class ClusterDetailSerializer(ClusterSerializer): # stack = serializers.JSONField(read_only=True) issue = serializers.SerializerMethodField() bundle_id = serializers.IntegerField(read_only=True) edition = serializers.CharField(read_only=True) license = serializers.CharField(read_only=True) action = CommonAPIURL(view_name='object-action') service = hlink('cluster-service', 'id', 'cluster_id') host = hlink('cluster-host', 'id', 'cluster_id') hostcomponent = hlink('host-component', 'id', 'cluster_id') status = serializers.SerializerMethodField() status_url = hlink('cluster-status', 'id', 'cluster_id') config = CommonAPIURL(view_name='object-config') serviceprototype = hlink('cluster-service-prototype', 'id', 'cluster_id') upgrade = hlink('cluster-upgrade', 'id', 'cluster_id') imports = hlink('cluster-import', 'id', 'cluster_id') bind = hlink('cluster-bind', 'id', 'cluster_id') prototype = hlink('cluster-type-details', 'prototype_id', 'prototype_id') def get_issue(self, obj): return cm.issue.get_issue(obj) def get_status(self, obj): return cm.status_api.get_cluster_status(obj.id)
class HistoryCurrentPreviousConfigSerializer(serializers.Serializer): history = CommonAPIURL(read_only=True, view_name='config-history') current = CommonAPIURL(read_only=True, view_name='config-current') previous = CommonAPIURL(read_only=True, view_name='config-previous')