[libvirt] [test-API][PATCH 0/5] Update migrate module

Current migrate module include the remote_guest_define function which has problem with transient guest created on local, it can't find persistent domain xml on local and copy to remote. This series fixes aim to solve this problem. First, remote_guest_define function in migrate is removed, then add support for define domain on remote in define module. New xml element uuid is added into xmlgenerator, and new variable static_uuid is introduced into env.cfg, this will help domain created on local and defined on remote get the same uuid. At last, all related conf files are updated. [test-API][PATCH 1/5] Remove remote_guest_define function in migrate [test-API][PATCH 2/5] Add new variable static_uuid into env.cfg [test-API][PATCH 3/5] Update add_option_value function in parser [test-API][PATCH 4/5] Add new element uuid in xmlgenerator [test-API][PATCH 5/5] Update the migration case conf file .../migration/ssh_persistent_paused_with_dst.conf | 192 ------------------- .../migration/ssh_persistent_running_with_dst.conf | 192 ------------------- cases/migration/ssh_transient_paused_with_dst.conf | 200 -------------------- .../migration/ssh_transient_running_with_dst.conf | 198 ------------------- .../migration/tcp_persistent_paused_with_dst.conf | 192 ------------------- .../migration/tcp_persistent_running_with_dst.conf | 192 ------------------- .../tcp_sasl_persistent_paused_with_dst.conf | 64 ------- .../tcp_sasl_persistent_running_with_dst.conf | 64 ------- .../tcp_sasl_transient_paused_with_dst.conf | 64 ------- .../tcp_sasl_transient_running_with_dst.conf | 64 ------- cases/migration/tcp_transient_paused_with_dst.conf | 200 -------------------- .../migration/tcp_transient_running_with_dst.conf | 198 ------------------- .../migration/tls_persistent_paused_with_dst.conf | 192 ------------------- .../migration/tls_persistent_running_with_dst.conf | 192 ------------------- .../tls_sasl_persistent_paused_with_dst.conf | 64 ------- .../tls_sasl_persistent_running_with_dst.conf | 64 ------- .../tls_sasl_transient_paused_with_dst.conf | 64 ------- .../tls_sasl_transient_running_with_dst.conf | 64 ------- cases/migration/tls_transient_paused_with_dst.conf | 200 -------------------- .../migration/tls_transient_running_with_dst.conf | 198 ------------------- env.cfg | 3 - parser.py | 12 +- repos/domain/migrate.py | 31 +++- utils/Python/xmlgenerator.py | 7 - 24 files changed, 33 insertions(+), 2878 deletions(-)

* this function will fail when domain is created on local, no persistent config xml generated, so can't be copied and used on dst for define domain --- repos/domain/migrate.py | 31 +++++-------------------------- 1 files changed, 5 insertions(+), 26 deletions(-) diff --git a/repos/domain/migrate.py b/repos/domain/migrate.py index 6b86188..5414c32 100644 --- a/repos/domain/migrate.py +++ b/repos/domain/migrate.py @@ -64,7 +64,6 @@ from exception import LibvirtAPI SSH_KEYGEN = "ssh-keygen -t rsa" SSH_COPY_ID = "ssh-copy-id" -GUEST_XML = "/etc/libvirt/qemu/%s.xml" def exec_command(logger, command, flag): """execute shell command @@ -167,28 +166,6 @@ def ssh_tunnel(hostname, username, password, logger): return 0 -def remote_guest_define(target_machine, username, guestname, logger): - """copy guest xml description to target machine and define it""" - xml_file = GUEST_XML % guestname - - if not os.path.exists(xml_file): - logger.error("guest %s xml file doesn't exsits" % guestname) - return 1 - - SCP_CMD = "scp %s %s@%s:/tmp" %(xml_file, username, target_machine) - status, ret = exec_command(logger, SCP_CMD, 0) - if status: - logger.error("copy guest file failed") - return 1 - - VIRSH_DEFINE = "ssh %s \"virsh define /tmp/%s.xml\"" % (target_machine, guestname) - status, ret = exec_command(logger, VIRSH_DEFINE, 0) - if status: - logger.error("faied to define guest on target machine") - return 1 - - return 0 - def migrate(params): """ migrate a guest back and forth between two machines""" logger = params['logger'] @@ -258,12 +235,14 @@ def migrate(params): dstdom = DomainAPI(dst) if predstconfig == "true": - ret = remote_guest_define(target_machine, username, guestname, logger) - if ret: + guest_names = dstdom.get_defined_list() + if guestname in guest_names: + logger.info("Dst VM exists") + else: + logger.error("Dst VM missing config, should define VM on Dst first") env_clean(src, dst, srcdom, dstdom, target_machine, guestname, logger) return 1 - try: if(migflags & VIR_MIGRATE_PEER2PEER): logger.info("use migrate_to_uri() API to migrate") -- 1.7.1

On 10/13/2011 07:30 PM, Wayne Sun wrote:
* this function will fail when domain is created on local, no persistent config xml generated, so can't be copied and used on dst for define domain --- repos/domain/migrate.py | 31 +++++-------------------------- 1 files changed, 5 insertions(+), 26 deletions(-)
diff --git a/repos/domain/migrate.py b/repos/domain/migrate.py index 6b86188..5414c32 100644 --- a/repos/domain/migrate.py +++ b/repos/domain/migrate.py @@ -64,7 +64,6 @@ from exception import LibvirtAPI
SSH_KEYGEN = "ssh-keygen -t rsa" SSH_COPY_ID = "ssh-copy-id" -GUEST_XML = "/etc/libvirt/qemu/%s.xml"
def exec_command(logger, command, flag): """execute shell command @@ -167,28 +166,6 @@ def ssh_tunnel(hostname, username, password, logger):
return 0
-def remote_guest_define(target_machine, username, guestname, logger): - """copy guest xml description to target machine and define it""" - xml_file = GUEST_XML % guestname - - if not os.path.exists(xml_file): - logger.error("guest %s xml file doesn't exsits" % guestname) - return 1 - - SCP_CMD = "scp %s %s@%s:/tmp" %(xml_file, username, target_machine) - status, ret = exec_command(logger, SCP_CMD, 0) - if status: - logger.error("copy guest file failed") - return 1 - - VIRSH_DEFINE = "ssh %s \"virsh define /tmp/%s.xml\"" % (target_machine, guestname) - status, ret = exec_command(logger, VIRSH_DEFINE, 0) - if status: - logger.error("faied to define guest on target machine") - return 1 - - return 0 - def migrate(params): """ migrate a guest back and forth between two machines""" logger = params['logger'] @@ -258,12 +235,14 @@ def migrate(params): dstdom = DomainAPI(dst)
if predstconfig == "true": - ret = remote_guest_define(target_machine, username, guestname, logger) - if ret: + guest_names = dstdom.get_defined_list() + if guestname in guest_names: + logger.info("Dst VM exists") + else: + logger.error("Dst VM missing config, should define VM on Dst first") env_clean(src, dst, srcdom, dstdom, target_machine, guestname, logger) return 1
- try: if(migflags& VIR_MIGRATE_PEER2PEER): logger.info("use migrate_to_uri() API to migrate")
ACK and pushed. Guannan Ren

--- env.cfg | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/env.cfg b/env.cfg index b5e404a..f0373b6 100644 --- a/env.cfg +++ b/env.cfg @@ -112,6 +112,9 @@ defaultvcpu = 1 # default the memory size(kilobytes) to use for defining or installing a guest defaultmem = 1048576 +# static uuid for define, create and installing a guest +static_uuid = 05867c1a-afeb-300e-e55e-2673391ae080 + # path to a disk image containing a preinstalled guest for testing testfullimagepath = /var/lib/libvirt/images/f14.img -- 1.7.1

On 10/13/2011 07:30 PM, Wayne Sun wrote:
--- env.cfg | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/env.cfg b/env.cfg index b5e404a..f0373b6 100644 --- a/env.cfg +++ b/env.cfg @@ -112,6 +112,9 @@ defaultvcpu = 1 # default the memory size(kilobytes) to use for defining or installing a guest defaultmem = 1048576
+# static uuid for define, create and installing a guest +static_uuid = 05867c1a-afeb-300e-e55e-2673391ae080 + # path to a disk image containing a preinstalled guest for testing testfullimagepath = /var/lib/libvirt/images/f14.img
We need to change define.py as well as other domain related testcases to use the uuid in env.cfg. It's better to add an additional option to theses testcases, such as "uuid". ACK and pushed. Guannan Ren

* Option should be added to the last dictionary in caselist. The old function will cause problem when multiple dictionaries in caselist have same testkey. --- parser.py | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/parser.py b/parser.py index 8d41776..085a1f2 100644 --- a/parser.py +++ b/parser.py @@ -125,13 +125,11 @@ class CaseFileParser(object): def add_option_value(self, caselist, casename, option, value): """ Add option to the data list. """ - for dictionary in caselist: - testkey = dictionary.keys()[0] - if casename == testkey: - if not dictionary[testkey].has_key(option): - dictionary[testkey][option] = value - else: - continue + dictionary = caselist[-1] + testkey = dictionary.keys()[0] + if casename == testkey: + if not dictionary[testkey].has_key(option): + dictionary[testkey][option] = value def debug_print(self, str1, str2=""): """Nicely print two strings and an arrow. For internal use.""" -- 1.7.1

* Option should be added to the last dictionary in caselist. The old function will cause problem when multiple dictionaries in caselist have same testkey. --- parser.py | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/parser.py b/parser.py index 8d41776..085a1f2 100644 --- a/parser.py +++ b/parser.py @@ -125,13 +125,11 @@ class CaseFileParser(object):
def add_option_value(self, caselist, casename, option, value): """ Add option to the data list. """ - for dictionary in caselist: - testkey = dictionary.keys()[0] - if casename == testkey: - if not dictionary[testkey].has_key(option): - dictionary[testkey][option] = value - else: - continue + dictionary = caselist[-1] + testkey = dictionary.keys()[0] + if casename == testkey: + if not dictionary[testkey].has_key(option): + dictionary[testkey][option] = value
def debug_print(self, str1, str2=""): """Nicely print two strings and an arrow. For internal use.""" This patch aims to modify the last testcase instead of all of the
On 10/13/2011 07:30 PM, Wayne Sun wrote: previous. It solved the parsing bug which two or more testcases with the same name but different options caused. ACK and pushed. Guannan Ren

* uuid xml element will be created and append to domain xml only if uuid option in params is provided --- utils/Python/xmlgenerator.py | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/utils/Python/xmlgenerator.py b/utils/Python/xmlgenerator.py index d57dd33..4aa045a 100644 --- a/utils/Python/xmlgenerator.py +++ b/utils/Python/xmlgenerator.py @@ -45,6 +45,13 @@ def domain_xml(params, install = False): name_element.appendChild(name_node) domain_element.appendChild(name_element) + # <uuid> + if params.has_key('uuid'): + uuid_element = domain.createElement('uuid') + uuid_node = domain.createTextNode(params['uuid']) + uuid_element.appendChild(uuid_node) + domain_element.appendChild(uuid_element) + # <memory> memory_element = domain.createElement('memory') if params.has_key('memory'): -- 1.7.1

On 10/13/2011 07:30 PM, Wayne Sun wrote:
* uuid xml element will be created and append to domain xml only if uuid option in params is provided --- utils/Python/xmlgenerator.py | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/utils/Python/xmlgenerator.py b/utils/Python/xmlgenerator.py index d57dd33..4aa045a 100644 --- a/utils/Python/xmlgenerator.py +++ b/utils/Python/xmlgenerator.py @@ -45,6 +45,13 @@ def domain_xml(params, install = False): name_element.appendChild(name_node) domain_element.appendChild(name_element)
+ #<uuid> + if params.has_key('uuid'): + uuid_element = domain.createElement('uuid') + uuid_node = domain.createTextNode(params['uuid']) + uuid_element.appendChild(uuid_node) + domain_element.appendChild(uuid_element) + #<memory> memory_element = domain.createElement('memory') if params.has_key('memory'):
ACK and pushed Guannan Ren

For patch size consideration, only one file chage is display here --- .../migration/ssh_persistent_paused_with_dst.conf | 192 +++++++++++++++++++ .../migration/ssh_persistent_running_with_dst.conf | 192 +++++++++++++++++++ cases/migration/ssh_transient_paused_with_dst.conf | 200 ++++++++++++++++++++ .../migration/ssh_transient_running_with_dst.conf | 198 +++++++++++++++++++ .../migration/tcp_persistent_paused_with_dst.conf | 192 +++++++++++++++++++ .../migration/tcp_persistent_running_with_dst.conf | 192 +++++++++++++++++++ .../tcp_sasl_persistent_paused_with_dst.conf | 64 +++++++ .../tcp_sasl_persistent_running_with_dst.conf | 64 +++++++ .../tcp_sasl_transient_paused_with_dst.conf | 64 +++++++ .../tcp_sasl_transient_running_with_dst.conf | 64 +++++++ cases/migration/tcp_transient_paused_with_dst.conf | 200 ++++++++++++++++++++ .../migration/tcp_transient_running_with_dst.conf | 198 +++++++++++++++++++ .../migration/tls_persistent_paused_with_dst.conf | 192 +++++++++++++++++++ .../migration/tls_persistent_running_with_dst.conf | 192 +++++++++++++++++++ .../tls_sasl_persistent_paused_with_dst.conf | 64 +++++++ .../tls_sasl_persistent_running_with_dst.conf | 64 +++++++ .../tls_sasl_transient_paused_with_dst.conf | 64 +++++++ .../tls_sasl_transient_running_with_dst.conf | 64 +++++++ cases/migration/tls_transient_paused_with_dst.conf | 200 ++++++++++++++++++++ .../migration/tls_transient_running_with_dst.conf | 198 +++++++++++++++++++ 20 files changed, 2858 insertions(+), 0 deletions(-) diff --git a/cases/migration/ssh_persistent_paused_with_dst.conf b/cases/migration/ssh_persistent_paused_with_dst.conf index 67e4191..05f9277 100644 --- a/cases/migration/ssh_persistent_paused_with_dst.conf +++ b/cases/migration/ssh_persistent_paused_with_dst.conf @@ -7,6 +7,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -45,6 +61,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -83,6 +115,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -121,6 +169,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -159,6 +223,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -197,6 +277,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -235,6 +331,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -273,6 +385,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -311,6 +439,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -349,6 +493,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -387,6 +547,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname @@ -425,6 +601,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password domain:start guestname

On 10/13/2011 07:30 PM, Wayne Sun wrote:
For patch size consideration, only one file chage is display here --- .../migration/ssh_persistent_paused_with_dst.conf | 192 +++++++++++++++++++ .../migration/ssh_persistent_running_with_dst.conf | 192 +++++++++++++++++++ cases/migration/ssh_transient_paused_with_dst.conf | 200 ++++++++++++++++++++ .../migration/ssh_transient_running_with_dst.conf | 198 +++++++++++++++++++ .../migration/tcp_persistent_paused_with_dst.conf | 192 +++++++++++++++++++ .../migration/tcp_persistent_running_with_dst.conf | 192 +++++++++++++++++++ .../tcp_sasl_persistent_paused_with_dst.conf | 64 +++++++ .../tcp_sasl_persistent_running_with_dst.conf | 64 +++++++ .../tcp_sasl_transient_paused_with_dst.conf | 64 +++++++ .../tcp_sasl_transient_running_with_dst.conf | 64 +++++++ cases/migration/tcp_transient_paused_with_dst.conf | 200 ++++++++++++++++++++ .../migration/tcp_transient_running_with_dst.conf | 198 +++++++++++++++++++ .../migration/tls_persistent_paused_with_dst.conf | 192 +++++++++++++++++++ .../migration/tls_persistent_running_with_dst.conf | 192 +++++++++++++++++++ .../tls_sasl_persistent_paused_with_dst.conf | 64 +++++++ .../tls_sasl_persistent_running_with_dst.conf | 64 +++++++ .../tls_sasl_transient_paused_with_dst.conf | 64 +++++++ .../tls_sasl_transient_running_with_dst.conf | 64 +++++++ cases/migration/tls_transient_paused_with_dst.conf | 200 ++++++++++++++++++++ .../migration/tls_transient_running_with_dst.conf | 198 +++++++++++++++++++ 20 files changed, 2858 insertions(+), 0 deletions(-)
diff --git a/cases/migration/ssh_persistent_paused_with_dst.conf b/cases/migration/ssh_persistent_paused_with_dst.conf index 67e4191..05f9277 100644 --- a/cases/migration/ssh_persistent_paused_with_dst.conf +++ b/cases/migration/ssh_persistent_paused_with_dst.conf @@ -7,6 +7,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -45,6 +61,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -83,6 +115,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -121,6 +169,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -159,6 +223,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -197,6 +277,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -235,6 +331,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -273,6 +385,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -311,6 +439,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -349,6 +493,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -387,6 +547,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname @@ -425,6 +601,22 @@ domain:define $defaultos guesttype $defaulthv + uuid + $static_uuid + +domain:define + guestname + $defaultos + guesttype + $defaulthv + uuid + $static_uuid + target_machine + $target_machine + username + $target_user + password + $target_password
domain:start guestname
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
ACK and pushed Guannan Ren
participants (2)
-
Guannan Ren
-
Wayne Sun