VirtualBox

Changeset 83255 in vbox


Ignore:
Timestamp:
Mar 11, 2020 10:34:49 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Handle cloud networking errors and fetch last access error to provide user with reason of cloud VM inaccessibility.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudMachine.cpp

    r83203 r83255  
    4949    , m_strName(other.m_strName)
    5050    , m_fAccessible(other.m_fAccessible)
     51    , m_strAccessError(other.m_strAccessError)
    5152    , m_enmMachineState(other.m_enmMachineState)
    5253    , m_strOsType(other.m_strOsType)
     
    6970{
    7071    /* Acquire instance info sync way, be aware, this is blocking stuff, it takes some time: */
    71     const QMap<KVirtualSystemDescriptionType, QString> instanceInfoMap = getInstanceInfo(m_comCloudClient, m_strId);
     72    const QMap<KVirtualSystemDescriptionType, QString> instanceInfoMap = getInstanceInfo(m_comCloudClient, m_strId, m_strAccessError);
     73    /* Update accessibility state: */
     74    m_fAccessible = m_strAccessError.isNull();
    7275
    73     /* Refresh corresponding values: */
    74     m_strOsType = fetchOsType(instanceInfoMap);
    75     m_iMemorySize = fetchMemorySize(instanceInfoMap);
    76     m_iCpuCount = fetchCpuCount(instanceInfoMap);
    77     m_enmMachineState = fetchMachineState(instanceInfoMap);
    78     m_strShape = fetchShape(instanceInfoMap);
    79     m_strDomain = fetchDomain(instanceInfoMap);
    80     m_strBootingFirmware = fetchBootingFirmware(instanceInfoMap);
    81     m_strImageId = fetchImageId(instanceInfoMap);
     76    /* Refresh corresponding values if accessible: */
     77    if (m_fAccessible)
     78    {
     79        m_strOsType = fetchOsType(instanceInfoMap);
     80        m_iMemorySize = fetchMemorySize(instanceInfoMap);
     81        m_iCpuCount = fetchCpuCount(instanceInfoMap);
     82        m_enmMachineState = fetchMachineState(instanceInfoMap);
     83        m_strShape = fetchShape(instanceInfoMap);
     84        m_strDomain = fetchDomain(instanceInfoMap);
     85        m_strBootingFirmware = fetchBootingFirmware(instanceInfoMap);
     86        m_strImageId = fetchImageId(instanceInfoMap);
    8287
    83     /* Acquire image info sync way, be aware, this is blocking stuff, it takes some time: */
    84     const QMap<QString, QString> imageInfoMap = getImageInfo(m_comCloudClient, m_strImageId);
    85     //printf("Image info:\n");
    86     //foreach (const QString &strKey, imageInfoMap.keys())
    87     //    printf("key = %s, value = %s\n", strKey.toUtf8().constData(), imageInfoMap.value(strKey).toUtf8().constData());
    88     //printf("\n");
     88        /* Acquire image info sync way, be aware, this is blocking stuff, it takes some time: */
     89        const QMap<QString, QString> imageInfoMap = getImageInfo(m_comCloudClient, m_strImageId, m_strAccessError);
     90        /* Update accessibility state: */
     91        m_fAccessible = m_strAccessError.isNull();
    8992
    90     /* Sorry, but these are hardcoded in Main: */
    91     m_strImageName = imageInfoMap.value("display name");
    92     m_strImageSize = imageInfoMap.value("size");
     93        //printf("Image info:\n");
     94        //foreach (const QString &strKey, imageInfoMap.keys())
     95        //    printf("key = %s, value = %s\n", strKey.toUtf8().constData(), imageInfoMap.value(strKey).toUtf8().constData());
     96        //printf("\n");
     97
     98        /* Refresh corresponding values if accessible: */
     99        if (m_fAccessible)
     100        {
     101            /* Sorry, but these are hardcoded in Main: */
     102            m_strImageName = imageInfoMap.value("display name");
     103            m_strImageSize = imageInfoMap.value("size");
     104        }
     105    }
     106
     107    /* Reset everything if not accessible: */
     108    if (!m_fAccessible)
     109    {
     110        m_enmMachineState = KMachineState_PoweredOff;
     111        m_strOsType = "Other";
     112        m_iMemorySize = 0;
     113        m_iCpuCount = 0;
     114        m_strShape.clear();
     115        m_strDomain.clear();
     116        m_strBootingFirmware.clear();
     117        m_strImageId.clear();
     118        m_strImageName.clear();
     119        m_strImageSize.clear();
     120    }
    93121}
    94122
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudMachine.h

    r83203 r83255  
    6262
    6363    /** Returns whether cloud VM is accessible. */
    64     bool isAccessible() const { return m_fAccessible; }
     64    bool accessible() const { return m_fAccessible; }
     65    /** Returns last access error message. */
     66    QString accessError() const { return m_strAccessError; }
    6567
    6668    /** Returns cloud VM state. */
     
    9799
    98100    /** Holds whether cloud VM is accessible. */
    99     bool  m_fAccessible;
     101    bool     m_fAccessible;
     102    /** Holds the last access error message. */
     103    QString  m_strAccessError;
    100104
    101105    /** Holds the cloud VM state. */
     
    157161
    158162    /** Returns whether cloud VM is accessible. */
    159     bool isAccessible() const { return d->isAccessible(); }
     163    bool accessible() const { return d->accessible(); }
     164    /** Returns last access error message. */
     165    QString accessError() const { return d->accessError(); }
    160166
    161167    /** Returns cloud VM state. */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudNetworkingStuff.cpp

    r83212 r83255  
    8585QMap<KVirtualSystemDescriptionType, QString> UICloudNetworkingStuff::getInstanceInfo(const CCloudClient &comCloudClient,
    8686                                                                                     const QString &strId,
     87                                                                                     QString &strErrorMessage,
    8788                                                                                     QWidget *pParent /* = 0 */)
    8889{
     
    100101            msgCenter().cannotCreateAppliance(comVBox, pParent);
    101102        else
    102         {
    103             /// @todo fetch error info
    104         }
     103            strErrorMessage = UIErrorString::formatErrorInfo(comVBox);
    105104    }
    106105    else
     
    113112                msgCenter().cannotCreateVirtualSystemDescription(comAppliance, pParent);
    114113            else
    115             {
    116                 /// @todo fetch error info
    117             }
     114                strErrorMessage = UIErrorString::formatErrorInfo(comAppliance);
    118115        }
    119116        else
     
    131128                    msgCenter().cannotAcquireCloudClientParameter(comCloudClient, pParent);
    132129                else
    133                 {
    134                     /// @todo fetch error info
    135                 }
     130                    strErrorMessage = UIErrorString::formatErrorInfo(comCloudClient);
    136131            }
    137132            else
     
    149144                        msgCenter().cannotAcquireCloudClientParameter(comProgress, pParent);
    150145                    else
    151                     {
    152                         /// @todo fetch error info
    153                     }
     146                        strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
    154147                }
    155148                else
     
    177170                                                const CCloudClient &comCloudClient,
    178171                                                const QString &strId,
     172                                                QString &strErrorMessage,
    179173                                                QWidget *pParent /* = 0 */)
    180174{
    181     return getInstanceInfo(comCloudClient, strId, pParent).value(enmType, QString());
     175    return getInstanceInfo(comCloudClient, strId, strErrorMessage, pParent).value(enmType, QString());
    182176}
    183177
    184178QMap<QString, QString> UICloudNetworkingStuff::getImageInfo(const CCloudClient &comCloudClient,
    185179                                                            const QString &strId,
     180                                                            QString &strErrorMessage,
    186181                                                            QWidget *pParent /* = 0 */)
    187182{
     
    197192            msgCenter().cannotAcquireCloudClientParameter(comCloudClient, pParent);
    198193        else
    199         {
    200             /// @todo fetch error info
    201         }
     194            strErrorMessage = UIErrorString::formatErrorInfo(comCloudClient);
    202195    }
    203196    else
     
    215208                msgCenter().cannotAcquireCloudClientParameter(comProgress, pParent);
    216209            else
    217             {
    218                 /// @todo fetch error info
    219             }
     210                strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
    220211        }
    221212        else
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudNetworkingStuff.h

    r83212 r83255  
    3434{
    3535    /** Acquires instance list.
    36       * @param  comCloudClient  Brings cloud client object.
    37       * @param  pWidget         Brings parent widget to show messages according to,
    38       *                         if no parent set, progress will be executed in blocking way. */
     36      * @param  comCloudClient   Brings cloud client object.
     37      * @param  strErrorMessage  Brings error message container.
     38      * @param  pWidget          Brings parent widget to show messages according to,
     39      *                          if no parent set, progress will be executed in blocking way. */
    3940    SHARED_LIBRARY_STUFF QList<UICloudMachine> listInstances(const CCloudClient &comCloudClient,
    4041                                                             QString &strErrorMessage,
     
    4243
    4344    /** Acquires instance info as a map.
    44       * @param  comCloudClient  Brings cloud client object.
    45       * @param  strId           Brings cloud instance id.
    46       * @param  pWidget         Brings parent widget to show messages according to,
    47       *                         if no parent set, progress will be executed in blocking way. */
     45      * @param  comCloudClient   Brings cloud client object.
     46      * @param  strId            Brings cloud instance id.
     47      * @param  strErrorMessage  Brings error message container.
     48      * @param  pWidget          Brings parent widget to show messages according to,
     49      *                          if no parent set, progress will be executed in blocking way. */
    4850    SHARED_LIBRARY_STUFF QMap<KVirtualSystemDescriptionType, QString> getInstanceInfo(const CCloudClient &comCloudClient,
    4951                                                                                      const QString &strId,
     52                                                                                      QString &strErrorMessage,
    5053                                                                                      QWidget *pParent = 0);
    5154    /** Acquires instance info of certain @a enmType as a string.
    52       * @param  comCloudClient  Brings cloud client object.
    53       * @param  strId           Brings cloud instance id.
    54       * @param  pWidget         Brings parent widget to show messages according to,
    55       *                         if no parent set, progress will be executed in blocking way. */
     55      * @param  comCloudClient   Brings cloud client object.
     56      * @param  strId            Brings cloud instance id.
     57      * @param  strErrorMessage  Brings error message container.
     58      * @param  pWidget          Brings parent widget to show messages according to,
     59      *                          if no parent set, progress will be executed in blocking way. */
    5660    SHARED_LIBRARY_STUFF QString getInstanceInfo(KVirtualSystemDescriptionType enmType,
    5761                                                 const CCloudClient &comCloudClient,
    5862                                                 const QString &strId,
     63                                                 QString &strErrorMessage,
    5964                                                 QWidget *pParent = 0);
    6065
    6166    /** Acquires image info as a map.
    62       * @param  comCloudClient  Brings cloud client object.
    63       * @param  strId           Brings cloud image id.
    64       * @param  pWidget         Brings parent widget to show messages according to,
    65       *                         if no parent set, progress will be executed in blocking way. */
     67      * @param  comCloudClient   Brings cloud client object.
     68      * @param  strId            Brings cloud image id.
     69      * @param  strErrorMessage  Brings error message container.
     70      * @param  pWidget          Brings parent widget to show messages according to,
     71      *                          if no parent set, progress will be executed in blocking way. */
    6672    SHARED_LIBRARY_STUFF QMap<QString, QString> getImageInfo(const CCloudClient &comCloudClient,
    6773                                                             const QString &strId,
     74                                                             QString &strErrorMessage,
    6875                                                             QWidget *pParent = 0);
    6976
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp

    r83203 r83255  
    131131        return table;
    132132
    133     if (!guiCloudMachine.isAccessible())
     133    if (!guiCloudMachine.accessible())
    134134    {
    135135        table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
     
    292292        return table;
    293293
    294     if (!guiCloudMachine.isAccessible())
     294    if (!guiCloudMachine.accessible())
    295295    {
    296296        table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
     
    571571        return table;
    572572
    573     if (!guiCloudMachine.isAccessible())
     573    if (!guiCloudMachine.accessible())
    574574    {
    575575        table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.h

    r83254 r83255  
    156156      * @{ */
    157157        /** Holds cached machine id. */
    158         QString      m_strId;
     158        QString  m_strId;
    159159        /** Holds cached machine name. */
    160         QString      m_strName;
     160        QString  m_strName;
    161161        /** Holds cached machine OS type id. */
    162         QString      m_strOSTypeId;
     162        QString  m_strOSTypeId;
    163163        /** Holds cached machine OS type pixmap. */
    164         QPixmap      m_pixmap;
     164        QPixmap  m_pixmap;
    165165        /** Holds cached machine OS type pixmap size. */
    166         QSize        m_logicalPixmapSize;
     166        QSize    m_logicalPixmapSize;
    167167    /** @} */
    168168
     
    170170      * @{ */
    171171        /** Holds cached machine state. */
    172         KMachineState             m_enmMachineState;
     172        KMachineState  m_enmMachineState;
    173173        /** Holds cached machine state name. */
    174         QString                   m_strMachineStateName;
     174        QString        m_strMachineStateName;
    175175        /** Holds cached machine state name. */
    176         QIcon                     m_machineStateIcon;
     176        QIcon          m_machineStateIcon;
    177177
    178178        /** Holds configuration access level. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp

    r83254 r83255  
    109109
    110110    /* Now determine whether VM is accessible: */
    111     m_fAccessible = true;
    112     if (m_fAccessible)
    113     {
    114         /* Reset last access error information: */
    115         m_strAccessError.clear();
    116 
    117         /* Determine own VM attributes: */
    118         m_strOSTypeId = !m_guiCloudMachine.isNull()
    119                       ? m_guiCloudMachine.osType()
    120                       : "Other";
    121 
    122         /* Determine VM states: */
    123         m_enmMachineState = !m_guiCloudMachine.isNull()
    124                           ? m_guiCloudMachine.machineState()
    125                           : KMachineState_PoweredOff;
    126         m_strMachineStateName = gpConverter->toString(m_enmMachineState);
    127         if (itemType() == ItemType_CloudFake)
     111    m_fAccessible = !m_guiCloudMachine.isNull()
     112                  ? m_guiCloudMachine.accessible()
     113                  : true;
     114    m_strAccessError = !m_guiCloudMachine.isNull()
     115                     ? m_guiCloudMachine.accessError()
     116                     : QString();
     117
     118    /* Determine own VM attributes: */
     119    m_strOSTypeId = !m_guiCloudMachine.isNull()
     120                  ? m_guiCloudMachine.osType()
     121                  : "Other";
     122
     123    /* Determine VM states: */
     124    m_enmMachineState = !m_guiCloudMachine.isNull()
     125                      ? m_guiCloudMachine.machineState()
     126                      : KMachineState_PoweredOff;
     127    m_strMachineStateName = gpConverter->toString(m_enmMachineState);
     128    if (itemType() == ItemType_CloudFake)
     129    {
     130        switch (m_enmFakeCloudItemState)
    128131        {
    129             switch (m_enmFakeCloudItemState)
    130             {
    131                 case UIVirtualMachineItemCloud::FakeCloudItemState_Loading:
    132                     m_machineStateIcon = UIIconPool::iconSet(":/state_loading_16px.png");
    133                     break;
    134                 case UIVirtualMachineItemCloud::FakeCloudItemState_Done:
    135                     m_machineStateIcon = UIIconPool::iconSet(":/vm_new_16px.png");
    136                     break;
    137                 default:
    138                     break;
    139             }
     132            case UIVirtualMachineItemCloud::FakeCloudItemState_Loading:
     133                m_machineStateIcon = UIIconPool::iconSet(":/state_loading_16px.png");
     134                break;
     135            case UIVirtualMachineItemCloud::FakeCloudItemState_Done:
     136                m_machineStateIcon = UIIconPool::iconSet(":/vm_new_16px.png");
     137                break;
     138            default:
     139                break;
    140140        }
    141         else
    142             m_machineStateIcon = gpConverter->toIcon(m_enmMachineState);
    143 
    144         /* Determine configuration access level: */
    145         m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Null;
    146 
    147         /* Determine whether we should show this VM details: */
    148         m_fHasDetails = true;
    149     }
    150     else
    151     {
    152         /// @todo handle inaccessible cloud VM
    153     }
     141    }
     142    else
     143        m_machineStateIcon = gpConverter->toIcon(m_enmMachineState);
     144
     145    /* Determine configuration access level: */
     146    m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Null;
     147
     148    /* Determine whether we should show this VM details: */
     149    m_fHasDetails = true;
    154150
    155151    /* Recache item pixmap: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette