Răsfoiți Sursa

Renamed InstanceTypes to VMTypes

Nuwan Goonasekera 8 ani în urmă
părinte
comite
3df1161aa7

+ 4 - 4
cloudbridge/cloud/base/resources.py

@@ -21,7 +21,6 @@ from cloudbridge.cloud.interfaces.resources import FloatingIP
 from cloudbridge.cloud.interfaces.resources import GatewayState
 from cloudbridge.cloud.interfaces.resources import Instance
 from cloudbridge.cloud.interfaces.resources import InstanceState
-from cloudbridge.cloud.interfaces.resources import InstanceType
 from cloudbridge.cloud.interfaces.resources import InternetGateway
 from cloudbridge.cloud.interfaces.resources import KeyPair
 from cloudbridge.cloud.interfaces.resources import LaunchConfig
@@ -41,6 +40,7 @@ from cloudbridge.cloud.interfaces.resources import Snapshot
 from cloudbridge.cloud.interfaces.resources import SnapshotState
 from cloudbridge.cloud.interfaces.resources import Subnet
 from cloudbridge.cloud.interfaces.resources import SubnetState
+from cloudbridge.cloud.interfaces.resources import VMType
 from cloudbridge.cloud.interfaces.resources import Volume
 from cloudbridge.cloud.interfaces.resources import VolumeState
 
@@ -362,13 +362,13 @@ class BasePageableObjectMixin(PageableObjectMixin):
                 yield result
 
 
-class BaseInstanceType(BaseCloudResource, InstanceType):
+class BaseVMType(BaseCloudResource, VMType):
 
     def __init__(self, provider):
-        super(BaseInstanceType, self).__init__(provider)
+        super(BaseVMType, self).__init__(provider)
 
     def __eq__(self, other):
-        return (isinstance(other, InstanceType) and
+        return (isinstance(other, VMType) and
                 # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id)

+ 7 - 7
cloudbridge/cloud/base/services.py

@@ -9,7 +9,6 @@ from cloudbridge.cloud.interfaces.services import ComputeService
 from cloudbridge.cloud.interfaces.services import GatewayService
 from cloudbridge.cloud.interfaces.services import ImageService
 from cloudbridge.cloud.interfaces.services import InstanceService
-from cloudbridge.cloud.interfaces.services import InstanceTypesService
 from cloudbridge.cloud.interfaces.services import KeyPairService
 from cloudbridge.cloud.interfaces.services import NetworkService
 from cloudbridge.cloud.interfaces.services import NetworkingService
@@ -20,6 +19,7 @@ from cloudbridge.cloud.interfaces.services import SecurityGroupService
 from cloudbridge.cloud.interfaces.services import SecurityService
 from cloudbridge.cloud.interfaces.services import SnapshotService
 from cloudbridge.cloud.interfaces.services import SubnetService
+from cloudbridge.cloud.interfaces.services import VMTypeService
 from cloudbridge.cloud.interfaces.services import VolumeService
 
 from .resources import BasePageableObjectMixin
@@ -112,15 +112,15 @@ class BaseSecurityGroupService(
         super(BaseSecurityGroupService, self).__init__(provider)
 
 
-class BaseInstanceTypesService(
-        BasePageableObjectMixin, InstanceTypesService, BaseCloudService):
+class BaseVMTypeService(
+        BasePageableObjectMixin, VMTypeService, BaseCloudService):
 
     def __init__(self, provider):
-        super(BaseInstanceTypesService, self).__init__(provider)
+        super(BaseVMTypeService, self).__init__(provider)
 
-    def get(self, instance_type_id):
-        itype = (t for t in self if t.id == instance_type_id)
-        return next(itype, None)
+    def get(self, vm_type_id):
+        vm_type = (t for t in self if t.id == vm_type_id)
+        return next(vm_type, None)
 
     def find(self, **kwargs):
         name = kwargs.get('name')

+ 1 - 1
cloudbridge/cloud/interfaces/provider.py

@@ -123,7 +123,7 @@ class CloudProvider(object):
         .. code-block:: python
 
             regions = provider.compute.regions.list()
-            instance_types = provider.compute.instance_types.list()
+            vm_types = provider.compute.vm_types.list()
             instances = provider.compute.instances.list()
             images = provider.compute.images.list()
 

+ 25 - 25
cloudbridge/cloud/interfaces/resources.py

@@ -469,25 +469,25 @@ class Instance(ObjectLifeCycleMixin, CloudResource):
         pass
 
     @abstractproperty
-    def instance_type_id(self):
+    def vm_type_id(self):
         """
-        Get the instance type id for this instance. This will typically be a
+        Get the vm type id for this instance. This will typically be a
         string value like 'm1.large'. On OpenStack, this may be a number or
-        UUID. To get the full :class:``.InstanceType``
-        object, you can use the instance.instance_type property instead.
+        UUID. To get the full :class:``.VMType``
+        object, you can use the instance.vm_type property instead.
 
         :rtype: ``str``
-        :return: Instance type name for this instance (e.g., ``m1.large``)
+        :return: VM type name for this instance (e.g., ``m1.large``)
         """
         pass
 
     @abstractproperty
-    def instance_type(self):
+    def vm_type(self):
         """
-        Retrieve full instance type information for this instance.
+        Retrieve full VM type information for this instance.
 
-        :rtype: :class:`.InstanceType`
-        :return: Instance type for this instance
+        :rtype: :class:`.VMType`
+        :return: VM type for this instance
         """
         pass
 
@@ -651,7 +651,7 @@ class LaunchConfig(object):
         lc = provider.compute.instances.create_launch_config()
         lc.add_block_device(...)
 
-        inst = provider.compute.instances.create(name, image, instance_type,
+        inst = provider.compute.instances.create(name, image, vm_type,
                                                  network, launch_config=lc)
     """
 
@@ -661,13 +661,13 @@ class LaunchConfig(object):
         Adds a new ephemeral block device mapping to the boot configuration.
         This can be used to add existing ephemeral devices to the instance.
         (The total number of ephemeral devices available for a particular
-        InstanceType can be determined by querying the InstanceTypes service).
+        VMType can be determined by querying the VMType service).
         Note that on some services, such as AWS, ephemeral devices must be
         added in as a device mapping at instance creation time, and cannot be
         added afterwards.
 
         Note that the device name, such as /dev/sda1, cannot be selected at
-        present, since this tends to be provider and instance type specific.
+        present, since this tends to be provider and VM type specific.
         However, the order of device addition coupled with device type will
         generally determine naming order, with devices added first getting
         lower letters than instances added later.
@@ -679,8 +679,8 @@ class LaunchConfig(object):
             lc = provider.compute.instances.create_launch_config()
 
             # 1. Add all available ephemeral devices
-            inst_type = provider.compute.instance_types.find(name='m1.tiny')[0]
-            for i in range(inst_type.num_ephemeral_disks):
+            vm_type = provider.compute.vm_types.find(name='m1.tiny')[0]
+            for i in range(vm_type.num_ephemeral_disks):
                 lc.add_ephemeral_device()
         """
         pass
@@ -698,7 +698,7 @@ class LaunchConfig(object):
         devices to the instance.
 
         Note that the device name, such as /dev/sda1, cannot be selected at
-        present, since this tends to be provider and instance type specific.
+        present, since this tends to be provider and VM type specific.
         However, the order of device addition coupled with device type will
         generally determine naming order, with devices added first getting
         lower letters than instances added later (except when is_root is set).
@@ -1579,17 +1579,17 @@ class PlacementZone(CloudResource):
         pass
 
 
-class InstanceType(CloudResource):
+class VMType(CloudResource):
 
     """
-    An instance type object.
+    A VM type object.
     """
     __metaclass__ = ABCMeta
 
     @abstractproperty
     def family(self):
         """
-        The family/group that this instance type belongs to.
+        The family/group that this VM type belongs to.
 
         For example, General Purpose Instances or High-Memory Instances. If
         the provider does not support such a grouping, it may return ``None``.
@@ -1602,7 +1602,7 @@ class InstanceType(CloudResource):
     @abstractproperty
     def vcpus(self):
         """
-        The number of VCPUs supported by this instance type.
+        The number of VCPUs supported by this VM type.
 
         :rtype: ``int``
         :return: Number of VCPUs.
@@ -1612,7 +1612,7 @@ class InstanceType(CloudResource):
     @abstractproperty
     def ram(self):
         """
-        The amount of RAM (in MB) supported by this instance type.
+        The amount of RAM (in MB) supported by this VM type.
 
         :rtype: ``int``
         :return: Total RAM (in MB).
@@ -1622,7 +1622,7 @@ class InstanceType(CloudResource):
     @abstractproperty
     def size_root_disk(self):
         """
-        The size of this instance types's root disk (in GB).
+        The size of this VM types's root disk (in GB).
 
         :rtype: ``int``
         :return: Size of root disk (in GB).
@@ -1632,7 +1632,7 @@ class InstanceType(CloudResource):
     @abstractproperty
     def size_ephemeral_disks(self):
         """
-        The size of this instance types's total ephemeral storage (in GB).
+        The size of this VM types's total ephemeral storage (in GB).
 
         :rtype: ``int``
         :return: Size of ephemeral disks (in GB).
@@ -1642,7 +1642,7 @@ class InstanceType(CloudResource):
     @abstractproperty
     def num_ephemeral_disks(self):
         """
-        The total number of ephemeral disks on this instance type.
+        The total number of ephemeral disks on this VM type.
 
         :rtype: ``int``
         :return: Number of ephemeral disks available.
@@ -1652,7 +1652,7 @@ class InstanceType(CloudResource):
     @abstractproperty
     def size_total_disk(self):
         """
-        The total disk space available on this instance type
+        The total disk space available on this VM type
         (root_disk + ephemeral).
 
         :rtype: ``int``
@@ -1667,7 +1667,7 @@ class InstanceType(CloudResource):
         nested dictionaries, but all key value pairs are strings or integers.
 
         :rtype: ``dict``
-        :return: Extra attributes for this instance type.
+        :return: Extra attributes for this VM type.
         """
         pass
 

+ 25 - 25
cloudbridge/cloud/interfaces/services.py

@@ -64,24 +64,24 @@ class ComputeService(CloudService):
         pass
 
     @abstractproperty
-    def instance_types(self):
+    def vm_types(self):
         """
-        Provides access to all Instance type related services in this provider.
+        Provides access to all VM type related services in this provider.
 
         Example:
 
         .. code-block:: python
 
-            # list all instance sizes
-            for inst_type in provider.compute.instance_types:
-                print(inst_type.id, inst_type.name)
+            # list all VM sizes
+            for vm_type in provider.compute.vm_types:
+                print(vm_type.id, vm_type.name)
 
             # find a specific size by name
-            inst_type = provider.compute.instance_types.find(name='m1.small')
-            print(inst_type.vcpus)
+            vm_type = provider.compute.vm_types.find(name='m1.small')
+            print(vm_type.vcpus)
 
-        :rtype: :class:`.InstanceTypeService`
-        :return: an InstanceTypeService object
+        :rtype: :class:`.VMTypeService`
+        :return: an VMTypeService object
         """
         pass
 
@@ -96,7 +96,7 @@ class ComputeService(CloudService):
 
             # launch a new instance
             image = provider.compute.images.find(name='Ubuntu 14.04')[0]
-            size = provider.compute.instance_types.find(name='m1.small')
+            size = provider.compute.vm_types.find(name='m1.small')
             instance = provider.compute.instances.create('Hello', image, size)
             print(instance.id, instance.name)
 
@@ -205,7 +205,7 @@ class InstanceService(PageableObjectMixin, CloudService):
         pass
 
     @abstractmethod
-    def create(self, name, image, instance_type, subnet, zone=None,
+    def create(self, name, image, vm_type, subnet, zone=None,
                key_pair=None, security_groups=None, user_data=None,
                launch_config=None,
                **kwargs):
@@ -219,8 +219,8 @@ class InstanceService(PageableObjectMixin, CloudService):
         :param image: The MachineImage object or id to boot the virtual machine
                       with
 
-        :type  instance_type: ``InstanceType`` or ``str``
-        :param instance_type: The InstanceType or name, specifying the size of
+        :type  vm_type: ``VMType`` or ``str``
+        :param vm_type: The VMType or name, specifying the size of
                               the instance to boot into
 
         :type  subnet:  ``Subnet`` or ``str``
@@ -1191,34 +1191,34 @@ class SecurityGroupService(PageableObjectMixin, CloudService):
         pass
 
 
-class InstanceTypesService(PageableObjectMixin, CloudService):
+class VMTypeService(PageableObjectMixin, CloudService):
     __metaclass__ = ABCMeta
 
     @abstractmethod
-    def get(self, instance_type_id):
+    def get(self, vm_type_id):
         """
-        Returns an InstanceType given its ID. Returns ``None`` if the
-        InstanceType does not exist.
+        Returns an VMType given its ID. Returns ``None`` if the
+        VMType does not exist.
 
         Example:
 
         .. code-block:: python
 
-            itype = provider.compute.instance_types.get('my_itype_id')
-            print(itype.id, itype.name)
+            vm_type = provider.compute.vm_types.get('my_vm_type_id')
+            print(vm_type.id, vm_type.name)
 
-        :rtype: :class:`.InstanceType`
-        :return:  an InstanceType instance
+        :rtype: :class:`.VMType`
+        :return:  an VMType instance
         """
         pass
 
     @abstractmethod
     def list(self, limit=None, marker=None):
         """
-        List all instance types.
+        List all VM types.
 
-        :rtype: ``list`` of :class:`.InstanceType`
-        :return: list of InstanceType objects
+        :rtype: ``list`` of :class:`.VMType`
+        :return: list of VMType objects
         """
         pass
 
@@ -1227,7 +1227,7 @@ class InstanceTypesService(PageableObjectMixin, CloudService):
         """
         Searches for an instance by a given list of attributes.
 
-        :rtype: ``object`` of :class:`.InstanceType`
+        :rtype: ``object`` of :class:`.VMType`
         :return: an Instance object
         """
         pass

+ 6 - 6
cloudbridge/cloud/providers/aws/resources.py

@@ -11,7 +11,6 @@ from cloudbridge.cloud.base.resources import BaseBucket
 from cloudbridge.cloud.base.resources import BaseBucketObject
 from cloudbridge.cloud.base.resources import BaseFloatingIP
 from cloudbridge.cloud.base.resources import BaseInstance
-from cloudbridge.cloud.base.resources import BaseInstanceType
 from cloudbridge.cloud.base.resources import BaseInternetGateway
 from cloudbridge.cloud.base.resources import BaseKeyPair
 from cloudbridge.cloud.base.resources import BaseLaunchConfig
@@ -24,6 +23,7 @@ from cloudbridge.cloud.base.resources import BaseSecurityGroup
 from cloudbridge.cloud.base.resources import BaseSecurityGroupRule
 from cloudbridge.cloud.base.resources import BaseSnapshot
 from cloudbridge.cloud.base.resources import BaseSubnet
+from cloudbridge.cloud.base.resources import BaseVMType
 from cloudbridge.cloud.base.resources import BaseVolume
 from cloudbridge.cloud.base.resources import ClientPagedResultList
 from cloudbridge.cloud.interfaces.resources import GatewayState
@@ -137,10 +137,10 @@ class AWSPlacementZone(BasePlacementZone):
         return self._aws_region
 
 
-class AWSInstanceType(BaseInstanceType):
+class AWSVMType(BaseVMType):
 
     def __init__(self, provider, instance_dict):
-        super(AWSInstanceType, self).__init__(provider)
+        super(AWSVMType, self).__init__(provider)
         self._inst_dict = instance_dict
 
     @property
@@ -232,12 +232,12 @@ class AWSInstance(BaseInstance):
         return [self._ec2_instance.private_ip_address]
 
     @property
-    def instance_type_id(self):
+    def vm_type_id(self):
         return self._ec2_instance.instance_type
 
     @property
-    def instance_type(self):
-        return self._provider.compute.instance_types.find(
+    def vm_type(self):
+        return self._provider.compute.vm_types.find(
             name=self._ec2_instance.instance_type)[0]
 
     def reboot(self):

+ 15 - 15
cloudbridge/cloud/providers/aws/services.py

@@ -9,7 +9,6 @@ from cloudbridge.cloud.base.services import BaseComputeService
 from cloudbridge.cloud.base.services import BaseGatewayService
 from cloudbridge.cloud.base.services import BaseImageService
 from cloudbridge.cloud.base.services import BaseInstanceService
-from cloudbridge.cloud.base.services import BaseInstanceTypesService
 from cloudbridge.cloud.base.services import BaseKeyPairService
 from cloudbridge.cloud.base.services import BaseNetworkService
 from cloudbridge.cloud.base.services import BaseNetworkingService
@@ -20,15 +19,16 @@ from cloudbridge.cloud.base.services import BaseSecurityGroupService
 from cloudbridge.cloud.base.services import BaseSecurityService
 from cloudbridge.cloud.base.services import BaseSnapshotService
 from cloudbridge.cloud.base.services import BaseSubnetService
+from cloudbridge.cloud.base.services import BaseVMTypeService
 from cloudbridge.cloud.base.services import BaseVolumeService
 from cloudbridge.cloud.interfaces.exceptions \
     import InvalidConfigurationException
-from cloudbridge.cloud.interfaces.resources import InstanceType
 from cloudbridge.cloud.interfaces.resources import KeyPair
 from cloudbridge.cloud.interfaces.resources import MachineImage
 from cloudbridge.cloud.interfaces.resources import PlacementZone
 from cloudbridge.cloud.interfaces.resources import SecurityGroup
 from cloudbridge.cloud.interfaces.resources import Snapshot
+from cloudbridge.cloud.interfaces.resources import VMType
 from cloudbridge.cloud.interfaces.resources import Volume
 
 import requests
@@ -39,7 +39,6 @@ from .helpers import BotoS3Service
 from .resources import AWSBucket
 from .resources import AWSFloatingIP
 from .resources import AWSInstance
-from .resources import AWSInstanceType
 from .resources import AWSInternetGateway
 from .resources import AWSKeyPair
 from .resources import AWSLaunchConfig
@@ -50,6 +49,7 @@ from .resources import AWSRouter
 from .resources import AWSSecurityGroup
 from .resources import AWSSnapshot
 from .resources import AWSSubnet
+from .resources import AWSVMType
 from .resources import AWSVolume
 
 
@@ -295,7 +295,7 @@ class AWSComputeService(BaseComputeService):
 
     def __init__(self, provider):
         super(AWSComputeService, self).__init__(provider)
-        self._instance_type_svc = AWSInstanceTypesService(self.provider)
+        self._vm_type_svc = AWSVMTypeService(self.provider)
         self._instance_svc = AWSInstanceService(self.provider)
         self._region_svc = AWSRegionService(self.provider)
         self._images_svc = AWSImageService(self.provider)
@@ -305,8 +305,8 @@ class AWSComputeService(BaseComputeService):
         return self._images_svc
 
     @property
-    def instance_types(self):
-        return self._instance_type_svc
+    def vm_types(self):
+        return self._vm_type_svc
 
     @property
     def instances(self):
@@ -325,14 +325,14 @@ class AWSInstanceService(BaseInstanceService):
                                   cb_resource=AWSInstance,
                                   boto_collection_name='instances')
 
-    def create(self, name, image, instance_type, subnet, zone=None,
+    def create(self, name, image, vm_type, subnet, zone=None,
                key_pair=None, security_groups=None, user_data=None,
                launch_config=None, **kwargs):
         AWSInstance.assert_valid_resource_name(name)
 
         image_id = image.id if isinstance(image, MachineImage) else image
-        instance_size = instance_type.id if \
-            isinstance(instance_type, InstanceType) else instance_type
+        vm_size = vm_type.id if \
+            isinstance(vm_type, VMType) else vm_type
         subnet = (self.provider.networking.subnets.get(subnet)
                   if isinstance(subnet, str) else subnet)
         zone_id = zone.id if isinstance(zone, PlacementZone) else zone
@@ -355,7 +355,7 @@ class AWSInstanceService(BaseInstanceService):
                                KeyName=key_pair_name,
                                SecurityGroupIds=security_group_ids or None,
                                UserData=user_data,
-                               InstanceType=instance_size,
+                               InstanceType=vm_size,
                                Placement=placement,
                                BlockDeviceMappings=bdm,
                                SubnetId=subnet_id
@@ -464,10 +464,10 @@ class AWSInstanceService(BaseInstanceService):
         return self.svc.list(limit=limit, marker=marker)
 
 
-class AWSInstanceTypesService(BaseInstanceTypesService):
+class AWSVMTypeService(BaseVMTypeService):
 
     def __init__(self, provider):
-        super(AWSInstanceTypesService, self).__init__(provider)
+        super(AWSVMTypeService, self).__init__(provider)
 
     @property
     def instance_data(self):
@@ -489,9 +489,9 @@ class AWSInstanceTypesService(BaseInstanceTypesService):
         return r.json()
 
     def list(self, limit=None, marker=None):
-        inst_types = [AWSInstanceType(self.provider, inst_type)
-                      for inst_type in self.instance_data]
-        return ClientPagedResultList(self.provider, inst_types,
+        vm_types = [AWSVMType(self.provider, vm_type)
+                    for vm_type in self.instance_data]
+        return ClientPagedResultList(self.provider, vm_types,
                                      limit=limit, marker=marker)
 
 

+ 10 - 10
cloudbridge/cloud/providers/openstack/resources.py

@@ -11,7 +11,6 @@ from cloudbridge.cloud.base.resources import BaseBucket
 from cloudbridge.cloud.base.resources import BaseBucketObject
 from cloudbridge.cloud.base.resources import BaseFloatingIP
 from cloudbridge.cloud.base.resources import BaseInstance
-from cloudbridge.cloud.base.resources import BaseInstanceType
 from cloudbridge.cloud.base.resources import BaseInternetGateway
 from cloudbridge.cloud.base.resources import BaseKeyPair
 from cloudbridge.cloud.base.resources import BaseMachineImage
@@ -23,6 +22,7 @@ from cloudbridge.cloud.base.resources import BaseSecurityGroup
 from cloudbridge.cloud.base.resources import BaseSecurityGroupRule
 from cloudbridge.cloud.base.resources import BaseSnapshot
 from cloudbridge.cloud.base.resources import BaseSubnet
+from cloudbridge.cloud.base.resources import BaseVMType
 from cloudbridge.cloud.base.resources import BaseVolume
 from cloudbridge.cloud.base.resources import ClientPagedResultList
 from cloudbridge.cloud.interfaces.resources import GatewayState
@@ -169,10 +169,10 @@ class OpenStackPlacementZone(BasePlacementZone):
         return self._os_region
 
 
-class OpenStackInstanceType(BaseInstanceType):
+class OpenStackVMType(BaseVMType):
 
     def __init__(self, provider, os_flavor):
-        super(OpenStackInstanceType, self).__init__(provider)
+        super(OpenStackVMType, self).__init__(provider)
         self._os_flavor = os_flavor
 
     @property
@@ -299,20 +299,20 @@ class OpenStackInstance(BaseInstance):
                 if ipaddress.ip_address(address).is_private]
 
     @property
-    def instance_type_id(self):
+    def vm_type_id(self):
         """
-        Get the instance type name.
+        Get the VM type name.
         """
         return self._os_instance.flavor.get('id')
 
     @property
-    def instance_type(self):
+    def vm_type(self):
         """
-        Get the instance type object.
+        Get the VM type object.
         """
         flavor = self._provider.nova.flavors.get(
             self._os_instance.flavor.get('id'))
-        return OpenStackInstanceType(self._provider, flavor)
+        return OpenStackVMType(self._provider, flavor)
 
     def reboot(self):
         """
@@ -320,9 +320,9 @@ class OpenStackInstance(BaseInstance):
         """
         self._os_instance.reboot()
 
-    def terminate(self):
+    def delete(self):
         """
-        Permanently terminate this instance.
+        Permanently delete this instance.
         """
         # delete the port we created when launching
         # Assumption: it's the first interface in the list

+ 15 - 15
cloudbridge/cloud/providers/openstack/services.py

@@ -14,7 +14,6 @@ from cloudbridge.cloud.base.services import BaseComputeService
 from cloudbridge.cloud.base.services import BaseGatewayService
 from cloudbridge.cloud.base.services import BaseImageService
 from cloudbridge.cloud.base.services import BaseInstanceService
-from cloudbridge.cloud.base.services import BaseInstanceTypesService
 from cloudbridge.cloud.base.services import BaseKeyPairService
 from cloudbridge.cloud.base.services import BaseNetworkService
 from cloudbridge.cloud.base.services import BaseNetworkingService
@@ -25,14 +24,15 @@ from cloudbridge.cloud.base.services import BaseSecurityGroupService
 from cloudbridge.cloud.base.services import BaseSecurityService
 from cloudbridge.cloud.base.services import BaseSnapshotService
 from cloudbridge.cloud.base.services import BaseSubnetService
+from cloudbridge.cloud.base.services import BaseVMTypeService
 from cloudbridge.cloud.base.services import BaseVolumeService
-from cloudbridge.cloud.interfaces.resources import InstanceType
 from cloudbridge.cloud.interfaces.resources import KeyPair
 from cloudbridge.cloud.interfaces.resources import MachineImage
 from cloudbridge.cloud.interfaces.resources import PlacementZone
 from cloudbridge.cloud.interfaces.resources import SecurityGroup
 from cloudbridge.cloud.interfaces.resources import Snapshot
 from cloudbridge.cloud.interfaces.resources import Subnet
+from cloudbridge.cloud.interfaces.resources import VMType
 from cloudbridge.cloud.interfaces.resources import Volume
 from cloudbridge.cloud.providers.openstack import helpers as oshelpers
 
@@ -43,7 +43,6 @@ from novaclient.exceptions import NotFound as NovaNotFound
 from .resources import OpenStackBucket
 from .resources import OpenStackFloatingIP
 from .resources import OpenStackInstance
-from .resources import OpenStackInstanceType
 from .resources import OpenStackInternetGateway
 from .resources import OpenStackKeyPair
 from .resources import OpenStackMachineImage
@@ -53,6 +52,7 @@ from .resources import OpenStackRouter
 from .resources import OpenStackSecurityGroup
 from .resources import OpenStackSnapshot
 from .resources import OpenStackSubnet
+from .resources import OpenStackVMType
 from .resources import OpenStackVolume
 
 log = logging.getLogger(__name__)
@@ -298,14 +298,14 @@ class OpenStackImageService(BaseImageService):
         return oshelpers.to_server_paged_list(self.provider, cb_images, limit)
 
 
-class OpenStackInstanceTypesService(BaseInstanceTypesService):
+class OpenStackVMTypeService(BaseVMTypeService):
 
     def __init__(self, provider):
-        super(OpenStackInstanceTypesService, self).__init__(provider)
+        super(OpenStackVMTypeService, self).__init__(provider)
 
     def list(self, limit=None, marker=None):
         cb_itypes = [
-            OpenStackInstanceType(self.provider, obj)
+            OpenStackVMType(self.provider, obj)
             for obj in self.provider.nova.flavors.list(
                 limit=oshelpers.os_result_limit(self.provider, limit),
                 marker=marker)]
@@ -539,7 +539,7 @@ class OpenStackComputeService(BaseComputeService):
 
     def __init__(self, provider):
         super(OpenStackComputeService, self).__init__(provider)
-        self._instance_type_svc = OpenStackInstanceTypesService(self.provider)
+        self._vm_type_svc = OpenStackVMTypeService(self.provider)
         self._instance_svc = OpenStackInstanceService(self.provider)
         self._region_svc = OpenStackRegionService(self.provider)
         self._images_svc = OpenStackImageService(self.provider)
@@ -549,8 +549,8 @@ class OpenStackComputeService(BaseComputeService):
         return self._images_svc
 
     @property
-    def instance_types(self):
-        return self._instance_type_svc
+    def vm_types(self):
+        return self._vm_type_svc
 
     @property
     def instances(self):
@@ -566,7 +566,7 @@ class OpenStackInstanceService(BaseInstanceService):
     def __init__(self, provider):
         super(OpenStackInstanceService, self).__init__(provider)
 
-    def create(self, name, image, instance_type, subnet, zone=None,
+    def create(self, name, image, vm_type, subnet, zone=None,
                key_pair=None, security_groups=None, user_data=None,
                launch_config=None,
                **kwargs):
@@ -574,10 +574,10 @@ class OpenStackInstanceService(BaseInstanceService):
         OpenStackInstance.assert_valid_resource_name(name)
 
         image_id = image.id if isinstance(image, MachineImage) else image
-        instance_size = instance_type.id if \
-            isinstance(instance_type, InstanceType) else \
-            self.provider.compute.instance_types.find(
-                name=instance_type)[0].id
+        vm_size = vm_type.id if \
+            isinstance(vm_type, VMType) else \
+            self.provider.compute.vm_types.find(
+                name=vm_type)[0].id
         if isinstance(subnet, Subnet):
             subnet_id = subnet.id
             net_id = subnet.network_id
@@ -636,7 +636,7 @@ class OpenStackInstanceService(BaseInstanceService):
         os_instance = self.provider.nova.servers.create(
             name,
             None if self._has_root_device(launch_config) else image_id,
-            instance_size,
+            vm_size,
             min_count=1,
             max_count=1,
             availability_zone=zone_id,

+ 3 - 3
test/helpers/__init__.py

@@ -78,13 +78,13 @@ def skipIfNoService(services):
 TEST_DATA_CONFIG = {
     "AWSCloudProvider": {
         "image": os.environ.get('CB_IMAGE_AWS', 'ami-5ac2cd4d'),
-        "instance_type": os.environ.get('CB_INSTANCE_TYPE_AWS', 't2.nano'),
+        "vm_type": os.environ.get('CB_VM_TYPE_AWS', 't2.nano'),
         "placement": os.environ.get('CB_PLACEMENT_AWS', 'us-east-1a'),
     },
     "OpenStackCloudProvider": {
         "image": os.environ.get('CB_IMAGE_OS',
                                 '842b949c-ea76-48df-998d-8a41f2626243'),
-        "instance_type": os.environ.get('CB_INSTANCE_TYPE_OS', 'm1.tiny'),
+        "vm_type": os.environ.get('CB_VM_TYPE_OS', 'm1.tiny'),
         "placement": os.environ.get('CB_PLACEMENT_OS', 'zone-r1'),
     }
 }
@@ -126,7 +126,7 @@ def create_test_instance(
     return provider.compute.instances.create(
         instance_name,
         get_provider_test_data(provider, 'image'),
-        get_provider_test_data(provider, 'instance_type'),
+        get_provider_test_data(provider, 'vm_type'),
         subnet=subnet,
         zone=get_provider_test_data(provider, 'placement'),
         key_pair=key_pair,

+ 1 - 1
test/test_cloud_factory.py

@@ -21,7 +21,7 @@ class CloudFactoryTestCase(unittest.TestCase):
         self.assertIsInstance(CloudProviderFactory().create_provider(
             factory.ProviderList.AWS, {}),
             interfaces.CloudProvider,
-            "create_provider did not return a valid instance type")
+            "create_provider did not return a valid VM type")
 
     def test_create_provider_invalid(self):
         """

+ 26 - 26
test/test_compute_service.py

@@ -9,8 +9,8 @@ from cloudbridge.cloud.interfaces import InstanceState
 from cloudbridge.cloud.interfaces import InvalidConfigurationException
 from cloudbridge.cloud.interfaces.exceptions import WaitStateException
 from cloudbridge.cloud.interfaces.resources import Instance
-from cloudbridge.cloud.interfaces.resources import InstanceType
 from cloudbridge.cloud.interfaces.resources import SnapshotState
+from cloudbridge.cloud.interfaces.resources import VMType
 
 import six
 
@@ -118,21 +118,21 @@ class CloudComputeServiceTestCase(ProviderTestBase):
             self.assertTrue(
                 self._is_valid_ip(ip_address),
                 "Instance must have a valid IP address")
-            self.assertIsInstance(test_instance.instance_type_id,
+            self.assertIsInstance(test_instance.vm_type_id,
                                   six.string_types)
-            itype = self.provider.compute.instance_types.get(
-                test_instance.instance_type_id)
+            vm_type = self.provider.compute.vm_types.get(
+                test_instance.vm_type_id)
             self.assertEqual(
-                itype, test_instance.instance_type,
-                "Instance type {0} does not match expected type {1}".format(
-                    itype.name, test_instance.instance_type))
-            self.assertIsInstance(itype, InstanceType)
+                vm_type, test_instance.vm_type,
+                "VM type {0} does not match expected type {1}".format(
+                    vm_type.name, test_instance.vm_type))
+            self.assertIsInstance(vm_type, VMType)
             expected_type = helpers.get_provider_test_data(self.provider,
-                                                           'instance_type')
+                                                           'vm_type')
             self.assertEqual(
-                itype.name, expected_type,
-                "Instance type {0} does not match expected type {1}".format(
-                    itype.name, expected_type))
+                vm_type.name, expected_type,
+                "VM type {0} does not match expected type {1}".format(
+                    vm_type.name, expected_type))
             find_zone = [zone for zone in
                          self.provider.compute.regions.current.zones
                          if zone.id == test_instance.zone_id]
@@ -141,7 +141,7 @@ class CloudComputeServiceTestCase(ProviderTestBase):
                              " found in zones list")
 
     @helpers.skipIfNoService(['compute.instances', 'compute.images',
-                              'compute.instance_types'])
+                              'compute.vm_types'])
     def test_block_device_mapping_launch_config(self):
         lc = self.provider.compute.instances.create_launch_config()
 
@@ -187,22 +187,22 @@ class CloudComputeServiceTestCase(ProviderTestBase):
                 delete_on_terminate=True)
 
         # Add all available ephemeral devices
-        instance_type_name = helpers.get_provider_test_data(
+        vm_type_name = helpers.get_provider_test_data(
             self.provider,
-            "instance_type")
-        inst_type = self.provider.compute.instance_types.find(
-            name=instance_type_name)[0]
-        for _ in range(inst_type.num_ephemeral_disks):
+            "vm_type")
+        vm_type = self.provider.compute.vm_types.find(
+            name=vm_type_name)[0]
+        for _ in range(vm_type.num_ephemeral_disks):
             lc.add_ephemeral_device()
 
         # block_devices should be populated
         self.assertTrue(
-            len(lc.block_devices) == 2 + inst_type.num_ephemeral_disks,
+            len(lc.block_devices) == 2 + vm_type.num_ephemeral_disks,
             "Expected %d total block devices bit found %d" %
-            (2 + inst_type.num_ephemeral_disks, len(lc.block_devices)))
+            (2 + vm_type.num_ephemeral_disks, len(lc.block_devices)))
 
     @helpers.skipIfNoService(['compute.instances', 'compute.images',
-                              'compute.instance_types', 'block_store.volumes'])
+                              'compute.vm_types', 'block_store.volumes'])
     def test_block_device_mapping_attachments(self):
         name = "cb_blkattch-{0}".format(helpers.get_uuid())
 
@@ -256,12 +256,12 @@ class CloudComputeServiceTestCase(ProviderTestBase):
                     delete_on_terminate=True)
 
                 # Add all available ephemeral devices
-                instance_type_name = helpers.get_provider_test_data(
+                vm_type_name = helpers.get_provider_test_data(
                     self.provider,
-                    "instance_type")
-                inst_type = self.provider.compute.instance_types.find(
-                    name=instance_type_name)[0]
-                for _ in range(inst_type.num_ephemeral_disks):
+                    "vm_type")
+                vm_type = self.provider.compute.vm_types.find(
+                    name=vm_type_name)[0]
+                for _ in range(vm_type.num_ephemeral_disks):
                     lc.add_ephemeral_device()
 
                 net, subnet = helpers.create_test_network(self.provider, name)

+ 0 - 76
test/test_instance_types_service.py

@@ -1,76 +0,0 @@
-from test import helpers
-
-from test.helpers import ProviderTestBase
-from test.helpers import standard_interface_tests as sit
-
-import six
-
-
-class CloudInstanceTypesServiceTestCase(ProviderTestBase):
-
-    @helpers.skipIfNoService(['compute.instance_types'])
-    def test_instance_type_properties(self):
-
-        for inst_type in self.provider.compute.instance_types:
-            sit.check_repr(self, inst_type)
-            self.assertIsNotNone(
-                inst_type.id,
-                "InstanceType id must have a value")
-            self.assertIsNotNone(
-                inst_type.name,
-                "InstanceType name must have a value")
-            self.assertTrue(
-                inst_type.family is None or isinstance(
-                    inst_type.family,
-                    six.string_types),
-                "InstanceType family family be None or a"
-                " string but is: {0}".format(inst_type.family))
-            self.assertTrue(
-                inst_type.vcpus is None or (
-                    isinstance(inst_type.vcpus, six.integer_types) and
-                    inst_type.vcpus >= 0),
-                "InstanceType vcpus family be None or a positive integer")
-            self.assertTrue(
-                inst_type.ram is None or inst_type.ram >= 0,
-                "InstanceType ram must be None or a positive number")
-            self.assertTrue(
-                inst_type.size_root_disk is None or
-                inst_type.size_root_disk >= 0,
-                "InstanceType size_root_disk must be None or a positive number"
-                " but is: {0}".format(inst_type.size_root_disk))
-            self.assertTrue(
-                inst_type.size_ephemeral_disks is None or
-                inst_type.size_ephemeral_disks >= 0,
-                "InstanceType size_ephemeral_disk must be None or a positive"
-                " number")
-            self.assertTrue(
-                isinstance(inst_type.num_ephemeral_disks,
-                           six.integer_types) and
-                inst_type.num_ephemeral_disks >= 0,
-                "InstanceType num_ephemeral_disks must be None or a positive"
-                " number")
-            self.assertTrue(
-                inst_type.size_total_disk is None or
-                inst_type.size_total_disk >= 0,
-                "InstanceType size_total_disk must be None or a positive"
-                " number")
-            self.assertTrue(
-                inst_type.extra_data is None or isinstance(
-                    inst_type.extra_data, dict),
-                "InstanceType extra_data must be None or a dict")
-
-    @helpers.skipIfNoService(['compute.instance_types'])
-    def test_instance_types_standard(self):
-        """
-        Searching for an instance by name should return an
-        InstanceType object and searching for a non-existent
-        object should return an empty iterator
-        """
-        instance_type_name = helpers.get_provider_test_data(
-            self.provider,
-            "instance_type")
-        inst_type = self.provider.compute.instance_types.find(
-            name=instance_type_name)[0]
-
-        sit.check_standard_behaviour(
-                self, self.provider.compute.instance_types, inst_type)

+ 76 - 0
test/test_vm_types_service.py

@@ -0,0 +1,76 @@
+from test import helpers
+
+from test.helpers import ProviderTestBase
+from test.helpers import standard_interface_tests as sit
+
+import six
+
+
+class CloudVMTypeServiceTestCase(ProviderTestBase):
+
+    @helpers.skipIfNoService(['compute.vm_types'])
+    def test_vm_type_properties(self):
+
+        for vm_type in self.provider.compute.vm_types:
+            sit.check_repr(self, vm_type)
+            self.assertIsNotNone(
+                vm_type.id,
+                "VMType id must have a value")
+            self.assertIsNotNone(
+                vm_type.name,
+                "VMType name must have a value")
+            self.assertTrue(
+                vm_type.family is None or isinstance(
+                    vm_type.family,
+                    six.string_types),
+                "VMType family family be None or a"
+                " string but is: {0}".format(vm_type.family))
+            self.assertTrue(
+                vm_type.vcpus is None or (
+                    isinstance(vm_type.vcpus, six.integer_types) and
+                    vm_type.vcpus >= 0),
+                "VMType vcpus family be None or a positive integer")
+            self.assertTrue(
+                vm_type.ram is None or vm_type.ram >= 0,
+                "VMType ram must be None or a positive number")
+            self.assertTrue(
+                vm_type.size_root_disk is None or
+                vm_type.size_root_disk >= 0,
+                "VMType size_root_disk must be None or a positive number"
+                " but is: {0}".format(vm_type.size_root_disk))
+            self.assertTrue(
+                vm_type.size_ephemeral_disks is None or
+                vm_type.size_ephemeral_disks >= 0,
+                "VMType size_ephemeral_disk must be None or a positive"
+                " number")
+            self.assertTrue(
+                isinstance(vm_type.num_ephemeral_disks,
+                           six.integer_types) and
+                vm_type.num_ephemeral_disks >= 0,
+                "VMType num_ephemeral_disks must be None or a positive"
+                " number")
+            self.assertTrue(
+                vm_type.size_total_disk is None or
+                vm_type.size_total_disk >= 0,
+                "VMType size_total_disk must be None or a positive"
+                " number")
+            self.assertTrue(
+                vm_type.extra_data is None or isinstance(
+                    vm_type.extra_data, dict),
+                "VMType extra_data must be None or a dict")
+
+    @helpers.skipIfNoService(['compute.vm_types'])
+    def test_vm_types_standard(self):
+        """
+        Searching for an instance by name should return an
+        VMType object and searching for a non-existent
+        object should return an empty iterator
+        """
+        vm_type_name = helpers.get_provider_test_data(
+            self.provider,
+            "vm_type")
+        vm_type = self.provider.compute.vm_types.find(
+            name=vm_type_name)[0]
+
+        sit.check_standard_behaviour(
+                self, self.provider.compute.vm_types, vm_type)