Пример #1
0
    def init_vm(self, vm_id, lab_repo_name):
        logger.debug("BridgeVZAdapter: init_vm(): vm_id = %s" % vm_id)
        success = True
        success = success and self.copy_public_key(vm_id)
        success = success and self.copy_ovpl_source(vm_id)
        success = success and self.copy_lab_source(vm_id, lab_repo_name,
                                              self.git.get_git_clone_loc())
        success = success and self.start_vm_manager(vm_id)
        response = {"vm_id": vm_id, "vm_ip": IP_ADDRESS, "vm_port": base_config.VM_MANAGER_PORT}
                            
        # check if the VMManager service came up and running..
        logger.debug("Ensuring VMManager service is running on VM %s" %
                     response['vm_ip'])
        vmmgr_port = int(base_config.VM_MANAGER_PORT)
        success = base_adapter.wait_for_service(response['vm_ip'], vmmgr_port,
                                                self.time_before_next_retry,
                                                config.TIMEOUT)
        
        if not success:
            logger.debug("Could not reach VMManager after %s secs!! Aborting." %
                         config.TIMEOUT)
            return (success, response)

        logger.debug("centos_openvz_adapter: init_vm(): success = %s, response = %s" %
                     (success, response))
       
        return (success, response)
Пример #2
0
    def init_vm(self, vm_id, lab_repo_name):
        """
        initialize the VM by copying relevant ADS component (VMManager) and
        the lab sources, add default gateway, start the VMManager and ensure the
        VMManager service is up...
        """
        logger.debug("AWSAdapter: init_vm(): vm_id = %s" % vm_id)

        vm_ip_addr = self.get_vm_ip(vm_id)

        logger.debug("instance id: %s; IP addr: %s" % (vm_id, vm_ip_addr))

        # Return info for AdapterServer: the VM's id, IP and port of VM Mgr
        info = {"vm_id": vm_id, "vm_ip": vm_ip_addr,
                "vm_port": base_config.VM_MANAGER_PORT}

        # wait until the VM is up with the SSH service..
        # until then we won't be able to go ahead with later steps..
        logger.debug("AWSAdapter: VM %s: waiting for SSH to be up..." %
                     vm_ip_addr)
        success = base_adapter.wait_for_service(vm_ip_addr, 22,
                                        self.time_before_next_retry,
                                        config.TIMEOUT)

        if not success:
            logger.debug("Could not reach SSH after %s secs!! Aborting." %
                         config.TIMEOUT)
            return (success, info)

        success = self._copy_ovpl_source(vm_ip_addr)
        if not success:
            logger.debug("Error in copying OVPL sources. Aborting.")
            return (success, info)

        success = self._copy_lab_source(vm_ip_addr, lab_repo_name)
        if not success:
            logger.debug("Error in copying lab sources. Aborting.")
            return (success, info)

        # NOTE: this step is necessary as the systems team is using a single
        # subnet for both public and private nodes, and that means for private
        # nodes default gateway has to be configured separately!
        success = self._add_default_gw(vm_ip_addr)
        if not success:
            logger.debug("Error in adding default gateway. Aborting.")
            return (success, info)

        success = self.start_vm_manager(vm_ip_addr)
        if not success:
            logger.debug("Error in starting VMManager. Aborting.")
            return (success, info)

        # check if the VMManager service came up and running..
        logger.debug("Ensuring VMManager service is running on VM %s" %
                     vm_ip_addr)
        vmmgr_port = int(base_config.VM_MANAGER_PORT)
        success = base_adapter.wait_for_service(vm_ip_addr, vmmgr_port,
                                        self.time_before_next_retry,
                                        config.TIMEOUT)
        if not success:
            logger.debug("Could not reach VMManager after %s secs!! Aborting." %
                         config.TIMEOUT)
            return (success, info)

        logger.debug("AWSAdapter: init_vm(): success = %s, response = %s" %
                     (success, info))

        return (success, info)
Пример #3
0
    def init_vm(self, vm_id, lab_repo_name):
        """
        initialize the VM by copying relevant ADS component (VMManager) and
        the lab sources, add default gateway, start the VMManager and ensure the
        VMManager service is up...
        """
        logger.debug("AWSAdapter: init_vm(): vm_id = %s" % vm_id)

        vm_ip_addr = self.get_vm_ip(vm_id)

        logger.debug("instance id: %s; IP addr: %s" % (vm_id, vm_ip_addr))

        # Return info for AdapterServer: the VM's id, IP and port of VM Mgr
        info = {
            "vm_id": vm_id,
            "vm_ip": vm_ip_addr,
            "vm_port": base_config.VM_MANAGER_PORT
        }

        # wait until the VM is up with the SSH service..
        # until then we won't be able to go ahead with later steps..
        logger.debug("AWSAdapter: VM %s: waiting for SSH to be up..." %
                     vm_ip_addr)
        success = base_adapter.wait_for_service(vm_ip_addr, 22,
                                                self.time_before_next_retry,
                                                config.TIMEOUT)

        if not success:
            logger.debug("Could not reach SSH after %s secs!! Aborting." %
                         config.TIMEOUT)
            return (success, info)

        success = self._copy_ovpl_source(vm_ip_addr)
        if not success:
            logger.debug("Error in copying OVPL sources. Aborting.")
            return (success, info)

        success = self._copy_lab_source(vm_ip_addr, lab_repo_name)
        if not success:
            logger.debug("Error in copying lab sources. Aborting.")
            return (success, info)

        # NOTE: this step is necessary as the systems team is using a single
        # subnet for both public and private nodes, and that means for private
        # nodes default gateway has to be configured separately!
        success = self._add_default_gw(vm_ip_addr)
        if not success:
            logger.debug("Error in adding default gateway. Aborting.")
            return (success, info)

        success = self.start_vm_manager(vm_ip_addr)
        if not success:
            logger.debug("Error in starting VMManager. Aborting.")
            return (success, info)

        # check if the VMManager service came up and running..
        logger.debug("Ensuring VMManager service is running on VM %s" %
                     vm_ip_addr)
        vmmgr_port = int(base_config.VM_MANAGER_PORT)
        success = base_adapter.wait_for_service(vm_ip_addr, vmmgr_port,
                                                self.time_before_next_retry,
                                                config.TIMEOUT)
        if not success:
            logger.debug(
                "Could not reach VMManager after %s secs!! Aborting." %
                config.TIMEOUT)
            return (success, info)

        logger.debug("AWSAdapter: init_vm(): success = %s, response = %s" %
                     (success, info))

        return (success, info)