Example #1
0
def TestRapiInstanceModify(instance):
    """Test modifying instance via RAPI"""
    default_hv = qa_config.GetDefaultHypervisor()

    def _ModifyInstance(**kwargs):
        _WaitForRapiJob(_rapi_client.ModifyInstance(instance.name, **kwargs))

    _ModifyInstance(beparams={
        constants.BE_VCPUS: 3,
    })

    _ModifyInstance(beparams={
        constants.BE_VCPUS: constants.VALUE_DEFAULT,
    })

    if default_hv == constants.HT_XEN_PVM:
        _ModifyInstance(hvparams={
            constants.HV_KERNEL_ARGS: "single",
        })
        _ModifyInstance(hvparams={
            constants.HV_KERNEL_ARGS: constants.VALUE_DEFAULT,
        })
    elif default_hv == constants.HT_XEN_HVM:
        _ModifyInstance(hvparams={
            constants.HV_BOOT_ORDER: "acn",
        })
        _ModifyInstance(hvparams={
            constants.HV_BOOT_ORDER: constants.VALUE_DEFAULT,
        })
Example #2
0
def TestInstanceModify(instance):
    """gnt-instance modify"""
    default_hv = qa_config.GetDefaultHypervisor()

    # Assume /sbin/init exists on all systems
    test_kernel = "/sbin/init"
    test_initrd = test_kernel

    orig_maxmem = qa_config.get(constants.BE_MAXMEM)
    orig_minmem = qa_config.get(constants.BE_MINMEM)
    #orig_bridge = qa_config.get("bridge", "xen-br0")

    args = [
        ["-B", "%s=128" % constants.BE_MINMEM],
        ["-B", "%s=128" % constants.BE_MAXMEM],
        [
            "-B",
            "%s=%s,%s=%s" % (constants.BE_MINMEM, orig_minmem,
                             constants.BE_MAXMEM, orig_maxmem)
        ],
        ["-B", "%s=2" % constants.BE_VCPUS],
        ["-B", "%s=1" % constants.BE_VCPUS],
        ["-B", "%s=%s" % (constants.BE_VCPUS, constants.VALUE_DEFAULT)],
        ["-B",
         "%s=%s" % (constants.BE_ALWAYS_FAILOVER, constants.VALUE_TRUE)],
        [
            "-B",
            "%s=%s" % (constants.BE_ALWAYS_FAILOVER, constants.VALUE_DEFAULT)
        ],
        ["-H", "%s=%s" % (constants.HV_KERNEL_PATH, test_kernel)],
        ["-H",
         "%s=%s" % (constants.HV_KERNEL_PATH, constants.VALUE_DEFAULT)],

        # TODO: bridge tests
        #["--bridge", "xen-br1"],
        #["--bridge", orig_bridge],
    ]

    if default_hv == constants.HT_XEN_PVM:
        args.extend([
            ["-H", "%s=%s" % (constants.HV_INITRD_PATH, test_initrd)],
            ["-H", "no_%s" % (constants.HV_INITRD_PATH, )],
            [
                "-H",
                "%s=%s" % (constants.HV_INITRD_PATH, constants.VALUE_DEFAULT)
            ],
        ])
    elif default_hv == constants.HT_XEN_HVM:
        args.extend([
            ["-H", "%s=acn" % constants.HV_BOOT_ORDER],
            [
                "-H",
                "%s=%s" % (constants.HV_BOOT_ORDER, constants.VALUE_DEFAULT)
            ],
        ])
    elif default_hv == constants.HT_KVM and \
      qa_config.TestEnabled("instance-device-hotplug"):
        args.extend([
            ["--net", "-1:add", "--hotplug"],
            [
                "--net", "-1:modify,mac=aa:bb:cc:dd:ee:ff", "--hotplug",
                "--force"
            ],
            ["--net", "-1:remove", "--hotplug"],
            ["--disk", "-1:add,size=1G", "--hotplug"],
            ["--disk", "-1:remove", "--hotplug"],
        ])

    for alist in args:
        AssertCommand(["gnt-instance", "modify"] + alist + [instance.name])

    # check no-modify
    AssertCommand(["gnt-instance", "modify", instance.name], fail=True)

    # Marking offline while instance is running must fail...
    AssertCommand(["gnt-instance", "modify", "--offline", instance.name],
                  fail=True)

    # ...while making it online is ok, and should work
    AssertCommand(["gnt-instance", "modify", "--online", instance.name])