Last active
March 1, 2016 18:41
-
-
Save Vegasq/049cd3519d35a59ae892 to your computer and use it in GitHub Desktop.
Fuel devops replace disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from devops import models | |
def main(env_name, node_name, size=300, add=True): | |
# value in GB | |
size = size * 1000000000 | |
env = models.Environment.get(name=env_name) | |
node = env.get_node(name=node_name) | |
# remove all exists disks | |
vol_name = "enlarge-" + node.disk_devices[0].volume.name | |
if add != True: | |
for disk in node.disk_devices: | |
disk.delete() | |
vol = models.Volume.volume_create(name=vol_name, | |
capacity=size, | |
environment=env) | |
models.DiskDevice.node_attach_volume(node=node, volume=vol) | |
node.driver.node_destroy(node) | |
node.driver.node_undefine(node) | |
vol.define() | |
node.define() | |
os.system('virsh start %s_%s' % (env_name, node_name)) | |
if __name__ == "__main__": | |
main(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment