def create_servers(self): servers = [] for credential in self.credentials: servers.append( provider.Server(host=credential["host"], user=credential["user"], key=credential.get("key"), password=credential.get("password"), port=credential.get("port", 22))) return servers
def create_servers(self): """Create VMs with chosen image.""" image_uuid = self.get_image_uuid() userdata = self.get_userdata() flavor = self.config["flavor_id"] nics = self.get_nics() keypair, public_key_path = self.create_keypair() self.create_security_group_and_rules() sg_args = {"security_groups": [self.sg.name]} if self.sg else {} os_servers = [] for i in range(self.config.get("amount", 1)): name = "%s-%d" % (self.config["deployment_name"], i) server = self.nova.servers.create(name, image_uuid, flavor, nics=nics, key_name=keypair.name, userdata=userdata, config_drive=self.config.get( "config_drive", False), **sg_args) os_servers.append(server) self.resources.create({"id": server.id}, type=SERVER_TYPE) kwargs = { "ready_statuses": ["ACTIVE"], "update_resource": utils.get_from_manager(), "timeout": 120, "check_interval": 5 } servers = [] for os_server in os_servers: os_server = utils.wait_for(os_server, **kwargs) server = provider.Server(host=_get_address(os_server), user="******", key=public_key_path) servers.append(server) for s in servers: s.ssh.wait(timeout=120, interval=5) if self.config.get("wait_for_cloud_init", False): for s in servers: utils.wait_for(s, is_ready=_cloud_init_success) return servers
def create_by_rebooting(self, system_name): """Ask cobbler to re-boot server which is controlled by given system. :param system_name: cobbler object as seen in Cobbler WebGUI :returns: rally Server """ token = self.cobbler.login(self.config["user"], self.config["password"]) handle = self.cobbler.get_system_handle(system_name, token) self.cobbler.power_system(handle, "reboot", token) rendered = self.cobbler.get_system_as_rendered(system_name) return provider.Server(host=self.ip_for_system(rendered), user=rendered["power_user"], key=rendered.get("redhat_management_key"), password=self.config.get("system_password", ""), port=22)
def create_servers(self): """Create VMs with chosen image.""" image_uuid = self.get_image_uuid() userdata = self.get_userdata() flavor = self.config["flavor_id"] nics = self.get_nics() keypair, public_key_path = self.create_keypair() os_servers = [] for i in range(self.config.get("amount", 1)): name = "%s-%d" % (self.config["deployment_name"], i) server = self.nova.servers.create(name, image_uuid, flavor, nics=nics, key_name=keypair.name, userdata=userdata, config_drive=self.config.get( "config_drive", False)) os_servers.append(server) self.resources.create({"id": server.id}, type=SERVER_TYPE) kwargs = { "is_ready": utils.resource_is("ACTIVE"), "update_resource": utils.get_from_manager(), "timeout": 120, "check_interval": 5 } servers = [] for os_server in os_servers: os_server = utils.wait_for(os_server, **kwargs) server = provider.Server(host=_get_address(os_server), user="******", key=public_key_path) servers.append(server) for s in servers: s.ssh.wait(timeout=120, interval=5) # NOTE(eyerediskin): usually ssh is ready much earlier then cloud-init time.sleep(8) return servers
def create_vm(self, vm_name): """Clone prebuilt VM template and start it.""" virt_url = self._get_virt_connection_url(self.config["connection"]) cmd = [ "virt-clone", "--connect=%s" % virt_url, "-o", self.config["template_name"], "-n", vm_name, "--auto-clone" ] subprocess.check_call(cmd) cmd = ["virsh", "--connect=%s" % virt_url, "start", vm_name] subprocess.check_call(cmd) self.resources.create({"name": vm_name}) return provider.Server( self._determine_vm_ip(vm_name), self.config["template_user"], password=self.config.get("template_password"), )
def create_vm(self, vm_name): """Clone prebuilt VM template and start it.""" virt_url = self._get_virt_connection_url(self.config["connection"]) cmd = "virt-clone --connect=%(url)s -o %(t)s -n %(n)s --auto-clone" % { "t": self.config["template_name"], "n": vm_name, "url": virt_url } subprocess.check_call(cmd, shell=True) cmd = "virsh --connect=%s start %s" % (virt_url, vm_name) subprocess.check_call(cmd, shell=True) self.resources.create({"name": vm_name}) return provider.Server( self._determine_vm_ip(vm_name), self.config["template_user"], password=self.config.get("template_password"), )
def test_credentials(self): server_one = provider.Server(*self.vals) creds = server_one.get_credentials() server_two = provider.Server.from_credentials(creds) for k in self.keys: self.assertEqual(getattr(server_one, k), getattr(server_two, k))
def test_init_server_dto(self): server = provider.Server(*self.vals) for k, v in dict(zip(self.keys, self.vals)).items(): self.assertEqual(getattr(server, k), v) self.assertIsInstance(server.ssh, sshutils.SSH)