forj 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d116642b62ded0c9f2aa26a8f3d67acf73a45d3
4
- data.tar.gz: 81d3018544a5e3a211dbaf72110815cddbd0c503
3
+ metadata.gz: b1995afd2ab24967e07aef8b4451acbff58dd367
4
+ data.tar.gz: 662ce3b7da524bf101ba45a3526ca1c04d1a336f
5
5
  SHA512:
6
- metadata.gz: e80b51b75742c2288a3351aca10d79438f94e8ce02713f14d956cadd135bfc29e9b4d8e9e90a5104ea90bb6f438c3afc4f5684989726a7cafa4cb0d47bd3d129
7
- data.tar.gz: b2e2fddb8b5dbe3410f22606eb248f43f0152b83b89c0a7a7f9643f0f385e0bdcd544e7aa8cd1f02b4fcf79617322914eb75ef1716d583ae59c799ac66c7c6e5
6
+ metadata.gz: bb8659a39b98f5aed5a0e26337428e8a96667d8f2c35482855e24b0db706492020a6d03564ded3d635d9f096a52b01e25f2d1a685bb4e824c5a93111ab464350
7
+ data.tar.gz: 60918b32d461c2ad7b5e43dda24172a036d6c22c6fef392d0ec4ce5092652d6e16bb250abc98ea038f9e8b581a0361b2112905487d43bd3c2d9784b0c455fe11
data/README.md CHANGED
@@ -8,17 +8,17 @@ Installation
8
8
 
9
9
  **Fedora/CentOS/Redhat rpm like package system**
10
10
 
11
- $ sudo yum install ruby-devel libxml2-devel libxslt-devel python-yaml -y
11
+ $ sudo yum install ruby-devel libxml2-devel libxslt-devel python-yaml gcc git -y
12
12
  $ sudo gem install forj
13
13
 
14
14
  **Ubuntu/Debian deb like package system (not tested)**
15
15
 
16
- $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev -y
16
+ $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev git -y
17
17
  $ sudo gem install forj
18
18
 
19
19
  ### For ruby 1.9
20
20
 
21
- $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev -y
21
+ $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev git -y
22
22
  $ sudo gem install forj
23
23
 
24
24
  ### For ruby 1.8
data/bin/forj CHANGED
@@ -18,6 +18,13 @@
18
18
  require 'rubygems'
19
19
  require 'require_relative'
20
20
  require 'thor'
21
+ require 'ansi'
22
+
23
+ $APP_PATH = File.dirname(__FILE__)
24
+ $LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
25
+
26
+ $FORJ_DATA_PATH= File.expand_path('~/.forj')
27
+ $LOAD_PATH << './lib'
21
28
 
22
29
  require_relative '../lib/boot.rb'
23
30
  include Boot
@@ -28,16 +35,25 @@ include Setup
28
35
  require_relative '../lib/ssh.rb'
29
36
  include Ssh
30
37
 
31
- $APP_PATH = File.dirname(__FILE__)
32
- $LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
38
+ require 'forj-config.rb' # Load class ForjConfig
39
+ require 'log.rb' # Load default loggers
40
+ require 'connection.rb' # Load class ForjConnection
33
41
 
34
- $FORJ_DATA_PATH= File.expand_path('~/.forj')
35
- $LOAD_PATH << './lib'
42
+ #require 'debugger' # Use to debug with Ruby < 2.0
43
+ #require 'byebug' # Use to debug with Ruby >= 2.0
44
+
45
+ include Logging
46
+
47
+ # Initialize global Log object
48
+ $FORJ_LOGGER=ForjLog.new()
36
49
 
37
- require 'forj-config.rb' # Load class ForjConfig
38
50
 
39
51
  class Forj < Thor
40
52
 
53
+ class_option :debug, :aliases => '-d', :desc => 'Set debug mode'
54
+ class_option :verbose, :aliases => '-v', :desc => 'Set verbose mode'
55
+ class_option :config, :aliases => '-c', :desc => 'Path to a different forj config file. By default, use ~/.forj/config.yaml'
56
+
41
57
 
42
58
  desc "help [action]", "Describe available FORJ actions or one specific action"
43
59
  def help(task = nil, subcommand = false)
@@ -84,7 +100,7 @@ The list of predefined values can be retrieved with forj show defaults
84
100
 
85
101
  LONGDESC
86
102
 
87
- method_option :config, :aliases => '-c', :desc => 'Path to a different forj config file. By default, use ~/.forj/config.yaml'
103
+ method_option :account_name, :aliases => '-a', :desc => 'Set the forj account name to use. By default, it takes the provider name.'
88
104
  method_option :infra, :aliases => '-i', :desc => 'Defines your Infra directory to use while booting. You can also set FORJ_INFRA_DIR.'
89
105
  method_option :key_name, :aliases => '-k', :desc => 'Import a key pair.'
90
106
  method_option :key_path, :aliases => '-p', :desc => 'Public key data'
@@ -92,19 +108,31 @@ The list of predefined values can be retrieved with forj show defaults
92
108
  method_option :boothook, :aliases => '-H', :desc => 'By default, boothook file used is build/bin/build-tools/boothook.sh. Use this option to set another one.'
93
109
  method_option :build, :aliases => '-B', :desc => 'Replace the default build.sh'
94
110
  method_option :build_config, :aliases => '-C', :desc => 'The build config file to load <confdir>/<BoxName>.<Config>.env. By default, uses "master" as Config.'
95
- method_option :git_repo, :aliases => '-R', :desc => 'The box built will use a different git repository sent out to <user_data>. This repository needs to be read only. No keys are sent.'
111
+ method_option :maestro_repo, :aliases => '-M', :desc => 'To use a different Maestro repository already cloned. By default, Maestro is cloned to ~/.forj/maestro from github.'
96
112
  method_option :branch, :aliases => '-B', :desc => 'The build will extract from git branch name. It sets the configuration build <config> to the branch name <branch>.'
97
113
  method_option :box_name, :aliases => '-N', :desc => 'Defines the name of the box or box image to build.'
98
114
  method_option :test_box, :aliases => '-T', :desc => 'Create test.rb-box meta from the repository path provided.'
99
115
 
100
116
  def boot(blueprint, on, cloud_provider, as, name, test = false)
101
- Boot.boot(blueprint, cloud_provider, name,
117
+ Logging.set_level(Logger::INFO) if options[:verbose]
118
+ Logging.set_level(Logger::DEBUG) if options[:debug]
119
+ oConfig=ForjConfig.new(options[:config])
120
+
121
+ Logging.fatal(1, "instance name '%s' not supported. Support only lower case, numeric and dash caracters." % [name]) if not /^[\d[[:lower:]]-]+$/ =~ name
122
+
123
+ # Options are added if they are set. Otherwise, get will retrieve the default value.
124
+ oConfig.set('account_name', options[:account_name])
125
+ oConfig.set('infra_repo', options[:infra])
126
+ oConfig.set('keypair_name', options[:key_name])
127
+ oConfig.set('keypair_path', options[:key_path])
128
+
129
+ # TODO: Be able to support the default provider from config.yaml
130
+ oConfig.set('provider', cloud_provider)
131
+ Boot.boot(blueprint, name,
102
132
  options[:build], options[:build_config_dir],
103
133
  options[:build_config], options[:branch],
104
- options[:git_repo], options[:boothook],
105
- options[:box_name], options[:key_name],
106
- options[:key_path],options[:region],
107
- options[:config], test)
134
+ options[:maestro_repo], options[:boothook],
135
+ options[:box_name], oConfig, test)
108
136
  end
109
137
 
110
138
  desc 'show defaults', 'Show list of predefined value you can update in your ~/.forj/config.yaml'
@@ -125,6 +153,8 @@ The list of predefined values can be retrieved with forj show defaults
125
153
  LONGDESC
126
154
 
127
155
  def down(name)
156
+ Logging.set_level(Logger::INFO) if options[:verbose]
157
+ Logging.set_level(Logger::DEBUG) if options[:debug]
128
158
  Down.down(name)
129
159
  end
130
160
 
@@ -137,11 +167,15 @@ Connect through ssh to an existing instance
137
167
  LONGDESC
138
168
 
139
169
  def ssh(name, server)
170
+ Logging.set_level(Logger::INFO) if options[:verbose]
171
+ Logging.set_level(Logger::DEBUG) if options[:debug]
140
172
  Ssh.connect(name, server)
141
173
  end
142
174
 
143
- # SETUP
144
- desc 'setup', 'set the credentials for forj cli'
175
+ # SETUP
176
+ method_option :account_name, :aliases => '-a', :desc => 'Set the forj account name to use. By default, it takes the provider name.'
177
+
178
+ desc 'setup [Provider] [options]', 'set the hpcloud credentials for forj cli'
145
179
  long_desc <<-LONGDESC
146
180
  Set the cloud credentials and services for forj. Currently supports only hpcloud provider.
147
181
 
@@ -152,9 +186,13 @@ Several data will be requested like:
152
186
  \x5- tenant_id: id for the tenant you want to use
153
187
  \x5- availability_zone: which availability zone will be deployed
154
188
  LONGDESC
155
- def setup
156
- Setup.setup
189
+ def setup(sProvider = 'hpcloud')
190
+ Logging.set_level(Logger::INFO) if options[:verbose]
191
+ Logging.set_level(Logger::DEBUG) if options[:debug]
192
+ oConfig=ForjConfig.new(options[:config])
193
+ Setup.setup(sProvider, oConfig, options)
157
194
  end
195
+
158
196
  end
159
197
 
160
198
 
data/lib/boot.rb CHANGED
@@ -24,8 +24,8 @@ require_relative 'security.rb'
24
24
  include SecurityGroup
25
25
  require_relative 'repositories.rb'
26
26
  include Repositories
27
- require_relative 'log.rb'
28
- include Logging
27
+ #require_relative 'log.rb'
28
+ #include Logging
29
29
  require_relative 'helpers.rb'
30
30
  include Helpers
31
31
 
@@ -34,27 +34,29 @@ include Helpers
34
34
  # Boot module
35
35
  #
36
36
  module Boot
37
- def boot(blueprint, cloud_provider, name,
37
+ def boot(blueprint, name,
38
38
  build, infra_dir, build_config,
39
- branch, git_repo, boothook, box_name,
40
- key_name, key_path, region, config,
41
- test = false)
39
+ branch, maestro_repo, boothook, box_name,
40
+ oConfig, test = false)
42
41
  begin
43
- initial_msg = 'booting %s on %s (~/.forj/forj.log)' % [blueprint , cloud_provider]
44
42
 
45
- Logging.info(initial_msg)
43
+ # Check options and set data
44
+ cloud_provider=oConfig.get('provider')
45
+ raise 'No provider specified.' if not cloud_provider
46
+
47
+ if cloud_provider != 'hpcloud'
48
+ raise "forj setup support only hpcloud. '%s' is currently not supported." % cloud_provider
49
+ end
46
50
 
47
- forj_dir = File.expand_path(File.dirname(__FILE__))
48
- Dir.chdir(forj_dir)
51
+ oConfig.setDefault('account_name', cloud_provider)
49
52
 
50
- puts ('INFO: Reading default configuration...')
51
- oConfig=ForjConfig.new(config)
52
- hConfig=oConfig.yConfig['default']
53
+ initial_msg = 'booting %s on %s (~/.forj/forj.log)' % [blueprint , cloud_provider]
54
+ Logging.message(initial_msg)
53
55
 
54
56
  # Initialize defaults
55
- maestro_url = hConfig['maestro_url']
57
+ maestro_url = oConfig.get('maestro_url')
56
58
 
57
- infra_dir = hConfig['infra_repo'] unless infra_dir
59
+ infra_dir = oConfig.get('infra_repo') unless infra_dir
58
60
 
59
61
  # Ask information if needed.
60
62
  bBuildInfra=false
@@ -62,95 +64,108 @@ module Boot
62
64
  sAsk = 'Your \'%s\' infra directory doesn\'t exist. Do you want to create a new one from Maestro(repo github)/templates/infra (yes/no)?' % [infra_dir]
63
65
  bBuildInfra=agree(sAsk)
64
66
  else
65
- puts('INFO: Re-using your infra... in \'%s\'' % [infra_dir])
67
+ Logging.info('Re-using your infra... in \'%s\'' % [infra_dir])
66
68
  end
67
69
  if not Dir.exist?(File.expand_path(infra_dir)) and not bBuildInfra
68
- puts ('Exiting.')
70
+ Logging.info ('Exiting.')
69
71
  return
70
72
  end
71
73
 
72
74
  # Step Maestro Clone
73
- puts('INFO: cloning maestro repo from \'%s\'...' % maestro_url)
74
- Repositories.clone_repo(maestro_url)
75
+ if not maestro_repo
76
+ Logging.info('cloning maestro repo from \'%s\'...' % maestro_url)
77
+ Repositories.clone_repo(maestro_url)
78
+ maestro_repo=File.expand_path('~/.forj/maestro')
79
+ else
80
+ maestro_repo=File.expand_path(maestro_repo)
81
+ if not File.exists?('%s/templates/infra/%s-maestro.box.GITBRANCH.env.tmpl' % [maestro_repo, cloud_provider])
82
+ Logging.fatal(1, "'%s' is not a recognized Maestro repository. forj cli searched for templates/infra/%s-maestro.box.GITBRANCH.env.tmpl" % [maestro_repo, cloud_provider])
83
+ end
84
+ Logging.info('Using your maestro cloned repo \'%s\'...' % maestro_repo)
85
+ end
75
86
 
76
87
  if bBuildInfra
77
- puts('INFO: Building your infra... in \'%s\'' % [infra_dir])
78
- Repositories.create_infra
88
+ Logging.info('Building your infra... in \'%s\'' % [infra_dir])
89
+ Repositories.create_infra(maestro_repo)
79
90
  end
80
91
 
81
- puts('INFO: Configuring network \'%s\'' % [hConfig['network']])
82
- network = Network.get_or_create_network(hConfig['network'])
92
+ # Connect to services
93
+ oFC=ForjConnection.new(oConfig)
94
+
95
+ Logging.info('Configuring network \'%s\'' % [oConfig.get('network')])
83
96
  begin
84
- subnet = Network.get_or_create_subnet(network.id, name)
85
- router = Network.get_router(hConfig['router'])
86
- Network.create_router_interface(subnet.id, router)
97
+ network = Network.get_or_create_network(oFC, oConfig.get('network'))
98
+ subnet = Network.get_or_create_subnet(oFC, network.id, network.name)
99
+ router = Network.get_or_create_router(oFC, network, subnet)
87
100
  rescue => e
88
- puts e.message
101
+ Logging.fatal(1, "Network properly configured is required.\n%s\n%s" % [e.message, e.backtrace.join("\n")])
89
102
  end
90
103
 
91
104
 
92
- puts('INFO: Configuring keypair \'%s\'' % [hConfig['keypair_name']])
93
- key_name = hConfig['keypair_name'] unless key_name
94
- key_path = hConfig['keypair_path'] unless key_path
105
+ Logging.info('Configuring keypair \'%s\'' % [oConfig.get('keypair_name')])
106
+ key_name = oConfig.get('keypair_name')
107
+ key_path = oConfig.get('keypair_path')
95
108
  SecurityGroup.upload_existing_key(key_name, key_path)
96
109
 
97
- puts('INFO: Configuring Security Group \'%s\'' % [hConfig['security_group']])
98
- security_group = SecurityGroup.get_or_create_security_group(hConfig['security_group'])
99
- ports = hConfig['ports']
100
-
101
- ports.each do|port|
102
- Network.get_or_create_rule(security_group.id, 'tcp', port, port)
110
+ Logging.info('Configuring Security Group \'%s\'' % [oConfig.get('security_group')])
111
+ security_group = SecurityGroup.get_or_create_security_group(oFC, oConfig.get('security_group'))
112
+ ports = oConfig.get('ports')
113
+
114
+ ports.each do |port|
115
+ port = port.to_s if port.class != String
116
+ if not /^\d+(-\d+)?$/ =~ port
117
+ Logging.error("Port '%s' is not valid. Must be <Port> or <PortMin>-<PortMax>" % [port])
118
+ else
119
+ mPortFound = /^(\d+)(-(\d+))?$/.match(port)
120
+ portmin = mPortFound[1]
121
+ portmax = (mPortFound[3]) ? (mPortFound[3]) : (portmin)
122
+ Network.get_or_create_rule(oFC, security_group.id, 'tcp', portmin, portmax)
123
+ end
103
124
  end
104
125
 
105
- ENV['FORJ_HPC_NETID'] = network.id
106
- ENV['FORJ_SECURITY_GROUP'] = security_group.name
126
+ ENV['FORJ_HPC_NET'] = network.name
127
+ ENV['FORJ_SECURITY_GROUP'] = oConfig.get('security_group')
107
128
  ENV['FORJ_KEYPAIR'] = key_name
108
- ENV['FORJ_HPC_KEYPUB'] = key_path
109
- if region
110
- ENV['FORJ_REGION'] = region
111
- end
129
+ ENV['FORJ_HPC_NOVA_KEYPUB'] = key_path
130
+ ENV['FORJ_BASE_IMG'] = oConfig.get('image')
112
131
 
113
132
  # run build.sh to boot maestro
114
133
  puts
115
- current_dir = Dir.pwd
116
- home = Helpers.get_home_path
117
- build_path = home + '/.forj/maestro/build'
118
- Dir.chdir(build_path)
119
134
 
120
135
  build = 'bin/build.sh' unless build
121
136
 
122
- build_config = hConfig['build_config'] unless build_config
137
+ build_config = oConfig.get('build_config') unless build_config
123
138
 
124
- branch = hConfig['branch'] unless branch
139
+ branch = oConfig.get('branch') unless branch
125
140
 
126
- box_name = hConfig['box_name'] unless box_name
141
+ box_name = oConfig.get('box_name') unless box_name
127
142
 
128
143
  meta = '--meta blueprint=%s ' % [blueprint]
129
144
 
130
145
  command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --debug-box %s' % [build, name, box_name, infra_dir, build_config, branch, meta]
131
146
 
132
- Logging.info('Calling build.sh')
133
- Logging.info(command)
147
+ maestro_build_path = File.expand_path('~/.forj/maestro/build')
134
148
 
135
- Kernel.system(command)
149
+ current_dir = Dir.pwd
150
+
151
+ Dir.chdir(File.expand_path('~/.forj/maestro/build'))
152
+
153
+ Logging.info("Calling '%s' from '%s'" % [build, Dir.pwd])
154
+ Logging.debug(command)
155
+ Kernel.system(ENV, command)
136
156
  Dir.chdir(current_dir)
137
157
 
138
158
  if test
139
- puts 'test flag is on, deleting objects'
159
+ Logging.debug 'test flag is on, deleting objects'
140
160
  Network.delete_router_interface(subnet.id, router)
141
161
  Network.delete_subnet(subnet.id)
142
162
  Network.delete_network(network.name)
143
163
  end
144
164
 
145
- rescue SystemExit, Interrupt
146
- msg = '%s interrupted by user' % [name]
147
- puts msg
148
- Logging.info(msg)
149
- rescue StandardError => e
150
- Logging.error(e.message)
151
- puts e.backtrace.join("\n")
152
-
153
- puts e.message
165
+ rescue Interrupt
166
+ Logging.message("\n'%s' boot from '%s' interrupted by user" % [name, blueprint])
167
+ rescue => e
168
+ Logging.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
154
169
  end
155
170
  end
156
171
  end
data/lib/compute.rb CHANGED
@@ -18,21 +18,16 @@
18
18
  require 'rubygems'
19
19
  require 'require_relative'
20
20
 
21
- require_relative 'connection.rb'
22
- include Connection
23
- require_relative 'log.rb'
24
- include Logging
25
-
26
21
  #
27
22
  # compute module
28
23
  #
29
24
  module Compute
30
- def delete_forge(name)
31
- instances = Connection.compute.servers.all(:name => name)
25
+ def delete_forge(oFC, name)
26
+ instances = oFC.oCompute.servers.all(:name => name)
32
27
  instances.each do|instance|
33
28
  # make sure we don't delete another forge because fog filters
34
29
  # the name in a "like syntax" way
35
- Connection.compute.servers.get(instance.id).destroy
30
+ oFC.oCompute.servers.get(instance.id).destroy
36
31
  end
37
32
  end
38
- end
33
+ end
data/lib/connection.rb CHANGED
@@ -25,43 +25,72 @@ include YamlParse
25
25
  #
26
26
  # Connection module
27
27
  #
28
- module Connection
29
- def compute
30
- begin
31
- credentials = get_credentials
32
- Fog::Compute.new({
33
- :provider => 'HP',
34
- :hp_access_key => credentials['access_key'],
35
- :hp_secret_key => credentials['secret_key'],
36
- :hp_auth_uri => credentials['auth_uri'],
37
- :hp_tenant_id => credentials['tenant_id'],
38
- :hp_avl_zone => credentials['availability_zone'],
28
+
29
+ class ForjConnection
30
+
31
+ attr_accessor :oCompute
32
+ attr_accessor :oNetwork
33
+
34
+ def initialize(oConfig)
35
+
36
+ sAccountName = oConfig.get('account_name')
37
+ @provider='HP' # TODO: Support multiple provider. (Generic Provider object required)
38
+ sAccountName = oConfig.get('provider') if not sAccountName
39
+ sAccountName = 'hpcloud' if not sAccountName
40
+
41
+ @credentials = get_credentials(sAccountName)
42
+ oSSLError=SSLErrorMgt.new
43
+
44
+ # Trying to get Compute object
45
+
46
+ Logging.debug("compute: Connecting to '%s' - Project '%s'" % [@provider, @credentials['tenant_id']])
47
+ begin
48
+ @oCompute=Fog::Compute.new({
49
+ :provider => @provider,
50
+ :hp_access_key => @credentials['access_key'],
51
+ :hp_secret_key => @credentials['secret_key'],
52
+ :hp_auth_uri => @credentials['auth_uri'],
53
+ :hp_tenant_id => @credentials['tenant_id'],
54
+ :hp_avl_zone => @credentials['availability_zone'],
39
55
  :version => 'v2'
40
- })
41
- rescue => e
42
- Logging.error(e.message)
43
- end
44
- end
56
+ })
57
+ rescue => e
58
+ if not oSSLError.ErrorDetected(e.message,e.backtrace)
59
+ retry
60
+ end
61
+ Logging.fatal(1, 'Unable to connect.')
62
+ end
63
+
64
+ # Trying to get Network object
65
+ Logging.debug("HP network: Connecting to '%s' - Project '%s'" % [@provider, @credentials['tenant_id']])
66
+ begin
67
+ @oNetwork=Fog::HP::Network.new({
68
+ :hp_access_key => @credentials['access_key'],
69
+ :hp_secret_key => @credentials['secret_key'],
70
+ :hp_auth_uri => @credentials['auth_uri'],
71
+ :hp_tenant_id => @credentials['tenant_id'],
72
+ :hp_avl_zone => @credentials['availability_zone']
73
+ })
74
+ rescue => e
75
+ if not oSSLError.ErrorDetected(e.message,e.backtrace)
76
+ retry
77
+ end
78
+ Logging.fatal(1, 'Unable to connect.')
79
+ end
80
+
81
+ end
45
82
 
46
- def network
47
- begin
48
- credentials = get_credentials
49
- Fog::HP::Network.new({
50
- :hp_access_key => credentials['access_key'],
51
- :hp_secret_key => credentials['secret_key'],
52
- :hp_auth_uri => credentials['auth_uri'],
53
- :hp_tenant_id => credentials['tenant_id'],
54
- :hp_avl_zone => credentials['availability_zone']
55
- })
56
- rescue => e
57
- Logging.error(e.message)
58
- end
59
- end
60
83
  end
61
84
 
62
- def get_credentials
63
- home = File.expand_path('~')
64
- creds = '%s/.hpcloud/accounts/hp' % [home]
85
+ def get_credentials(sAccountName)
86
+ # TODO: Should support forj credentials. not hpcloud credentials.
87
+
88
+ raise 'Internal Error: Missing sAccountName' if not sAccountName
89
+
90
+ creds = File.expand_path('~/.hpcloud/accounts/%s' % [sAccountName])
91
+ if not File.exists?(creds)
92
+ Logging.fatal(1, "'%s' was not configured. Did you executed 'forj setup %s'? Please do it and retry." % [sAccountName, sAccountName])
93
+ end
65
94
  template = YAML.load_file(creds)
66
95
  credentials = Hash.new
67
96
 
@@ -72,8 +101,8 @@ def get_credentials
72
101
  credentials['tenant_id'] = template[:credentials][:tenant_id]
73
102
  credentials['availability_zone'] = template[:regions][:compute]
74
103
  rescue => e
104
+ Logging.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
75
105
  puts 'your credentials are not configured, delete the file %s and run forj setup again' % [creds]
76
- Logging.error(e.message)
77
106
  end
78
107
  credentials
79
108
  end
data/lib/defaults.yaml CHANGED
@@ -15,14 +15,15 @@
15
15
  default:
16
16
  maestro_url: https://github.com/forj-oss/maestro.git
17
17
  infra_repo: ~/.forj/infra
18
- image: proto2b
18
+ # You can set proto2b in your ~/.forj/config.yaml if you built it from maestro/build. Read the maestro/README.md to create it.
19
+ image: Ubuntu Precise 12.04.4 LTS Server 64-bit 20140414 (Rescue Image)
19
20
  flavor: standard.xsmall
20
- ports: [22, 80, 443, 3131, 3000, 3132, 3133, 3134, 3135, 4505, 4506, 5000, 5666, 8000, 8080, 8081, 8083, 8125, 8139, 8140, 8773, 8774, 8776, 9292, 29418, 35357]
21
+ ports: [22, 80, 443, 3000, 3131, 3132, 3233, 3134, 3135, 4505-4506, 5000, 5666, 8000, 8080-8081, 8083, 8125, 8139-8140, 8773-8776, 9292, 29418, 35357]
21
22
  keypair_path: ~/.hpcloud/keypairs/nova
22
23
  keypair_name: nova
23
- router: private-ext
24
- security_group: default
25
- network: private
24
+ # Network: If network doesn't exist, forj cli will try to create it, and attach it a router.
25
+ network: forj
26
+ security_group: forj
26
27
  # at this point you have to clone the infra project manually
27
28
  build_config: box
28
29
  branch: master
data/lib/down.rb CHANGED
@@ -24,8 +24,8 @@ require_relative 'yaml_parse.rb'
24
24
  include YamlParse
25
25
  require_relative 'security.rb'
26
26
  include SecurityGroup
27
- require_relative 'log.rb'
28
- include Logging
27
+ #require_relative 'log.rb'
28
+ #include Logging
29
29
  require_relative 'ssh.rb'
30
30
  include Ssh
31
31
  require_relative 'compute.rb'
@@ -35,28 +35,26 @@ include Compute
35
35
  # Down module
36
36
  #
37
37
  module Down
38
- def down(name)
38
+ def down(oFC, name)
39
39
  begin
40
40
 
41
41
  initial_msg = 'deleting forge "%s"' % [name]
42
42
  Logging.info(initial_msg)
43
- puts (initial_msg)
44
43
 
45
44
  Compute.delete_forge(name)
46
45
 
47
- router = Network.get_router('private-ext')
48
- subnet = Network.get_subnet(name)
46
+ router = Network.get_router(oFC, 'private-ext')
47
+ subnet = Network.get_subnet(oFC, name)
49
48
  Network.delete_router_interface(subnet.id, router)
50
49
 
51
- Network.delete_subnet(subnet.id)
52
- network = Network.get_network(name)
53
- Network.delete_network(network.name)
50
+ Network.delete_subnet(oFC, subnet.id)
51
+ network = Network.get_network(oFC, name)
52
+ Network.delete_network(oFC, network.name)
54
53
 
55
54
  rescue SystemExit, Interrupt
56
- puts 'process interrupted by user'
57
55
  Logging.error('process interrupted by user')
58
56
  rescue Exception => e
59
- Logging.error(e.message)
57
+ Logging.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
60
58
  end
61
59
  end
62
60
  end