Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Decides which instance object needs to be created"""
try:
instance_name = VSINSTANCE_TYPE[agent_object.instances._vs_instance_type_dict[instance_id]]
except KeyError:
instance_name = re.sub('[^A-Za-z0-9_]+', '', instance_name.replace(" ", "_"))
try:
instance_module = import_module("cvpysdk.instances.virtualserver.{}".format(instance_name))
except ImportError:
instance_module = import_module("cvpysdk.instances.virtualserver.null")
classes = getmembers(instance_module, lambda m: isclass(m) and not isabstract(m))
for name, _class in classes:
if issubclass(_class, VirtualServerInstance) and _class.__module__.rsplit(".", 1)[-1] == instance_name:
return object.__new__(_class)
Instance object associated with the
VirtualServer Instance
_get_instance_properties() -- VirtualServer Instance class method
overwritten to get azure Stack
Specific instance properties as well
_get_instance_properties_json() -- get the all instance related
properties of this subclient.
"""
from ..vsinstance import VirtualServerInstance
class AzureStackInstance(VirtualServerInstance):
"""Class for representing Azure stack instance of the Virtual Server agent"""
def __init__(self, agent, name, iid):
""" Initialize the Instance object for the given Virtual Server instance
Args:
agent (object) -- the instance of the agent class
name (str) -- the name of the instance
iid (int) -- the instance id
"""
self._vendor_id = 403
self._subscriptionid = None
def __init__(self, agent, name, iid):
"""Initialize the Instance object for the given Virtual Server instance.
Args:
class_object (agent_object,instance_name,instance_id) -- instance of the
Agent class,
instance name,
instance id
"""
self._vendor_id = 7
super(VirtualServerInstance, self).__init__(agent, name, iid)
instance_id) -- initialize object of oraclevm Instance object
associated with the VirtualServer Instance
_get_instance_properties() -- VirtualServer Instance class method overwritten
to get oraclevm specific instance properties
_get_instance_properties_json() -- get the all instance(oraclevm)
related properties of this subclient
"""
from ..vsinstance import VirtualServerInstance
class OracleVMInstance(VirtualServerInstance):
"""Class for representing VMWare instance of the Virtual Server agent."""
def __init__(self, agent_object, instance_name, instance_id=None):
"""Initialize the Instance object for the given Virtual Server instance.
Args:
agent_object (object) -- instance of the Agent class
instance_name (str) -- instance name
instance_id (int) -- instance id
"""
self._vendor_id = 10
self._vmwarvendor = None
associated with the VirtualServer Instance
_get_instance_properties() -- VirtualServer Instance class method overwritten
to get vcloud specific instance properties
_get_instance_properties_json() -- get the all instance(vcloud)
related properties of this subclient
"""
from ..vsinstance import VirtualServerInstance
from ...instance import Instance
class vcloudInstance(VirtualServerInstance):
"""Class for representing VCloud instance of the Virtual Server agent."""
def __init__(self, agent_object, instance_name, instance_id=None):
"""Initialize the Instance object for the given Virtual Server instance.
Args:
agent_object (object) -- instance of the Agent class
instance_name (str) -- instance name
instance_id (int) -- instance id
"""
self._vendor_id = 103
self._vmwarvendor = None
self._server_name = []
VirtualServer Instance
_get_instance_properties() -- VirtualServer Instance class method
overwritten to get azure RM
Specific instance properties as well
_get_instance_properties_json() -- get the all instance related
properties of this subclient.
"""
from ..vsinstance import VirtualServerInstance
from ...exception import SDKException
from ...instance import Instance
class AzureRMInstance(VirtualServerInstance):
'''
AzureResoureceManagerInstance:
__init__(agent_object,instance_name,instance_id) -- initialize object
of azure resource manager Instance object associated with
the VirtualServer Instance
'''
def __init__(self, agent, name, iid):
"""Initialize the Instance object for the given Virtual Server instance.
Args:
class_object (agent_object,instance_name,instance_id) -- instance of the
Agent class,
instance name,
GoogleCloudInstance: Derived class from VirtualServer Base class, representing a
Google Cloud Platform instance, and to perform operations on that instance
GoogleCloudInstance:
__init__(agent_object,instance_name,instance_id) -- initialize object of Google Cloud
Platform Instance object associated
with the VirtualServer Instance
"""
from ..vsinstance import VirtualServerInstance
from ...exception import SDKException
from ...instance import Instance
class GoogleCloudInstance(VirtualServerInstance):
def __init__(self, agent, name, iid):
self._vendor_id = 16
self._server_name = []
super(GoogleCloudInstance, self).__init__(agent, name, iid)
def _get_instance_properties(self):
"""
Get the properties of this instance
Raise:
SDK Exception:
if response is not empty
if response is not success
"""
super(GoogleCloudInstance, self)._get_instance_properties()
instance_id) -- initialize object of vmware Instance object
associated with the VirtualServer Instance
_get_instance_properties() -- VirtualServer Instance class method overwritten
to get openstack specific instance properties
_get_instance_properties_json() -- get the all instance(vmware)
related properties of this subclient
"""
from ..vsinstance import VirtualServerInstance
class OpenStackInstance(VirtualServerInstance):
"""Class for representing VMWare instance of the Virtual Server agent."""
def __init__(self, agent_object, instance_name, instance_id=None):
"""Initialize the Instance object for the given Virtual Server instance.
Args:
agent_object (object) -- instance of the Agent class
instance_name (str) -- instance name
instance_id (int) -- instance id
"""
self._vendor_id = 12
self._server_name = []
self._server_host_name = []
VirtualServer Instance
_get_instance_properties() -- VirtualServer Instance class method
overwritten to get nutanix AHV
Specific instance properties as well
_get_instance_properties_json() -- get the all instance related
properties of this subclient.
"""
from ..vsinstance import VirtualServerInstance
from ...exception import SDKException
from ...instance import Instance
class nutanixinstance(VirtualServerInstance):
"""Class for representing Nutanix AHV instance of the Virtual Server agent"""
def __init__(self, agent, name, iid):
""" Initialize the Instance object for the given Virtual Server instance
Args:
agent (object) -- the instance of the agent class
name (str) -- the name of the instance
iid (int) -- the instance id
"""
self._vendor_id = 601
self._nutanix_cluster = None
_get_instance_properties() -- VirtualServer Instance class method
overwritten to get Hyper-V Specific
instance properties as well
_set_instance_properties() -- Hyper-V Instance class method to
set Hyper-V Specific instance properties
"""
from ..vsinstance import VirtualServerInstance
class HyperVInstance(VirtualServerInstance):
"""Class for representing an Hyper-V of the Virtual Server agent."""
def __init__(self, agent, instance_name, instance_id=None):
"""Initialize the Instance object for the given Virtual Server instance.
Args:
class_object (agent_object,instance_name,instance_id) -- instance of the
Agent class,
instance name,
instance id
"""
self._vendor_id = 2
super(HyperVInstance, self).__init__(agent, instance_name, instance_id)