コード例 #1
0
ファイル: storage.py プロジェクト: abelboldu/kahuna
 def create_volume(self, vdc, tier, name, size):
     """ Creates a new volume in the given virtual datacenter """
     log.info("Creating volume %s of %s MB..." % (name, size))
     volume = Volume.builder(self.__context, vdc, tier) \
              .name(name) \
              .sizeInMb(size) \
              .build()
     volume.save()
     return volume
コード例 #2
0
 def create_volume(self, vdc, tier, name, size):
     """ Creates a new volume in the given virtual datacenter """
     log.info("Creating volume %s of %s MB..." % (name, size))
     volume = Volume.builder(self.__context, vdc, tier) \
              .name(name) \
              .sizeInMb(size) \
              .build()
     volume.save()
     return volume
コード例 #3
0
    def create(self, args):
        """ Create a volume in a given tier """
        parser = OptionParser(usage="volume create <options>")
        parser.add_option("-n",
                          "--name",
                          dest="name",
                          help="The name of the volume to create")
        parser.add_option(
            "-v",
            "--vdc-id",
            dest="vdc",
            type="int",
            help="The id of the virtual datacenter where the volume"
            "will be created")
        parser.add_option("-s",
                          "--size",
                          dest="size",
                          type="int",
                          help=("The size in MB of the volume to create"))
        parser.add_option("-t",
                          "--tier-id",
                          dest="tier",
                          type="int",
                          help=("The id of the tier where the volume "
                                "should be created"))
        (options, args) = parser.parse_args(args)
        if not options.name or not options.vdc \
            or not options.size or not options.tier:
            parser.print_help()
            return

        try:
            api_context = self._context.getApiContext()
            cloud = self._context.getCloudService()
            vdc = cloud.getVirtualDatacenter(options.vdc)
            if not vdc:
                print "Virtual datacenter %s does not exist" % options.vdc
                return
            tier = vdc.getStorageTier(options.tier)
            if not tier:
                print "Tier %s does not exist in the virtual datacenter" \
                    % options.tier
                return

            volume = Volume.builder(api_context, vdc, tier) \
                .name(options.name) \
                .sizeInMb(options.size) \
                .build()
            volume.save()

            pprint_volumes([volume])
        except (AbiquoException, AuthorizationException), ex:
            print "Error: %s" % ex.getMessage()
コード例 #4
0
ファイル: volume.py プロジェクト: nacx/kahuna
    def create(self, args):
        """ Create a volume in a given tier """
        parser = OptionParser(usage="volume create <options>")
        parser.add_option("-n", "--name", dest="name",
                help="The name of the volume to create")
        parser.add_option("-v", "--vdc-id", dest="vdc", type="int",
                help="The id of the virtual datacenter where the volume"
                "will be created")
        parser.add_option("-s", "--size", dest="size", type="int",
                help=("The size in MB of the volume to create"))
        parser.add_option("-t", "--tier-id", dest="tier", type="int",
                help=("The id of the tier where the volume "
                "should be created"))
        (options, args) = parser.parse_args(args)
        if not options.name or not options.vdc \
            or not options.size or not options.tier:
            parser.print_help()
            return

        try:
            api_context = self._context.getApiContext()
            cloud = self._context.getCloudService()
            vdc = cloud.getVirtualDatacenter(options.vdc)
            if not vdc:
                print "Virtual datacenter %s does not exist" % options.vdc
                return
            tier = vdc.getStorageTier(options.tier)
            if not tier:
                print "Tier %s does not exist in the virtual datacenter" \
                    % options.tier
                return

            volume = Volume.builder(api_context, vdc, tier) \
                .name(options.name) \
                .sizeInMb(options.size) \
                .build()
            volume.save()

            pprint_volumes([volume])
        except (AbiquoException, AuthorizationException), ex:
            print "Error: %s" % ex.getMessage()