コード例 #1
0
ファイル: models.py プロジェクト: mastermind1981/sahara-1
class Cluster(mb.SaharaBase):
    """Contains all info about cluster."""

    __tablename__ = 'clusters'

    __table_args__ = (sa.UniqueConstraint('name', 'tenant_id'), )

    id = _id_column()
    name = sa.Column(sa.String(80), nullable=False)
    description = sa.Column(sa.Text)
    tenant_id = sa.Column(sa.String(36))
    trust_id = sa.Column(sa.String(36))
    is_transient = sa.Column(sa.Boolean, default=False)
    plugin_name = sa.Column(sa.String(80), nullable=False)
    hadoop_version = sa.Column(sa.String(80), nullable=False)
    cluster_configs = sa.Column(st.JsonDictType())
    default_image_id = sa.Column(sa.String(36))
    neutron_management_network = sa.Column(sa.String(36))
    anti_affinity = sa.Column(st.JsonListType())
    management_private_key = sa.Column(sa.Text, nullable=False)
    management_public_key = sa.Column(sa.Text, nullable=False)
    user_keypair_id = sa.Column(sa.String(80))
    status = sa.Column(sa.String(80))
    status_description = sa.Column(st.LongText())
    info = sa.Column(st.JsonDictType())
    extra = sa.Column(st.JsonDictType())
    rollback_info = sa.Column(st.JsonDictType())
    sahara_info = sa.Column(st.JsonDictType())
    use_autoconfig = sa.Column(sa.Boolean(), default=True)
    provision_progress = relationship('ClusterProvisionStep',
                                      cascade="all,delete",
                                      backref='cluster',
                                      lazy='joined')
    verification = relationship('ClusterVerification',
                                cascade="all,delete",
                                backref="cluster",
                                lazy='joined')
    node_groups = relationship('NodeGroup',
                               cascade="all,delete",
                               backref='cluster',
                               lazy='joined')
    cluster_template_id = sa.Column(sa.String(36),
                                    sa.ForeignKey('cluster_templates.id'))
    cluster_template = relationship('ClusterTemplate',
                                    backref="clusters",
                                    lazy='joined')
    shares = sa.Column(st.JsonListType())
    is_public = sa.Column(sa.Boolean())
    is_protected = sa.Column(sa.Boolean())
    domain_name = sa.Column(sa.String(255))

    def to_dict(self, show_progress=False):
        d = super(Cluster, self).to_dict()
        d['node_groups'] = [ng.to_dict() for ng in self.node_groups]
        d['provision_progress'] = [
            pp.to_dict(show_progress) for pp in self.provision_progress
        ]
        if self.verification:
            d['verification'] = self.verification[0].to_dict()
        return d
コード例 #2
0
def upgrade():
    op.alter_column('clusters',
                    'status_description',
                    type_=st.LongText(),
                    existing_nullable=True,
                    existing_server_default=None)