def execute(self, args): if len(args) != 2: self.parser.error( "you must specify a volume id and a size (in GB)") volid, size = args size = self._get_size_arg(size) vol = self.ec2.get_volume(volid) zone = vol.zone if self.opts.dest_zone: zone = self.ec2.get_zone(self.opts.dest_zone).name key = self.opts.keypair host_instance = None if self.opts.host_instance: host_instance = self.ec2.get_instance(self.opts.host_instance) key = host_instance.key_name keypair, key_location = self._load_keypair(key) if host_instance: host_instance = node.Node(host_instance, key_location, alias="volumecreator_host") kwargs = self.specified_options_dict kwargs.update(dict(keypair=keypair, key_location=key_location, host_instance=host_instance)) vc = volume.VolumeCreator(self.ec2, **kwargs) if host_instance: vc._validate_host_instance(host_instance, zone) try: new_volid = vc.resize(vol, size, dest_zone=self.opts.dest_zone) if new_volid: self.log.info("Volume %s was successfully resized to %sGB" % (volid, size)) self.log.info("New volume id is: %s" % new_volid) else: self.log.error("failed to resize volume %s" % volid) except KeyboardInterrupt: self.cancel_command()
def execute(self, args): if len(args) != 2: self.parser.error( "you must specify a size (in GB) and an availability zone") size, zone = args size = self._get_size_arg(size) zone = self.ec2.get_zone(zone).name key = self.opts.keypair host_instance = None if self.opts.host_instance: host_instance = self.ec2.get_instance(self.opts.host_instance) key = host_instance.key_name keypair, key_location = self._load_keypair(key) if host_instance: host_instance = node.Node(host_instance, key_location, alias="volumecreator_host") kwargs = self.specified_options_dict kwargs.update(dict(keypair=keypair, key_location=key_location, host_instance=host_instance)) vc = volume.VolumeCreator(self.ec2, **kwargs) if host_instance: vc._validate_host_instance(host_instance, zone) try: vc.create(size, zone, name=self.opts.name, tags=self.opts.tags) except KeyboardInterrupt: raise exception.CancelledCreateVolume()
def execute(self, args): if len(args) != 2: self.parser.error( "you must specify a size (in GB) and an availability zone") size, zone = args size = self._get_size_arg(size) zone = self.ec2.get_zone(zone).name key = self.opts.keypair host_instance = None if self.opts.host_instance: host_instance = self.ec2.get_instance(self.opts.host_instance) key = host_instance.key_name keypair, key_location = self._load_keypair(key) if host_instance: host_instance = node.Node(host_instance, key_location, alias="volumecreator_host") kwargs = self.specified_options_dict kwargs.update( dict(keypair=keypair, key_location=key_location, host_instance=host_instance)) vc = volume.VolumeCreator(self.ec2, **kwargs) if host_instance: vc._validate_host_instance(host_instance, zone) self.catch_ctrl_c() volid = vc.create(size, zone) if volid: self.log.info( "Your new %sGB volume %s has been created successfully" % \ (size, volid)) else: self.log.error("failed to create new volume")