Esempio n. 1
0
class Task(SerializerMixin, db.Model):
    __tablename__ = "task"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=False, default='')
    created = db.Column(db.DateTime, nullable=False, server_default=func.now())
    updated = db.Column(db.DateTime, onupdate=func.now())
    started = db.Column(db.DateTime)
    finished = db.Column(db.DateTime)

    node_id = db.Column(db.Integer, db.ForeignKey('node.id'), nullable=True)
    node = db.relationship("Node",
                           backref=db.backref("tasks", lazy=True),
                           uselist=False)

    task_group_id = db.Column(db.Integer,
                              db.ForeignKey('task_group.id'),
                              nullable=False)
    task_group = db.relationship("TaskGroup",
                                 backref=db.backref("tasks", lazy=True))

    task_type = db.Column(db.String(16), nullable=False, default='')
    status = db.Column(db.Enum(TaskStatus),
                       nullable=False,
                       default=TaskStatus.QUEUED)
    order = db.Column(db.Integer, default=1)
    message = db.Column(db.String(4096), nullable=True, default='')
Esempio n. 2
0
class HypervisorManager(SerializerMixin, db.Model):
    __tablename__ = "hypervisor_manager"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=False, default='')
    created = db.Column(db.DateTime, nullable=False, server_default=func.now())
    updated = db.Column(db.DateTime)

    api_url = db.Column(db.String(256), nullable=False, default='')
    manager_type = db.Column(db.String(64), nullable=False, default='')

    allow_insecure = db.Column(db.Boolean, nullable=False, default=False)
    username = db.Column(db.String(256), nullable=False, default='')
    password = db.Column(db.String(256), nullable=False, default='')

    def load_vms(self):
        if self.manager_type == 'ovirt':
            connection = ovirt.connection.get_connection(
                self.api_url, self.username, self.password, True)
            hvm_vms = ovirt.system.get_vms(connection)
            connection.close()
            logger.info("Loaded %s vms" % len(hvm_vms))
            core_vm.update_vms(hvm_vms, hvm_id=self.id)
            logger.info("Updating VMs finished ...")
            return len(hvm_vms)

        raise UnsupportedHypervisorManagerAction(self.manager_type,
                                                 "loading vms")
Esempio n. 3
0
class HypervisorManager(SerializerMixin, db.Model):
    __tablename__ = "hypervisor_manager"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=False, default='')
    created = db.Column(db.DateTime, nullable=False, server_default=func.now())
    updated = db.Column(db.DateTime)

    api_url = db.Column(db.String(256), nullable=False, default='')
    manager_type = db.Column(db.String(64), nullable=False, default='')
Esempio n. 4
0
class Node(SerializerMixin, db.Model):
    __tablename__ = "node"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=False, default='')
    created = db.Column(db.DateTime, nullable=False, server_default=func.now())
    updated = db.Column(db.DateTime, onupdate=func.now())

    ip_addr = db.Column(db.String(64), nullable=False, default='')
    state = db.Column(db.String(16), nullable=False, default='')
    watchdog = db.Column(db.DateTime)
Esempio n. 5
0
class Vm(SerializerMixin, db.Model):
    __tablename__ = "vm"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=False, default='')
    created = db.Column(db.DateTime, nullable=False, server_default=func.now())
    updated = db.Column(db.DateTime, onupdate=func.now())

    uuid = db.Column(db.String(256), nullable=False, default='')
    last_replication = db.Column(db.DateTime)

    datacenter_id = db.Column(db.Integer, db.ForeignKey('datacenter.id'), nullable=False)
    cluster_id = db.Column(db.Integer, db.ForeignKey('cluster.id'), nullable=False)
    hypervisor_id = db.Column(db.Integer, db.ForeignKey('hypervisor.id'), nullable=False)
    hypervisor_manager_id = db.Column(db.Integer, db.ForeignKey('hypervisor_manager.id'), nullable=False)

    datacenter = db.relationship("Datacenter", backref=db.backref("vms", lazy=True))
    cluster = db.relationship("Cluster", backref=db.backref("vms", lazy=True))
    hypervisor = db.relationship("Hypervisor", backref=db.backref("vms", lazy=True))
    hypervisor_manager = db.relationship("HypervisorManager", backref=db.backref("vms", lazy=True))
Esempio n. 6
0
class Cluster(SerializerMixin, db.Model):
    __tablename__ = "cluster"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=True, default='')
    created = db.Column(db.DateTime, nullable=False, server_default=func.now())
    updated = db.Column(db.DateTime, onupdate=func.now())