Feature 10911-Vertical scaling of VM instances from OSM
[osm/RO.git] / RO-VIM-vmware / osm_rovim_vmware / vimconn_vmware.py
index a3c25ca..ff89b5a 100644 (file)
 vimconn_vmware implementation an Abstract class in order to interact with VMware  vCloud Director.
 """
 
-from lxml import etree as lxmlElementTree
-from osm_ro_plugin import vimconn
-from progressbar import Percentage, Bar, ETA, FileTransferSpeed, ProgressBar
-from pyVim.connect import SmartConnect, Disconnect
-from pyVmomi import vim, vmodl  # @UnresolvedImport
-from pyvcloud.vcd.client import BasicLoginCredentials, Client
-from pyvcloud.vcd.org import Org
-from pyvcloud.vcd.vapp import VApp
-from pyvcloud.vcd.vdc import VDC
-from xml.etree import ElementTree as XmlElementTree
-from xml.sax.saxutils import escape
 import atexit
 import hashlib
 import json
 import logging
-import netaddr
 import os
 import random
 import re
-import requests
 import shutil
 import socket
 import ssl
@@ -54,6 +41,20 @@ import tempfile
 import time
 import traceback
 import uuid
+from xml.etree import ElementTree as XmlElementTree
+from xml.sax.saxutils import escape
+
+from lxml import etree as lxmlElementTree
+import netaddr
+from osm_ro_plugin import vimconn
+from progressbar import Bar, ETA, FileTransferSpeed, Percentage, ProgressBar
+from pyvcloud.vcd.client import BasicLoginCredentials, Client
+from pyvcloud.vcd.org import Org
+from pyvcloud.vcd.vapp import VApp
+from pyvcloud.vcd.vdc import VDC
+from pyVim.connect import Disconnect, SmartConnect
+from pyVmomi import vim, vmodl  # @UnresolvedImport
+import requests
 import yaml
 
 # global variable for vcd connector type
@@ -1906,6 +1907,7 @@ class vimconnector(vimconn.VimConnector):
         start=False,
         image_id=None,
         flavor_id=None,
+        affinity_group_list=[],
         net_list=[],
         cloud_config=None,
         disk_list=None,
@@ -6229,7 +6231,7 @@ class vimconnector(vimconn.VimConnector):
                     )
                     return None
 
-                deviceId = hex(host_pci_dev.deviceId % 2 ** 16).lstrip("0x")
+                deviceId = hex(host_pci_dev.deviceId % 2**16).lstrip("0x")
                 backing = vim.VirtualPCIPassthroughDeviceBackingInfo(
                     deviceId=deviceId,
                     id=host_pci_dev.id,
@@ -7492,13 +7494,10 @@ if [ "$1" = "precustomization" ];then
 
                 for device in devices:
                     if type(device) is vim.vm.device.VirtualDisk:
-                        if (
-                            isinstance(
-                                device.backing,
-                                vim.vm.device.VirtualDisk.FlatVer2BackingInfo,
-                            )
-                            and hasattr(device.backing, "fileName")
-                        ):
+                        if isinstance(
+                            device.backing,
+                            vim.vm.device.VirtualDisk.FlatVer2BackingInfo,
+                        ) and hasattr(device.backing, "fileName"):
                             disk_info["full_path"] = device.backing.fileName
                             disk_info["datastore"] = device.backing.datastore
                             disk_info["capacityKB"] = device.capacityInKB
@@ -8660,3 +8659,23 @@ if [ "$1" = "precustomization" ];then
             poweron_task = self.get_task_from_response(response.text)
 
             return poweron_task
+
+    def migrate_instance(self, vm_id, compute_host=None):
+        """
+        Migrate a vdu
+        param:
+            vm_id: ID of an instance
+            compute_host: Host to migrate the vdu to
+        """
+        # TODO: Add support for migration
+        raise vimconn.VimConnNotImplemented("Should have implemented this")
+
+    def resize_instance(self, vm_id, flavor_id=None):
+        """
+        resize a vdu
+        param:
+            vm_id: ID of an instance
+            flavor_id: flavor_id to resize the vdu to
+        """
+        # TODO: Add support for resize
+        raise vimconn.VimConnNotImplemented("Should have implemented this")