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 cancel_command(self, signum, frame): raise exception.CancelledCreateVolume()