Esempio n. 1
0
    def test_launch(self):
        instance_name = f"test-instance-{util.random_string()}"

        logging.info(f"Test launch: {instance_name}.")
        lxc.launch("images:alpine/3.10", instance_name)
        instance = util.find(
            lambda i: i["Name"] == instance_name and i["Status"] == "Running",
            lxc.list_(), None)
        self.assertIsNotNone(instance)
Esempio n. 2
0
    def test_delete(self):
        instance_name = f"test-instance-{util.random_string()}"
        lxc.launch("images:alpine/3.10", instance_name)
        lxc.stop([instance_name])
        lxc.delete([instance_name])

        instance = util.find(lambda i: i["Name"] == instance_name, lxc.list_(),
                             None)
        self.assertIsNone(instance)
Esempio n. 3
0
    def test_launch(self):
        util.mark("test_launch")

        instance_name = util.generate_instance_name()
        lxc.launch("images", "alpine/3.10", instance_name)
        instance = yurt_util.find(
            lambda i: i["Name"] == instance_name and i["Status"] == "Running",
            lxc.list_(),
            None
        )
        self.assertIsNotNone(instance)
Esempio n. 4
0
    def test_ping_from_host(self):
        instance_name = f"test-instance-{util.random_string()}"
        lxc.launch("images:alpine/3.10", instance_name)
        instance = util.find(
            lambda i: i["Name"] == instance_name and i["Status"] == "Running",
            lxc.list_(), None)
        self.assertIsNotNone(instance)

        logging.info(f"Test ping: {instance_name}")
        ip_address = instance["IP Address"]
        self.assertTrue(ping(ip_address))
Esempio n. 5
0
    def test_delete(self):
        util.mark("test_delete")

        instance_name = util.generate_instance_name()
        lxc.launch("images", "alpine/3.10", instance_name)
        lxc.stop([instance_name])
        lxc.delete([instance_name])

        instance = yurt_util.find(
            lambda i: i["Name"] == instance_name,
            lxc.list_(),
            None
        )
        self.assertIsNone(instance)
Esempio n. 6
0
    def test_ping_from_host(self):
        util.mark("test_ping_from_host")

        instance_name = util.generate_instance_name()
        lxc.launch("images", "alpine/3.10", instance_name)
        instance = yurt_util.find(
            lambda i: i["Name"] == instance_name and i["Status"] == "Running",
            lxc.list_(),
            None
        )
        self.assertIsNotNone(instance)

        logging.info(f"Test ping: {instance_name}")
        ip_address = instance["IP Address"]
        self.assertTrue(util.ping(ip_address))
Esempio n. 7
0
def list_():
    """
    List instances.
    """

    try:
        vm.ensure_is_ready()

        instances = tabulate(lxc.list_(), headers="keys")
        if instances:
            click.echo(instances)
        else:
            click.echo(
                "No instances found. Create one with 'yurt launch <image> <name>'")

    except YurtException as e:
        logging.error(e.message)