From ee3b89edb1f26de87f7e271c03a24a3461f794c4 Mon Sep 17 00:00:00 2001 From: Dmitry Tyzhnenko Date: Thu, 25 Jun 2015 15:42:52 +0300 Subject: [PATCH] Don't change undisclosed param on slave-change If use only one of --vcpu or --ram param in slave-change command, other param won't use default value and won't change VM Change-Id: Ie1e37d1083a1f860d1b03d8c75af3500201c2f67 Closes-bug: #1464649 --- devops/models/node.py | 4 ++-- devops/shell.py | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/devops/models/node.py b/devops/models/node.py index 755ba3e8..63620168 100644 --- a/devops/models/node.py +++ b/devops/models/node.py @@ -164,7 +164,7 @@ def set_vcpu(self, vcpu): param: vcpu: Integer :rtype : None """ - if vcpu != self.vcpu: + if vcpu is not None and vcpu != self.vcpu: self.vcpu = vcpu self.driver.node_set_vcpu(node=self, vcpu=vcpu) self.save() @@ -175,7 +175,7 @@ def set_memory(self, memory): param: memory: Integer :rtype : None """ - if memory != self.memory: + if memory is not None and memory != self.memory: self.memory = memory self.driver.node_set_memory(node=self, memory=memory * 1024) self.save() diff --git a/devops/shell.py b/devops/shell.py index 842a4444..53747490 100644 --- a/devops/shell.py +++ b/devops/shell.py @@ -216,8 +216,8 @@ def do_slave_change(self): def do_admin_change(self): node = self.env.get_node(name="admin") - node.set_vcpu(vcpu=self.params.vcpu_count) - node.set_memory(memory=self.params.ram_size) + node.set_vcpu(vcpu=self.params.admin_vcpu_count) + node.set_memory(memory=self.params.admin_ram_size) def do_admin_setup(self): admin_node = self.env.get_node(name='admin') @@ -327,6 +327,18 @@ def get_params(self): admin_vcpu_parser.add_argument('--admin-vcpu', dest='admin_vcpu_count', help='Select admin node VCPU count', default=2, type=int) + change_admin_ram_parser = argparse.ArgumentParser(add_help=False) + change_admin_ram_parser.add_argument('--admin-ram', + dest='admin_ram_size', + help='Select admin node RAM ' + 'size (MB)', + default=None, type=int) + change_admin_vcpu_parser = argparse.ArgumentParser(add_help=False) + change_admin_vcpu_parser.add_argument('--admin-vcpu', + dest='admin_vcpu_count', + help='Select admin node VCPU ' + 'count', + default=None, type=int) admin_disk_size_parser = argparse.ArgumentParser(add_help=False) admin_disk_size_parser.add_argument('--admin-disk-size', dest='admin_disk_size', @@ -341,6 +353,14 @@ def get_params(self): vcpu_parser.add_argument('--vcpu', dest='vcpu_count', help='Set node VCPU count', default=1, type=int) + change_ram_parser = argparse.ArgumentParser(add_help=False) + change_ram_parser.add_argument('--ram', dest='ram_size', + help='Set node RAM size', + default=None, type=int) + change_vcpu_parser = argparse.ArgumentParser(add_help=False) + change_vcpu_parser.add_argument('--vcpu', dest='vcpu_count', + help='Set node VCPU count', + default=None, type=int) node_count = argparse.ArgumentParser(add_help=False) node_count.add_argument('--node-count', dest='node_count', help='How many nodes will be created', @@ -457,7 +477,7 @@ def get_params(self): description="Add a new node to environment") subparsers.add_parser('slave-change', parents=[name_parser, node_name_parser, - ram_parser, vcpu_parser], + change_ram_parser, change_vcpu_parser], help="Change node VCPU and memory config", description="Change count of VCPUs and memory") subparsers.add_parser('slave-remove', @@ -470,8 +490,8 @@ def get_params(self): help="Setup admin node", description="Setup admin node from ISO") subparsers.add_parser('admin-change', - parents=[name_parser, admin_ram_parser, - admin_vcpu_parser], + parents=[name_parser, change_admin_ram_parser, + change_admin_vcpu_parser], help="Change admin node VCPU and memory config", description="Change count of VCPUs and memory " "for admin node")