Beispiel #1
0
    def obj_load_attr(self, attrname):
        if attrname not in LAZY_LOADED_ATTRS:
            raise exception.ObjectError(action='obj_load_attr',
                                        obj_name=self.name,
                                        obj_id=self.uuid,
                                        reason='unable to lazy-load %s' %
                                        attrname)

        self['cluster_template'] = ClusterTemplate.get_by_uuid(
            self._context, self.cluster_template_id)

        self.obj_reset_changes(['cluster_template'])
Beispiel #2
0
    def _from_db_object(cluster, db_cluster):
        """Converts a database entity to a formal object."""
        for field in cluster.fields:
            if field != 'cluster_template':
                cluster[field] = db_cluster[field]

        # Note(eliqiao): The following line needs to be placed outside the
        # loop because there is a dependency from cluster_template to
        # cluster_template_id. The cluster_template_id must be populated
        # first in the loop before it can be used to find the cluster_template.
        cluster['cluster_template'] = ClusterTemplate.get_by_uuid(
            cluster._context, cluster.cluster_template_id)

        cluster.obj_reset_changes()
        return cluster
Beispiel #3
0
    def _from_db_object(cluster, db_cluster):
        """Converts a database entity to a formal object."""
        for field in cluster.fields:
            if field != 'cluster_template':
                cluster[field] = db_cluster[field]

        # Note(eliqiao): The following line needs to be placed outside the
        # loop because there is a dependency from cluster_template to
        # cluster_template_id. The cluster_template_id must be populated
        # first in the loop before it can be used to find the cluster_template.
        cluster['cluster_template'] = ClusterTemplate.get_by_uuid(
            cluster._context, cluster.cluster_template_id)

        cluster.obj_reset_changes()
        return cluster