Permalink
Browse files

Rename to MiniClould. Ready for beta release

  • Loading branch information...
1 parent 110b5a0 commit f3c4661d82267353438a78999cda77afb9c7d96b @ryandoyle committed Sep 16, 2011
View
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+@options = Hash.new
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-add-key -n NAME -p PUBKEY"
+ opts.separator "Add a public SSH key to the minicloud keystore"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on("-n", "--name KEYNAME", "Name assigned to the public key") do |k|
+ @options[:keyname] = k
+ end
+ opts.on("-p", "--public-key PUBKEY", "The full public key string") do |k|
+ @options[:pub] = k
+ end
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+ opts.separator ""
+ opts.separator "Example:"
+ opts.separator ""
+ opts.separator "$ mcc-add-key --name my-key --public-key \"ssh-rsa AAAAB3NzaC1yc2.....aQ== me@exmaple.com\""
+end
+
+# Parse and check the required arguments
+begin
+ opts.parse!
+ raise OptionParser::MissingArgument if @options[:keyname].nil?
+ raise OptionParser::MissingArgument if @options[:pub].nil?
+rescue OptionParser::InvalidOption, OptionParser::MissingArgument
+ puts $!.to_s
+ puts ""
+ puts opts
+ exit 1
+end
+
+key = MCC::Keystore.new.add_key(@options[:keyname], @options[:pub])
View
@@ -0,0 +1,57 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+@options = Hash.new
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-destroy-instance -i INSTANCE"
+ opts.separator "Destroy a mcc instance"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.separator ""
+ opts.on("-i", "--instance ID", "The instance ID") do |a|
+ @options[:id] = a
+ end
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+ opts.separator ""
+ opts.separator "Example:"
+ opts.separator ""
+ opts.separator "$ mcc-destroy-instance -i 500"
+end
+
+
+# Parse and check the required arguments
+begin
+ opts.parse!
+ raise OptionParser::MissingArgument if @options[:id].nil?
+rescue OptionParser::InvalidOption, OptionParser::MissingArgument
+ puts $!.to_s
+ puts ""
+ puts opts
+ exit 1
+end
+
+if ENV['MCC_SERVER'].nil?
+ puts "MCC_SERVER environment variable is not defined."
+ exit 1
+end
+
+begin
+ mcc = MCC::Client.new(ENV['MCC_SERVER']).destroy_instance(@options[:id])
+rescue XMLRPC::FaultException # Can't get the exact exception, probably an invalid ID
+ puts "Instance ID " + @options[:id] + " not found"
+end
+
+
+
+
View
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+
+@options = Hash.new
+
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-destroy-key -n KEYNAME"
+ opts.separator "Removes an SSH key stored in a MiniCloud keystore"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on("-n", "--name KEYNAME", "Name of the public key") do |k|
+ @options[:keyname] = k
+ end
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+ opts.separator ""
+ opts.separator "Example:"
+ opts.separator ""
+ opts.separator "$ mcc-destroy-key -n my-key"
+ opts.separator ""
+ opts.separator "Notes:"
+ opts.separator ""
+ opts.separator "- This does not alter any keys in ~/.ssh. MiniCloud stores it's own copy of"
+ opts.separator " keys in ~/.mcc/keys. Destroying keys will only alter ~/.mcc/keys"
+end
+
+# Parse and check the required arguments
+begin
+ opts.parse!
+ raise OptionParser::MissingArgument if @options[:keyname].nil?
+rescue OptionParser::InvalidOption, OptionParser::MissingArgument
+ puts $!.to_s
+ puts ""
+ puts opts
+ exit 1
+end
+
+begin
+ key = MCC::Keystore.new.del_key(@options[:keyname])
+rescue => e
+ puts e.message
+end
+
View
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+
+@options = Hash.new
+
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-list-images"
+ opts.separator "List MiniCloud images"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+end
+opts.parse!
+
+if ENV['MCC_SERVER'].nil?
+ puts "MCC_SERVER environment variable is not defined."
+ exit 1
+end
+
+
+mcc = MCC::Client.new(ENV['MCC_SERVER'])
+
+image = mcc.get_images
+
+
+# Print out a heading and the images
+image.each do |img|
+ puts "IMAGE \t" + img
+end
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+
+@options = Hash.new
+
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-list-instance-types"
+ opts.separator "List MiniCloud instance types"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+end
+
+begin
+ opts.parse!
+rescue OptionParser::InvalidOption, OptionParser::MissingArgument
+ puts $!.to_s
+ puts ""
+ puts opts
+ exit 1
+end
+
+if ENV['MCC_SERVER'].nil?
+ puts "MCC_SERVER environment variable is not defined."
+ exit 1
+end
+
+
+# Do the call
+mcc = MCC::Client.new(ENV['MCC_SERVER'])
+types = mcc.get_instance_types
+
+# Print out a heading and the images
+types.each do |type|
+ puts "INST_TYPE\t" + type
+end
View
@@ -0,0 +1,69 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+
+@options = Hash.new
+
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-list-instances [OPTIONS]"
+ opts.separator "List MiniCloud instances"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.separator ""
+ opts.on("-a", "--all", "Shows running and stopped instances") do
+ @options[:all] = true
+ end
+ opts.on("-i", "--instance ID", "Only show a specific instance ID") do |a|
+ @options[:instance] = a
+ end
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+end
+
+begin
+ opts.parse!
+rescue OptionParser::InvalidOption, OptionParser::MissingArgument
+ puts $!.to_s
+ puts ""
+ puts opts
+ exit 1
+end
+
+if ENV['MCC_SERVER'].nil?
+ puts "MCC_SERVER environment variable is not defined."
+ exit 1
+end
+
+
+mcc = MCC::Client.new(ENV['MCC_SERVER'])
+
+
+if @options[:instance]
+ instances = mcc.get_instances(:instance => @options[:instance])
+elsif @options[:all]
+ instances = mcc.get_instances(:all => true)
+else
+ instances = mcc.get_instances
+end
+
+# Print out a heading and the instances
+puts "\t\tID\tIP\t\tSTATUS\t\tTEMPLATE"
+instances.each do |inst|
+ # Fix the formatting for stopped instances
+ if inst['ip'].eql?('-')
+ puts "INSTANCE\t" + inst['id'] + "\t" + inst['ip'] + "\t\t" + inst['status'] + "\t\t" + inst['ostemplate']
+ else
+ puts "INSTANCE\t" + inst['id'] + "\t" + inst['ip'] + "\t" + inst['status'] + "\t\t" + inst['ostemplate']
+ end
+end
+
View
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require File.expand_path(
+ File.join(
+ File.dirname(File.expand_path(
+ File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
+ )),
+ '../lib/mcc'
+ )
+)
+
+
+@options = Hash.new
+
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: mcc-list-keys"
+ opts.separator "List SSH keys stored in a MiniCloud keystore"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on("-h", "--help", "This help screen") do
+ print opts
+ exit
+ end
+end
+
+begin
+ opts.parse!
+rescue OptionParser::InvalidOption, OptionParser::MissingArgument
+ puts $!.to_s
+ puts ""
+ puts opts
+ exit 1
+end
+
+
+key = MCC::Keystore.new.get_keys
+
+# Print out a heading and the images
+
+key.each do |k|
+ puts "KEY\t" + k
+end
Oops, something went wrong.

0 comments on commit f3c4661

Please sign in to comment.