diff options
Diffstat (limited to 'snaps/openstack/create_instance.py')
-rw-r--r-- | snaps/openstack/create_instance.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/snaps/openstack/create_instance.py b/snaps/openstack/create_instance.py index 73cdf8a..dcb73cd 100644 --- a/snaps/openstack/create_instance.py +++ b/snaps/openstack/create_instance.py @@ -113,8 +113,8 @@ class OpenStackVmInstance(OpenStackComputeObject): 'Found existing machine with name - %s', self.instance_settings.name) - fips = neutron_utils.get_floating_ips(self.__neutron, - self.__ports) + fips = neutron_utils.get_port_floating_ips( + self.__neutron, self.__ports) for port_id, fip in fips: settings = self.instance_settings.floating_ip_settings for fip_setting in settings: @@ -136,7 +136,7 @@ class OpenStackVmInstance(OpenStackComputeObject): glance = glance_utils.glance_client(self._os_creds) self.__vm = nova_utils.create_server( self._nova, self.__neutron, glance, self.instance_settings, - self.image_settings, self.keypair_settings) + self.image_settings, self.project_id, self.keypair_settings) logger.info('Created instance with name - %s', self.instance_settings.name) @@ -167,7 +167,7 @@ class OpenStackVmInstance(OpenStackComputeObject): if volume and self.vm_active(block=True): vm = nova_utils.attach_volume( self._nova, self.__neutron, self.__vm, volume, - VOL_DETACH_TIMEOUT) + self.project_id, timeout=VOL_DETACH_TIMEOUT) if vm: self.__vm = vm @@ -273,7 +273,7 @@ class OpenStackVmInstance(OpenStackComputeObject): if volume: vm = nova_utils.detach_volume( self._nova, self.__neutron, self.__vm, volume, - VOL_DETACH_TIMEOUT) + self.project_id, timeout=VOL_DETACH_TIMEOUT) if vm: self.__vm = vm else: @@ -318,7 +318,8 @@ class OpenStackVmInstance(OpenStackComputeObject): for port_setting in port_settings: port = neutron_utils.get_port( - self.__neutron, port_settings=port_setting) + self.__neutron, port_settings=port_setting, + project_id=self.project_id) if port: ports.append((port_setting.name, port)) @@ -358,7 +359,7 @@ class OpenStackVmInstance(OpenStackComputeObject): :return: Server object """ return nova_utils.get_server_object_by_id( - self._nova, self.__neutron, self.__vm.id) + self._nova, self.__neutron, self.__vm.id, self.project_id) def get_console_output(self): """ @@ -506,7 +507,7 @@ class OpenStackVmInstance(OpenStackComputeObject): STATUS_ACTIVE, block, self.instance_settings.vm_boot_timeout, poll_interval): self.__vm = nova_utils.get_server_object_by_id( - self._nova, self.__neutron, self.__vm.id) + self._nova, self.__neutron, self.__vm.id, self.project_id) return True return False @@ -773,19 +774,21 @@ class OpenStackVmInstance(OpenStackComputeObject): self._nova, self.__vm, reboot_type=reboot_type) -def generate_creator(os_creds, vm_inst, image_config, keypair_config=None): +def generate_creator(os_creds, vm_inst, image_config, project_id, + keypair_config=None): """ Initializes an OpenStackVmInstance object :param os_creds: the OpenStack credentials :param vm_inst: the SNAPS-OO VmInst domain object :param image_config: the associated ImageConfig object + :param project_id: the associated project ID :param keypair_config: the associated KeypairConfig object (optional) :return: an initialized OpenStackVmInstance object """ nova = nova_utils.nova_client(os_creds) neutron = neutron_utils.neutron_client(os_creds) derived_inst_config = settings_utils.create_vm_inst_config( - nova, neutron, vm_inst) + nova, neutron, vm_inst, project_id) derived_inst_creator = OpenStackVmInstance( os_creds, derived_inst_config, image_config, keypair_config) |