示例#1
0
    def onSnap_list(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info(fila[8])

        #listado de snapshot en una ventana emergente

        self.my_dialogo_texto = dialogos.Dialogo_texto(
            None, -1, 'Listados de Snapshots')
        vm = conexion.searchIndex.FindByUuid(None, fila[8], True)
        snap_info = vm.snapshot
        self.my_dialogo_texto.salida_texto.SetValue('Maquna vm = ' + fila[1])
        snaptexto = 'Listado de snapshot \n'
        if not snap_info:
            self.my_dialogo_texto.salida_texto.SetValue('No hay snapshot')
            if logger != None: logger.info('No hay snapshot')
        else:
            tree = snap_info.rootSnapshotList
            while tree[0].childSnapshotList is not None:
                snaptexto = snaptexto + (
                    "Nombre Snap: {0} = description> {1}  \n".format(
                        tree[0].name, tree[0].description))
                if logger != None:
                    logger.info("Snap: {0} => {1}".format(
                        tree[0].name, tree[0].description))
                if len(tree[0].childSnapshotList) < 1:
                    break
                tree = tree[0].childSnapshotList
            self.my_dialogo_texto.salida_texto.SetValue(snaptexto)

        result = self.my_dialogo_texto.ShowModal(
        )  # pintamos la ventana con la informcion
        self.my_dialogo_texto.Destroy()
示例#2
0
def on_event_vm(self, event, conexion, logger):
    """
        Arg:
            event       (Var from menu)
            conexion    (Var whit a conexion datacenter)
            logger      (Var objet to pass the log)
        """
    fila = self.listadoVM
    #print (self, event, conexion)
    for i in range(len(fila)):
        if logger != None: logger.info(fila[i])

    # El 9 elemento es el UUID
    if logger != None: logger.info(fila[8])

    # List about vm detail in dialog box

    self.my_dialogo_texto = dialogos.Dialogo_texto(None, -1,
                                                   'Listados de Eventos VM')

    vm = conexion.searchIndex.FindByUuid(None, fila[8], True)
    if logger != None: logger.info('informacion vm: ' + vm.summary.config.name)

    snaptexto = "=====================\n "
    snaptexto += 'Maquna vm = ' + fila[1] + '\n'
    snaptexto += 'Triggerd: ' + str(
        alarm.print_triggered_alarms(entity=vm)) + '\n'
    snaptexto += 'Refs: ' + str(alarm.get_alarm_refs(entity=vm)) + '\n'

    # Since the above method will list all of the triggered alarms we will now
    # prompt the user for the entity info needed to reset an alarm from red
    # to green
    """
            if alarm.reset_alarm(entity_moref=HOST._moId,
                                 entity_type='HostSystem',
                                 alarm_moref=alarm_mor.strip(),
                                 service_instance=SI):
               snaptexto +="Successfully reset alarm {0} to green.".format(alarm_mor)"""

    snaptexto += "====================="

    self.my_dialogo_texto.salida_texto.SetValue(snaptexto)
    result = self.my_dialogo_texto.ShowModal(
    )  # pintamos la ventana con la informcion
    self.my_dialogo_texto.Destroy()
示例#3
0
def on_info_vm(self, event, conexion, logger):
        """
        Arg:
            event       (Var from menu)
            conexion    (Var whit a conexion datacenter)
            logger      (Var objet to pass the log)
        """
        fila = self.listadoVM
        #print (self, event, conexion)
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
            
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        
        # List about vm detail in dialog box

        self.my_dialogo_texto = dialogos.Dialogo_texto(None, -1, 'Listados de datos VM')

        vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
        if logger != None: logger.info('informacion vm: '+ vm.summary.config.name)
        

        snaptexto ='\n Maquna vm = ' + fila[1] + '\n'

        snaptexto +="=====================\n"
        details = {'name': vm.summary.config.name,
                   'instance UUID': vm.summary.config.instanceUuid,
                   'bios UUID': vm.summary.config.uuid,
                   'path to VM': vm.summary.config.vmPathName,
                   'guest OS id': vm.summary.config.guestId,
                   'guest OS name': vm.summary.config.guestFullName,
                   'host name': vm.runtime.host.name,
                   'last booted timestamp': vm.runtime.bootTime}

        for name, value in details.items():
            snaptexto +=u"\n  {0:{width}{base}}: {1}".format(name, value, width=25, base='s')

        snaptexto += "\n------------------------------"
        snaptexto += "\nDevices:"
        snaptexto +="\n------------------------------\n"
        for device in vm.config.hardware.device:
            # diving into each device, we pull out a few interesting bits
            dev_details = {'key': device.key,
                           'summary': device.deviceInfo.summary,
                           'device type': type(device).__name__,
                           'backing type': type(device.backing).__name__}

            snaptexto +="\n------------------\n"
            snaptexto +=u"\n  label: {0}".format(device.deviceInfo.label)

            for name, value in dev_details.items():
                snaptexto +=u"\n    {0:{width}{base}}: {1}".format(name, value, width=15, base='s')

            if device.backing is None:
                continue

            # the following is a bit of a hack, but it lets us build a summary
            # without making many assumptions about the backing type, if the
            # backing type has a file name we *know* it's sitting on a datastore
            # and will have to have all of the following attributes.
            if hasattr(device.backing, 'fileName'):
                datastore = device.backing.datastore
                if datastore:
                    snaptexto +="    datastore\n"
                    snaptexto +="        name: {0}\n".format(datastore.name)
                    # there may be multiple hosts, the host property
                    # is a host mount info type not a host system type
                    # but we can navigate to the host system from there
                    for host_mount in datastore.host:
                        host_system = host_mount.key
                        snaptexto +=u"\n        host: {0}".format(host_system.name)
                    snaptexto +="        summary"
                    summary = {'capacity': datastore.summary.capacity,
                               'freeSpace': datastore.summary.freeSpace,
                               'file system': datastore.summary.type,
                               'url': datastore.summary.url}
                    for key, val in summary.items():
                        snaptexto +=(u"\n            {0}: {1}".format(key, val))
                snaptexto +=(u"\n    fileName: {0}".format(device.backing.fileName))
                snaptexto +=(u"\n    device ID: {0}".format(device.backing.backingObjectId))

            snaptexto +="\n--------------------------------------------\n"

        snaptexto += "====================="
        self.my_dialogo_texto.salida_texto.SetValue(snaptexto)
        result = self.my_dialogo_texto.ShowModal() # pintamos la ventana con la informcion
        self.my_dialogo_texto.Destroy()
示例#4
0
def onSnap_create(self, event, conexion, logger):

        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        #Dialogo para pedir datos para el snapshop......

        self.my_dialogo_snapshot = dialogos.Dialog_snapshot(None, -1, 'Propiedades Snapshot')

        self.my_dialogo_snapshot.nombre_snap.SetValue(fila[1] + ' Razon del snapshot? ...' )
        result = self.my_dialogo_snapshot.ShowModal()

        nombre = str(self.my_dialogo_snapshot.nombre_snap.GetValue())
        descricion = str(self.my_dialogo_snapshot.descripcion_snap.GetValue())
        checkbox_memory=self.my_dialogo_snapshot.checkbox_memory.GetValue()
        checkbox_quiesce=self.my_dialogo_snapshot.checkbox_quiesce.GetValue()
        self.my_dialogo_snapshot.Destroy()

        #if logger != None: logger.info ('resultado = ' + str(result))
        #if logger != None: logger.info('wx.ID_OK = ' + str(wx.ID_OK))


        vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
        # Window progress task
        keepGoing = True
        dlg_process = wx.ProgressDialog("Process task snapshot ",
                            "Task process",
                            maximum = 100, )
        keepGoing = dlg_process.Update(0)

        if result == wx.ID_OK:
            if  vm  is not None:
                if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
                TASK = task = vm.CreateSnapshot_Task(nombre, description = descricion, memory=checkbox_memory, quiesce=checkbox_quiesce)
                #contador de tareas
                #count = 0
                #state_task= task.info.state
                wait_cursor = wx.BusyCursor()
                while task.info.state != vim.TaskInfo.State.success:
                    #if logger != None: logger.info('Running => {0}  state: {1} info.result = {2}'.format(count, task.info.state, task.info.result))
                    #if logger != None: logger.info('Running => {0}  %'.format(task.info.progress))
                    #count += 1
                    try:
                        porcentage = int(task.info.progress)
                    except:
                        pass

                    else:
                        keepGoing = dlg_process.Update(porcentage, "Snapshot {}%".format(porcentage))

                #tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("Snapshot Completed.")
                del wait_cursor

        dlg_process.Destroy()

        #listado de snapshot en una ventana emergente

        self.my_dialogo_texto = dialogos.Dialogo_texto(None, -1, 'Listados de Snapshots')

        del vm
        vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
        snap_info = vm.snapshot


        #Show the actual state snapshot
        onSnap_list(self, event, conexion, logger)
示例#5
0
    def onSnap_create(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info(fila[8])
        #Dialogo para pedir datos para el snapshop......

        self.my_dialogo_sanshot = dialogos.Dialog_snapshot(
            None, -1, 'Propiedades Snapshot')

        self.my_dialogo_sanshot.nombre_snap.SetValue(
            fila[1] + ' Razon del snapshot? ...')
        result = self.my_dialogo_sanshot.ShowModal()

        nombre = str(self.my_dialogo_sanshot.nombre_snap.GetValue())
        descricion = str(self.my_dialogo_sanshot.descripcion_snap.GetValue())
        checkbox_memory = self.my_dialogo_sanshot.checkbox_memory.GetValue()
        checkbox_quiesce = self.my_dialogo_sanshot.checkbox_quiesce.GetValue()

        self.my_dialogo_sanshot.Destroy()
        #if logger != None: logger.info ('resultado = ' + str(result))
        #if logger != None: logger.info('wx.ID_OK = ' + str(wx.ID_OK))
        """dlg_reset = wx.MessageDialog(self,
                                     "¿Hacer snapshot de : ? \n " + fila[1] + " ",
                                     "Confirm Exit",
                                     wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        result = dlg_reset.ShowModal()
        dlg_reset.Destroy()"""

        vm = conexion.searchIndex.FindByUuid(None, fila[8], True)
        if result == wx.ID_OK:
            if vm is not None:
                if logger != None:
                    logger.info("The current powerState is: {0}".format(
                        vm.runtime.powerState))
                TASK = task = vm.CreateSnapshot_Task(nombre,
                                                     description=descricion,
                                                     memory=checkbox_memory,
                                                     quiesce=checkbox_quiesce)
                tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("Snapshot Completed.")

        #listado de snapshot en una ventana emergente

        self.my_dialogo_texto = dialogos.Dialogo_texto(
            None, -1, 'Listados de Snapshots')

        del vm
        vm = conexion.searchIndex.FindByUuid(None, fila[8], True)
        snap_info = vm.snapshot
        self.my_dialogo_texto.salida_texto.SetValue('Maquna vm = ' + fila[1])
        snaptexto = 'Listado de snapshot \n'
        if not snap_info:
            self.my_dialogo_texto.salida_texto.SetValue('No hay snapshot')
            if logger != None: logger.info('No hay snapshot')
        else:
            tree = snap_info.rootSnapshotList
            while tree[0].childSnapshotList is not None:
                snaptexto = snaptexto + (
                    "Nombre Snap: {0} = description> {1}  \n".format(
                        tree[0].name, tree[0].description))
                if logger != None:
                    logger.info("Snap: {0} => {1}".format(
                        tree[0].name, tree[0].description))
                if len(tree[0].childSnapshotList) < 1:
                    break
                tree = tree[0].childSnapshotList
            self.my_dialogo_texto.salida_texto.SetValue(snaptexto)

        result = self.my_dialogo_texto.ShowModal(
        )  # pintamos la ventana con la informcion
        self.my_dialogo_texto.Destroy()