"""
Instantiates and returns a client for communications with OpenStack's Nova
server
:param os_creds: The connection credentials to the OpenStack API
"""
Instantiates and returns a client for communications with OpenStack's Nova
server
:param os_creds: The connection credentials to the OpenStack API
-def create_server(nova, neutron, glance, instance_config, image_config,
- project_id, keypair_config=None):
+def create_server(nova, keystone, neutron, glance, instance_config,
+ image_config, project_name, keypair_config=None):
:param neutron: the neutron client for retrieving ports (required)
:param glance: the glance client (required)
:param instance_config: the VMInstConfig object (required)
:param image_config: the VM's ImageConfig object (required)
:param neutron: the neutron client for retrieving ports (required)
:param glance: the glance client (required)
:param instance_config: the VMInstConfig object (required)
:param image_config: the VM's ImageConfig object (required)
:param keypair_config: the VM's KeypairConfig object (optional)
:return: a snaps.domain.VmInst object
"""
:param keypair_config: the VM's KeypairConfig object (optional)
:return: a snaps.domain.VmInst object
"""
- neutron, port_settings=port_setting, project_id=project_id)
+ neutron, keystone, port_settings=port_setting,
+ project_name=project_name)
- return __map_os_server_obj_to_vm_inst(neutron, server, project_id)
+ return __map_os_server_obj_to_vm_inst(
+ neutron, keystone, server, project_name)
-def get_server(nova, neutron, vm_inst_settings=None, server_name=None,
- project_id=None):
+def get_server(nova, neutron, keystone, vm_inst_settings=None,
+ server_name=None, project_id=None):
"""
Returns a VmInst object for the first server instance found.
:param nova: the Nova client
:param neutron: the Neutron client
"""
Returns a VmInst object for the first server instance found.
:param nova: the Nova client
:param neutron: the Neutron client
:param vm_inst_settings: the VmInstanceConfig object from which to build
the query if not None
:param server_name: the server with this name to return if vm_inst_settings
:param vm_inst_settings: the VmInstanceConfig object from which to build
the query if not None
:param server_name: the server with this name to return if vm_inst_settings
- return __map_os_server_obj_to_vm_inst(neutron, server, project_id)
+ return __map_os_server_obj_to_vm_inst(
+ neutron, keystone, server, project_id)
-def __map_os_server_obj_to_vm_inst(neutron, os_server, project_id):
+def __map_os_server_obj_to_vm_inst(neutron, keystone, os_server,
+ project_name=None):
if len(os_server.networks) > 0:
for net_name, ips in os_server.networks.items():
network = neutron_utils.get_network(
if len(os_server.networks) > 0:
for net_name, ips in os_server.networks.items():
network = neutron_utils.get_network(
- neutron, network_name=net_name, project_id=project_id)
+ neutron, keystone, network_name=net_name,
+ project_name=project_name)
name=os_server.name, inst_id=os_server.id,
image_id=os_server.image['id'], flavor_id=os_server.flavor['id'],
ports=out_ports, keypair_name=os_server.key_name,
name=os_server.name, inst_id=os_server.id,
image_id=os_server.image['id'], flavor_id=os_server.flavor['id'],
ports=out_ports, keypair_name=os_server.key_name,
- sec_grp_names=sec_grp_names, volume_ids=volumes)
+ sec_grp_names=sec_grp_names, volume_ids=volumes,
+ compute_host=os_server._info.get('OS-EXT-SRV-ATTR:host'),
+ availability_zone=os_server._info.get('OS-EXT-AZ:availability_zone'))
-def get_latest_server_object(nova, neutron, server, project_id):
+def get_latest_server_object(nova, neutron, keystone, server, project_name):
"""
Returns a server with a given id
:param nova: the Nova client
:param neutron: the Neutron client
"""
Returns a server with a given id
:param nova: the Nova client
:param neutron: the Neutron client
:return: the list of servers or None if not found
"""
server = __get_latest_server_os_object(nova, server)
:return: the list of servers or None if not found
"""
server = __get_latest_server_os_object(nova, server)
- return __map_os_server_obj_to_vm_inst(neutron, server, project_id)
+ return __map_os_server_obj_to_vm_inst(
+ neutron, keystone, server, project_name)
-def get_server_object_by_id(nova, neutron, server_id, project_id):
+def get_server_object_by_id(nova, neutron, keystone, server_id,
+ project_name=None):
"""
Returns a server with a given id
:param nova: the Nova client
:param neutron: the Neutron client
"""
Returns a server with a given id
:param nova: the Nova client
:param neutron: the Neutron client
:return: an SNAPS-OO VmInst object or None if not found
"""
server = __get_latest_server_os_object_by_id(nova, server_id)
:return: an SNAPS-OO VmInst object or None if not found
"""
server = __get_latest_server_os_object_by_id(nova, server_id)
- return __map_os_server_obj_to_vm_inst(neutron, server, project_id)
+ return __map_os_server_obj_to_vm_inst(
+ neutron, keystone, server, project_name)
-def attach_volume(nova, neutron, server, volume, project_id, timeout=120):
+def attach_volume(nova, neutron, keystone, server, volume, project_name,
+ timeout=120):
"""
Attaches a volume to a server. When the timeout parameter is used, a VmInst
object with the proper volume updates is returned unless it has not been
updated in the allotted amount of time then an Exception will be raised.
:param nova: the nova client
:param neutron: the neutron client
"""
Attaches a volume to a server. When the timeout parameter is used, a VmInst
object with the proper volume updates is returned unless it has not been
updated in the allotted amount of time then an Exception will be raised.
:param nova: the nova client
:param neutron: the neutron client
:param timeout: denotes the amount of time to block to determine if the
has been properly attached.
:return: updated VmInst object
:param timeout: denotes the amount of time to block to determine if the
has been properly attached.
:return: updated VmInst object
- vm = get_server_object_by_id(nova, neutron, server.id, project_id)
+ vm = get_server_object_by_id(
+ nova, neutron, keystone, server.id, project_name)
-def detach_volume(nova, neutron, server, volume, project_id, timeout=120):
+def detach_volume(nova, neutron, keystone, server, volume, project_name,
+ timeout=120):
"""
Detaches a volume to a server. When the timeout parameter is used, a VmInst
object with the proper volume updates is returned unless it has not been
updated in the allotted amount of time then an Exception will be raised.
:param nova: the nova client
:param neutron: the neutron client
"""
Detaches a volume to a server. When the timeout parameter is used, a VmInst
object with the proper volume updates is returned unless it has not been
updated in the allotted amount of time then an Exception will be raised.
:param nova: the nova client
:param neutron: the neutron client
:param timeout: denotes the amount of time to block to determine if the
has been properly detached.
:return: updated VmInst object
:param timeout: denotes the amount of time to block to determine if the
has been properly detached.
:return: updated VmInst object
- vm = get_server_object_by_id(nova, neutron, server.id, project_id)
+ vm = get_server_object_by_id(
+ nova, neutron, keystone, server.id, project_name)