Пример #1
0
def launch(image, name):
    """
    Create and start a container.

    \b
    <image>     -   Image to use as source. e.g. ubuntu/18.04 or alpine/3.11.
                    Only images in https://images.linuxcontainers.org
                    are supported at this time. Run 'yurt images' to list them.
    NAME        -   Container name

    \b
    Container names must:
    * be between 1 and 63 characters long
    * be made up exclusively of letters, numbers and dashes from the ASCII table
    * not start with a digit or a dash
    * not end with a dash

    EXAMPLES:

    \b
    $ yurt launch ubuntu/18.04 c1       -   Create and start an ubuntu 18.04 container.

    """

    try:
        vm.ensure_is_ready()

        lxc.launch("images", image, name)

    except YurtException as e:
        logging.error(e.message)
Пример #2
0
    def test_ping_between_instances(self):
        instance1_name = f"test-instance-{util.random_string()}"
        instance2_name = f"test-instance-{util.random_string()}"
        lxc.launch("images:alpine/3.10", instance1_name)
        lxc.launch("images:alpine/3.10", instance2_name)

        lxc.exec_(instance1_name, ["ping", "-c1", instance2_name])
Пример #3
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)
Пример #4
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)
Пример #5
0
    def test_ping_between_instances(self):
        util.mark("test_ping_between_instances")

        instance1_name = util.generate_instance_name()
        instance2_name = util.generate_instance_name()
        lxc.launch("images", "alpine/3.10", instance1_name)
        lxc.launch("images", "alpine/3.10", instance2_name)

        res = lxc.exec_(instance1_name, ["ping", "-c1", instance2_name])
        self.assertTrue(res.exit_code == 0)
Пример #6
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)
Пример #7
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))
Пример #8
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)
Пример #9
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))