vmshepherd.iaas package¶
Submodules¶
vmshepherd.iaas.abstract module¶
IaaS driver is responsible for communication with IaaS provider. To VmShepherd work, driver should implement create_vm, terminate_vms, list_vms and get_vm_info.
Initialization - consider following config:
iaas:
driver: SomeIaaS
auth_key: AAAA
auth_secret: BBBB
some_x: CCC
All params will be passed as config dict to the driver init:
-
class
vmshepherd.iaas.abstract.
AbstractIaasDriver
(config=None)[source]¶ Bases:
object
-
create_vm
(preset_name: str, image: str, flavor: str, security_groups: List = None, userdata: Dict = None, key_name: str = None, availability_zone: str = None, subnets: List = None) → Any[source]¶ Create (boot) a new server.
Parameters: - preset_name (string) – Name of vm group where vm is created.
- image (string) – Image name.
- flavor (string) – Flavor (or instance_type in AWS) name.
- security_groups (list) – A list of security group names.
- userdata (dict) – A dict of arbitrary key/value metadata to store in grains.
- key_name (string) – (optional extension) name of previously created keypair to inject into the instance.
- availability_zone (string) – Name of the availability zone for instance placement.
- subnets (string) – List of the subnets for instance placement.
Returns Any vm_id.
-
get_vm
(vm_id: Any) → vmshepherd.iaas.vm.Vm[source]¶ Get vm info (with metadata and/or tags).
Parameters: vm_id (string) – Id Vm to get. Returns list of Vm objects.
-
vmshepherd.iaas.dummy_driver module¶
-
class
vmshepherd.iaas.dummy_driver.
DummyIaasDriver
(config=None)[source]¶ Bases:
vmshepherd.iaas.abstract.AbstractIaasDriver
DummyIaasDriver - mainly for test purposes.
Implements required API of fake-in-memory-iaas (dict). To mimic communication with external service additional delay has been introduced.
-
create_vm
(**kwargs)¶
-
get_vm
(**kwargs)¶
-
list_vms
(**kwargs)¶
-
terminate_vm
(**kwargs)¶
-
vmshepherd.iaas.exception module¶
vmshepherd.iaas.openstack_driver module¶
vmshepherd.iaas.vm module¶
-
class
vmshepherd.iaas.vm.
Vm
(manager, id, name, ip, created, state=<VmState.UNKNOWN: 'unknown'>, metadata=None, tags=None, flavor=None, image=None, timed_shutdown_at=None)[source] Bases:
object
Vm class definition. Define API to implement in specific IaasDrivers like Openstack or EC2.
-
get_state
()[source]
-
is_dead
()[source]
-
is_running
()[source]
-
terminate
()[source] Terminate vm.
-
-
class
vmshepherd.iaas.vm.
VmState
[source] Bases:
enum.Enum
Standard states for a Virtual Machine.
Variables: - RUNNING – Vm is running.
- NEARBY_SHUTDOWN – Vm is running but it’s minutes are numbered.
- AFTER_TIME_SHUTDOWN – Vm is running but it should be dead now.
- TERMINATED – Vm is terminated. This node can’t be started later on.
- PENDING – Vm is pending.
- UNKNOWN – Vm state is unknown.
- ERROR – Vm is an error state. Usually no operations can be performed on the node once it ends up in the error state.
-
AFTER_TIME_SHUTDOWN
= 'after_time_shutdown'
-
ERROR
= 'error'
-
NEARBY_SHUTDOWN
= 'nearby_shutdown'
-
PENDING
= 'pending'
-
RUNNING
= 'running'
-
TERMINATED
= 'terminated'
-
UNKNOWN
= 'unknown'