Revision 3e7c63f8 snf-cyclades-app/synnefo/logic/management/commands/pool-modify.py

b/snf-cyclades-app/synnefo/logic/management/commands/pool-modify.py
49 49
                    help="Type of pool"
50 50
                    ),
51 51
        make_option('--offset', dest='offset'),
52
        make_option('--size', dest='size'),
52 53
        make_option('--base', dest='base'),
53 54
        make_option('--add-reserved', dest='add-reserved',
54 55
                    help="Comma-seperated list of values to reserve"),
......
90 91
        if base:
91 92
            pool_row.base = base
92 93

  
94
        # Save now, to avoid conflict with resizing pool.save()
93 95
        pool_row.save()
96

  
97
        if size:
98
            try:
99
                size = int(size)
100
            except ValueError:
101
                raise CommandError("Invalid size")
102
            pool = pool_row.get_pool()
103
            self.resize_pool(pool, pool_row.size, size)
104
            pool.save()
105

  
106
    def resize_pool(self, pool, old_size, new_size):
107
        if new_size == old_size:
108
            return
109
        elif new_size > old_size:
110
            pool.extend(new_size - old_size)
111
        else:
112
            pool.shrink(old_size - new_size)
113
        pool.save()

Also available in: Unified diff