In a very interesting new development, Ahmadinejad is not going to Vienna to preside over the OPEC meeting. Surely, regardless of what the official press release said, this camera-loving president did not cancel the trip based on his own volition. Rather, I'd argue that the trip was blocked by the volatile conditions in Iran.
Ahmadinejad's recent sacking of the Ministers of Petroleum, Social Welfare, and Industrial and Mining was done as a response to parliament's demands to streamline the Iranian cabinet. Keep in mind parliament has the right to discuss which ministry to downsize and then vet prospective members of the new cabinet. And Khamenei's faction within parliament saw this "streamlining" as a way to impose control over Ahmadinejad's cabinet. Ahmadinejad thus attempted to bypass the parliament integrating these three cabinets under his direct leadership, in essence taking out the ability of Khamenei's cliques to impose people who they want on three most useful ministries in the next election. Not surprisingly, the parliament cried foul and the spat is still ongoing today.
In the light of Ahmadinejad's attempt to raise the stakes and prevent the meddling of Khamenei's cliques on his cabinet, Ahmadinejad's decision to forgo his usual ego-boosting trip is understandable. He might have lost control over his cabinet had the Iranian parliament, supported by Khamenei's blessings, decided to use his absence to impose changes on Iran's cabinet. At the same time, Khamenei might have raised the stakes further had he believed that the purpose of Ahmadinejad's trip was to increase his profile.