Exemple #1
0
def upgradeTo2_0_1(update_from_version):
    print "Upgrading to 2.0.1..."
    from convirt.core.services.tasks \
        import RefreshNodeInfoTask, RefreshNodeMetricsTask,\
        Purging, CollectMetricsForNodes, TimeBasisRollupForNodes,\
        UpdateDeploymentStatusTask, CheckForUpdateTask,\
        EmailTask, UpdateDiskSize, NodeAvailTask, VMAvailTask
    node_avail_task = NodeAvailTask(u'Update node availability',\
                                    {'quiet':True}, [], {}, None, u'admin')
    node_avail_task.id = 8
    node_avail_task.interval = [model.TaskInterval(1)]
    model.DBSession.merge(node_avail_task)

    vm_avail_task = VMAvailTask(u'Update VM availability',\
                                {'quiet':True}, [], {}, None, u'admin')
    vm_avail_task.id = 9
    vm_avail_task.interval = [model.TaskInterval(1)]
    model.DBSession.merge(vm_avail_task)

    model.DBSession.flush()
#
    transaction.commit()

    from convirt.model.availability import AvailState
#        from convirt.model import DBSession
    from convirt.model.Groups import ServerGroup
    from convirt.model.ManagedNode import ManagedNode
    from convirt.model.VM import VM



    server_groups=model.DBSession.query(ServerGroup).all()
    for s_group in server_groups:
        s_group_avail= AvailState(s_group.id, None, \
                                 AvailState.MONITORING,\
                                description = u'New ServerPool')
        s_group.current_state=s_group_avail
        model.DBSession.add(s_group_avail)

    managed_nodes= model.DBSession.query(ManagedNode).all()

    for m_node in managed_nodes:
        m_node_avail=AvailState(m_node.id, ManagedNode.UP,\
                                    AvailState.MONITORING,\
                                    description=u"Newly created node.")

        m_node.current_state=m_node_avail
        model.DBSession.add(m_node_avail)



    vm_entities= model.DBSession.query(VM).all()

    for vm in vm_entities:
        vm_avail=AvailState(vm.id, VM.NOT_STARTED, \
                                    AvailState.NOT_MONITORING,\
                                    description = u'New VM')
        vm.current_state=vm_avail
        model.DBSession.add(vm_avail)

    print "Successfully upgraded to 2.0.1"
Exemple #2
0
    send_mail_task= EmailTask(u'EmailTask', {'quiet':True}, [],\
                    {}, None, u'admin')
    send_mail_task.id = 6
    send_mail_task.interval = [model.TaskInterval(2)]
    set_entity_details(send_mail_task, dc_ent)
    model.DBSession.merge(send_mail_task)

    update_disk_task = UpdateDiskSize(u'Updating the disk size',\
                 {'quiet':True}, [], {}, None, u'admin')
    update_disk_task.id = 7
    update_disk_interval = tg.config.get(constants.UPDATE_DISK_SIZE_INTERVAL)
    update_disk_task.interval = [model.TaskInterval(int(update_disk_interval))]
    set_entity_details(update_disk_task, dc_ent)
    model.DBSession.merge(update_disk_task)

    node_avail_task = NodeAvailTask(u'Update node availability',\
                                    {'quiet':True}, [], {}, None, u'admin')
    node_avail_task.id = 8
    node_avail_task.interval = [model.TaskInterval(1)]
    set_entity_details(node_avail_task, dc_ent)
    model.DBSession.merge(node_avail_task)

    vm_avail_task = VMAvailTask(u'Update VM availability',\
                                {'quiet':True}, [], {}, None, u'admin')
    vm_avail_task.id = 9
    vm_avail_task.interval = [model.TaskInterval(1)]
    set_entity_details(vm_avail_task, dc_ent)
    model.DBSession.merge(vm_avail_task)

    #below code is for deployment update to convirt periodically, comment it as there is no need for us
    # snd_dep_task = SendDeploymentStatsRptTask(u'Send Deployment Stats',\
    #                     {'quiet':True}, [], {}, None, u'admin')