Fuel UI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

release.py 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2013 Mirantis, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from copy import deepcopy
  16. from nailgun.objects.serializers.base import BasicSerializer
  17. class ReleaseSerializer(BasicSerializer):
  18. fields = (
  19. "id",
  20. "name",
  21. "version",
  22. "description",
  23. "operating_system",
  24. "modes_metadata",
  25. "roles_metadata",
  26. "tags_metadata",
  27. "state",
  28. "attributes_metadata",
  29. "vmware_attributes_metadata",
  30. "components_metadata"
  31. )
  32. @classmethod
  33. def serialize(cls, instance, fields=None):
  34. from nailgun.objects.release import Release
  35. release_dict = \
  36. super(ReleaseSerializer, cls).serialize(instance, fields)
  37. release_dict["is_deployable"] = Release.is_deployable(instance)
  38. return release_dict
  39. class ComponentSerializer(BasicSerializer):
  40. @classmethod
  41. def serialize(cls, instance):
  42. component = deepcopy(instance)
  43. # binds use for mapping components on cluster_attributes options,
  44. # it's only back-end logic and no need send it to client
  45. component.pop('bind', None)
  46. return component