[PATCH aeolus-cli 1/4] added hwp list and delete cli options, hwp create command

Samridh samridh90 at gmail.com
Fri Jun 29 08:36:04 UTC 2012


---
 lib/aeolus_cli/command/config_parser.rb |   61 ++++++++++++++++++++++++++++++-
 1 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/lib/aeolus_cli/command/config_parser.rb b/lib/aeolus_cli/command/config_parser.rb
index 8c08515..cdacb57 100644
--- a/lib/aeolus_cli/command/config_parser.rb
+++ b/lib/aeolus_cli/command/config_parser.rb
@@ -18,7 +18,7 @@ require 'logger'
 module Aeolus
   module CLI
     class ConfigParser
-      COMMANDS = %w(list build push import delete status)
+      COMMANDS = %w(list build push import delete status create)
 
       attr_accessor :options, :command, :args
 
@@ -75,6 +75,7 @@ module Aeolus
         subtext += "\n    import : Imports an existing image"
         subtext += "\n    delete : Delete an Aeolus Image Resource"
         subtext += "\n    status : Check the status of a push or build"
+        subtext += "\n    create : Create a specific resource"
         subtext += "\nSee `aeolus-image <command> -h` for more information on each command"
 
         general = OptionParser.new do |opts|
@@ -94,6 +95,9 @@ module Aeolus
           opts.on('-i', '--images', @value, 'Retrieve a list of images') do
             @options[:subcommand] = :images
           end
+          opts.on('-H', '--hwps', 'Retrieve a list of front-end hardware profiles') do
+            @options[:subcommand] = :hardwareProfiles
+          end
           opts.on('-E', '--environment ENVIRONMENT', @value, 'Limit image list to environment') do |environment|
             @options[:environment] =  environment
           end
@@ -126,6 +130,7 @@ module Aeolus
           opts.separator ""
           opts.separator "Examples:"
           opts.separator "aeolus-image list --images                     # list available images"
+          opts.separator "aeolus-image list --hwps                       # list available hardware profiles"
           opts.separator "aeolus-image list --images --environment $env   # list available images for an environment"
           opts.separator "aeolus-image list --builds $image_id           # list the builds of an image"
           opts.separator "aeolus-image list --targetimages $build_id     # list the target images from a build"
@@ -272,6 +277,11 @@ module Aeolus
             @options[:subcommand] = :provider_image
             @options[:providerimage] = id
           end
+          opts.on('-H', '--hwp ID', Integer, 'delete front-end hardware profile') do |id|
+            @options[:subcommand] = :hardware_profile
+            @options[:hwp] = id
+          end
+          
           opts.on( '-h', '--help', 'Get usage information for this command')
 
           opts.separator ""
@@ -284,7 +294,46 @@ module Aeolus
           opts.separator "N.B. Aeolus Credentials should be defined in the configuration file ~/.aeolus-cli"
         end
       end
+      
+      def createOptions
+        @options[:memory] = nil
+        @options[:storage] = nil
+        @options[:cpu] = nil
+        @options[:arch] = nil
+        
+        OptionParser.new do |opts|
+          opts.banner = "Usage: aeolus-image create [command options]"
+          opts.separator ""
+          opts.separator "Options:"
+          opts.on('-H', '--hwp', 'Create a front-end hardware profile') do
+            @options[:subcommand] = :hardwareProfile
+          end
+          opts.on('-n', '--name NAME', 'name for hardware profile') do |name|
+            @options[:name] = name
+          end
+          opts.on('-m', '--memory [VALUE]', 'minimum memory value in MB for hardware profile') do |value|
+            @options[:memory] = value
+          end
+          opts.on('-s', '--storage [VALUE]', 'minimum storage value in GB for hardware profile') do |value|
+            @options[:storage] = value
+          end
+          opts.on('-c', '--cpu [VALUE]', 'minimum cpu count for hardware profile') do |value|
+            @options[:cpu] = value
+          end
+          opts.on('-a', '--arch [VALUE]', 'architecture label for hardware profile') do |value|
+            @options[:arch] = value
+          end
+          opts.on( '-h', '--help', 'Get usage information for this command')
 
+          opts.separator ""
+          opts.separator "Examples:"
+          opts.separator "aeolus-image create --hwp --name $hwp_name --memory $memory_value --cpu $cpu_count --arch $arch_label"
+          opts.separator "aeolus-image create --hwp --name $hwp_name --memory $memory_value --cpu $cpu_count --storage $storge_value --arch $arch_label"
+          opts.separator ""
+          opts.separator "N.B. Aeolus Credentials should be defined in the configuration file ~/.aeolus-cli"
+        end
+      end
+      
       def list
         # TODO: Instantiate and call object matching command type, for example:
         # l = ListCommand.new(@options)
@@ -332,6 +381,16 @@ module Aeolus
         status_command = StatusCommand.new(@options)
         status_command.run
       end
+      
+      def create
+        if @options[:subcommand].nil?
+          puts "Could not find subcommand fore create, run `./aeolus-image create --help` for usage instructions"
+          exit(1)
+        else        
+          create_command = CreateCommand.new(@options)
+          create_command.send(@options[:subcommand])
+        end
+      end
     end
   end
 end
-- 
1.7.7.6




More information about the aeolus-devel mailing list