forj 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b005cfdf0378f6542960384a955b0178b6fba87
4
+ data.tar.gz: 36c3649b97b76407bec1ea5abcc7a56b56df89df
5
+ SHA512:
6
+ metadata.gz: c04216e0b8ebf47678739a6d926ad00e30160d53648432cb2bf9c175da4b5bc90e86ca0e8f48d906248ea8a8f89a1f4c29e9840b6bba56038d377d519b67556a
7
+ data.tar.gz: 092c8482f8bd958e6fbdbbe12b39866755b43a600895e00b15301ca5925385b9da9e697f8431a31e004f251af8326306d6a5ddc9e48a0ce250dd69ccb1efd398
data/README.md CHANGED
@@ -5,11 +5,14 @@ Forj cli
5
5
  Installation
6
6
  =====================
7
7
  For ruby 2.0
8
- Fedora/CentOS/Redhat/rpm like system :
8
+
9
+ Fedora/CentOS/Redhat/rpm like system
10
+
9
11
  sudo yum install ruby-dev build-essential libopenssl-ruby libssl-dev zlib1g-dev -y
10
12
  sudo gem install forj
11
13
 
12
- Ubuntu/Debian/debian like system (not tested)
14
+ Ubuntu/Debian/debian like system (not tested)
15
+
13
16
  sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev -y
14
17
  sudo gem install forj
15
18
 
@@ -53,7 +56,27 @@ Optional arguments
53
56
  -x --box_name # Defines the name of the box or box image to build.
54
57
  -k --key_name # Key pair name to import.
55
58
  -p --key_path # Public key pair data.
56
-
59
+ -y --catalog # A path for the yaml file data about the blueprint
60
+
61
+ Catalog.yaml example
62
+
63
+ redstone:
64
+ image: proto2b
65
+ flavor: standard.xsmall
66
+ 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]
67
+ keypair_path: ~/.hpcloud/keypairs/nova
68
+ keypair_name: nova
69
+ router: private-ext
70
+ security_group: default
71
+ network: private
72
+ # at this point you have to clone the infra project manually
73
+ build_config_dir: ~/forj/infra/build/boxes/maestro
74
+ build_config: box-13.5
75
+ branch: master
76
+ box_name: maestro
77
+ infra: ~/.forj/infra
78
+ default:
79
+ maestro: https://github.com/forj-oss/maestro.git
57
80
  To ssh into a server
58
81
 
59
82
  forj ssh <name> <node>
data/bin/forj CHANGED
@@ -34,24 +34,23 @@ class Forj < Thor
34
34
  def help
35
35
  puts 'Forj cli help'
36
36
  puts ''
37
- puts ' forj setup # Set the credentials for forj.'
38
- puts ' required credentials:'
37
+ puts ' forj setup # Set the credentials for forj. Currently supports only hpcloud provider.'
38
+ puts ' Several data will be requested like:'
39
39
  puts ' access_key: access key from hpcloud'
40
40
  puts ' secret_key: secret key from hpcloud'
41
41
  puts ' auth_uri: identity endpoint'
42
42
  puts ' tenant_id: id for the tenant you want to use'
43
43
  puts ' availability_zone: which availability zone will be deployed'
44
44
  puts ''
45
- puts ' forj boot # Boot a new forge with the following options'
46
- puts ' required:'
47
- puts ' blueprint: name of the blueprint (currently cli only supports redstone)'
48
- puts ' on: just to have a natural description'
49
- puts ' cloud_provider: in which cloud provider to deploy the forge'
50
- puts ' as: just to have a natural description'
51
- puts ' name: name of the forge'
52
- puts ' example:'
53
- puts ' forj boot redstone on hpcloud as maestro_test'
54
- puts ' optional:'
45
+ puts ' forj boot <Blueprint> on <Provider> as <InstanceName> [options] # Boot a new forge with the following options'
46
+ puts ' where:'
47
+ puts ' blueprint : Is the name of the blueprint (currently cli only supports redstone)'
48
+ puts ' Provider : in which cloud provider to deploy the forge'
49
+ puts ' InstanceName : name of the forge'
50
+ puts ''
51
+ puts ' Ex: forj boot redstone on hpcloud as maestro_test'
52
+ puts ''
53
+ puts ' [Options] are:'
55
54
  puts ' -b build: replace the default build.sh'
56
55
  puts ' -bcd build_config_dir: defines the build configuration directory to load the build configuration file'
57
56
  puts ' -bc build_config: the build config file to load <confdir>/<BoxName>.<Config>.env.'
@@ -61,12 +60,12 @@ class Forj < Thor
61
60
  puts ' -bh boothook: by default, boothook file used is build/bin/build-tools/boothook.sh. Use this option to set another one.'
62
61
  puts ' -bn box_name: defines the name of the box or box image to build.'
63
62
  puts ''
64
- puts ' forj ssh # Connect through ssh to an existing instance'
65
- puts ' required:'
66
- puts ' name: name of the forge (maestro_test)'
67
- puts ' node: name of the node (maestro, ci, etc...)'
63
+ puts ' forj ssh <Name> <Node> # Connect through ssh to an existing instance'
64
+ puts ' where'
65
+ puts ' InstanceName: is the name of the forge (maestro_test)'
66
+ puts ' Node : is the name of the node (maestro, ci, etc...)'
68
67
  puts ''
69
- puts ' forj down # Delete a forge and create a backup of your data'
68
+ puts ' forj down <InstanceName> # Delete a forge and create a backup of your data'
70
69
  puts ' not yet implemented'
71
70
  puts ''
72
71
  puts ' forj help # Display this help'
@@ -75,7 +74,7 @@ class Forj < Thor
75
74
  desc 'boot', 'boot a Maestro box and instruct it to provision the blueprint'
76
75
 
77
76
  method_option :build, :aliases => '-u', :desc => 'Replace the default build.sh'
78
- method_option :build_config_dir, :aliases => '-d', :desc => 'Defines the build configuration directory to load the build configuration file. You can set FORJ_BLD_CONF_DIR. By default, it will look in your current directory.'
77
+ method_option :infra, :aliases => '-I', :desc => 'Defines the Infra directory to load the build configuration file. You can set FORJ_INFRA_DIR. By default, it will look in your current directory.'
79
78
  method_option :build_config, :aliases => '-c', :desc => 'The build config file to load <confdir>/<BoxName>.<Config>.env. By default, uses "master" as Config.'
80
79
  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>.'
81
80
  method_option :test_box, :aliases => '-t', :desc => 'Create test.rb-box meta from the repository path provided.'
data/lib/boot.rb CHANGED
@@ -15,8 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'rubygems'
19
- require 'require_relative'
18
+
19
+
20
20
 
21
21
  require_relative 'network.rb'
22
22
  include Network
@@ -36,58 +36,72 @@ include Helpers
36
36
  #
37
37
  module Boot
38
38
  def boot(blueprint, cloud_provider, name,
39
- build, build_config_dir, build_config,
39
+ build, infra_dir, build_config,
40
40
  branch, git_repo, boothook, box_name,
41
41
  key_name, key_path, region, catalog,
42
42
  test = false)
43
43
  begin
44
- initial_msg = 'booting %s on %s' % [blueprint , cloud_provider]
44
+ initial_msg = 'booting %s on %s (~/.forj/forj.log)' % [blueprint , cloud_provider]
45
45
 
46
46
  Logging.info(initial_msg)
47
- puts (initial_msg)
47
+ puts ('INFO: Reading default configuration...')
48
48
 
49
49
  forj_dir = File.expand_path(File.dirname(__FILE__))
50
50
  Dir.chdir(forj_dir)
51
51
 
52
+ #TODO: Consider defaults.yaml as default variables, and load more from ~/.forj/forj-config.yaml, to change defaults on user need.
52
53
  if catalog
53
54
  definitions = YamlParse.get_values(catalog)
54
55
  else
55
- definitions = YamlParse.get_values('catalog.yaml')
56
+ definitions = YamlParse.get_values('defaults.yaml')
56
57
  end
58
+
59
+ # Initialize defaults
60
+ maestro_url = definitions['default']['maestro_url']
57
61
 
58
- maestro_url = definitions['default']['maestro']
59
-
60
- Repositories.clone_repo(maestro_url)
61
- infra_exists = nil
62
+ infra_dir = definitions['default']['infra_repo'] unless infra_dir
62
63
 
63
- begin
64
- if File.directory?(definitions[blueprint]['infra'])
65
- infra_exists = true
66
- else
67
- Repositories.create_infra
68
- end
69
- rescue => e
70
- infra_exists = false
71
- puts e.message
64
+ # Ask information if needed.
65
+ bBuildInfra=false
66
+ if not Dir.exist?(File.expand_path(infra_dir))
67
+ 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]
68
+ bBuildInfra=agree(sAsk)
69
+ else
70
+ puts('INFO: Re-using your infra... in \'%s\'' % [infra_dir])
71
+ end
72
+ if not Dir.exist?(File.expand_path(infra_dir)) and not bBuildInfra
73
+ puts ('Exiting.')
74
+ return
72
75
  end
73
76
 
77
+ # Step Maestro Clone
78
+ puts('INFO: cloning maestro repo from \'%s\'...' % maestro_url)
79
+ Repositories.clone_repo(maestro_url)
80
+
81
+ if bBuildInfra
82
+ puts('INFO: Building your infra... in \'%s\'' % [infra_dir])
83
+ Repositories.create_infra
84
+ end
74
85
 
75
- network = Network.get_or_create_network(definitions[blueprint]['network'])
86
+ puts('INFO: Configuring network \'%s\'' % [definitions['default']['network']])
87
+ network = Network.get_or_create_network(definitions['default']['network'])
76
88
  begin
77
89
  subnet = Network.get_or_create_subnet(network.id, name)
78
- router = Network.get_router(definitions[blueprint]['router'])
90
+ router = Network.get_router(definitions['default']['router'])
79
91
  Network.create_router_interface(subnet.id, router)
80
92
  rescue => e
81
93
  puts e.message
82
94
  end
83
95
 
84
- security_group = SecurityGroup.get_or_create_security_group(definitions[blueprint]['security_group'])
85
96
 
86
- key_name = definitions[blueprint]['keypair_name'] unless key_name
87
- key_path = definitions[blueprint]['keypair_path'] unless key_path
97
+ puts('INFO: Configuring keypair \'%s\'' % [definitions['default']['keypair_name']])
98
+ key_name = definitions['default']['keypair_name'] unless key_name
99
+ key_path = definitions['default']['keypair_path'] unless key_path
88
100
  SecurityGroup.upload_existing_key(key_name, key_path)
89
101
 
90
- ports = definitions[blueprint]['ports']
102
+ puts('INFO: Configuring Security Group \'%s\'' % [definitions['default']['security_group']])
103
+ security_group = SecurityGroup.get_or_create_security_group(definitions['default']['security_group'])
104
+ ports = definitions['default']['ports']
91
105
 
92
106
  ports.each do|port|
93
107
  Network.get_or_create_rule(security_group.id, 'tcp', port, port)
@@ -102,6 +116,7 @@ module Boot
102
116
  end
103
117
 
104
118
  # run build.sh to boot maestro
119
+ puts
105
120
  current_dir = Dir.pwd
106
121
  home = Helpers.get_home_path
107
122
  build_path = home + '/.forj/maestro/build'
@@ -109,23 +124,19 @@ module Boot
109
124
 
110
125
  build = 'bin/build.sh' unless build
111
126
 
112
- if infra_exists
113
- build_config_dir = definitions[blueprint]['infra'] unless build_config_dir
114
- else
115
- build_config_dir = definitions[blueprint]['build_config_dir'] unless build_config_dir
116
- end
117
-
118
- build_config = definitions[blueprint]['build_config'] unless build_config
127
+ build_config = definitions['default']['build_config'] unless build_config
119
128
 
120
- branch = definitions[blueprint]['branch'] unless branch
129
+ branch = definitions['default']['branch'] unless branch
121
130
 
122
- box_name = definitions[blueprint]['box_name'] unless box_name
131
+ box_name = definitions['default']['box_name'] unless box_name
123
132
 
124
- meta = '--meta blueprint=%s --meta HPCLOUD_PRIV=~/.cache/forj/master.forj-13.5.g64' % [blueprint]
133
+ meta = '--meta blueprint=%s' % [blueprint]
125
134
 
126
- command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --debug-box %s' % [build, name, box_name, build_config_dir, build_config, branch, meta]
135
+ 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]
127
136
 
128
- Logging.info('using build.sh for %s' % [name])
137
+ Logging.info('Calling build.sh')
138
+ Logging.info(command)
139
+
129
140
  Kernel.system(command)
130
141
  Dir.chdir(current_dir)
131
142
 
@@ -142,6 +153,9 @@ module Boot
142
153
  Logging.info(msg)
143
154
  rescue StandardError => e
144
155
  Logging.error(e.message)
156
+ puts e.backtrace.join("\n")
157
+
158
+ puts e.message
145
159
  end
146
160
  end
147
161
  end
@@ -12,7 +12,9 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- redstone:
15
+ default:
16
+ maestro_url: https://github.com/forj-oss/maestro.git
17
+ infra_repo: ~/.forj/infra
16
18
  image: proto2b
17
19
  flavor: standard.xsmall
18
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]
@@ -23,16 +25,6 @@ redstone:
23
25
  network: private
24
26
  # at this point you have to clone the infra project manually
25
27
  build_config_dir: ~/forj/infra/build/boxes/maestro
26
- build_config: box-13.5
28
+ build_config: box
27
29
  branch: master
28
30
  box_name: maestro
29
- infra: ~/.forj/infra
30
-
31
-
32
- modus:
33
- ports: []
34
- keypair: nova
35
- router: private-ext
36
-
37
- default:
38
- maestro: https://github.com/forj-oss/maestro.git
data/lib/repositories.rb CHANGED
@@ -50,6 +50,7 @@ module Repositories
50
50
  end
51
51
  Dir.chdir(current_dir)
52
52
  end
53
+
53
54
  def create_infra
54
55
  home = File.expand_path('~')
55
56
  path = home + '/.forj/'
@@ -68,4 +69,4 @@ module Repositories
68
69
  fill_template = 'python build-env.py -p ~/.forj/infra --maestro-path ~/.forj/maestro'
69
70
  Kernel.system(fill_template)
70
71
  end
71
- end
72
+ end
data/lib/setup.rb CHANGED
@@ -17,6 +17,7 @@
17
17
 
18
18
  require 'rubygems'
19
19
  require 'require_relative'
20
+ require 'highline/import'
20
21
 
21
22
  require_relative 'yaml_parse.rb'
22
23
  include YamlParse
@@ -36,14 +37,14 @@ end
36
37
 
37
38
  def setup_credentials
38
39
  puts 'Enter hpcloud username: '
39
- hpcloud_os_user = $stdin.gets
40
- puts 'Enter hpcloud password: '
41
- hpcloud_os_key = $stdin.gets
40
+ hpcloud_os_user = ask('Enter hpcloud username: ')
41
+ hpcloud_os_key = ask('Enter hpcloud password: ') { |q| q.echo = '*'}
42
42
 
43
43
  home = File.expand_path('~')
44
44
  creds = '%s/.cache/forj/creds' % [home]
45
45
  File.open(creds, 'w') {|file|
46
46
  file.write('HPCLOUD_OS_USER=%s' % [hpcloud_os_user])
47
+ file.write("\n")
47
48
  file.write('HPCLOUD_OS_KEY=%s' % [hpcloud_os_key])
48
49
  }
49
50
  end
data/lib/yaml_parse.rb CHANGED
@@ -26,7 +26,7 @@ include Logging
26
26
  module YamlParse
27
27
  def get_values(path_to_yaml)
28
28
  begin
29
- Logging.info('getting values from catalog.yaml, this will be a service catalog.forj.io')
29
+ Logging.info('getting values from defaults.yaml, this will be a service catalog.forj.io')
30
30
  YAML.load_file(path_to_yaml)
31
31
  rescue => e
32
32
  Logging.error(e.message)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
5
- prerelease:
4
+ version: 0.0.32
6
5
  platform: ruby
7
6
  authors:
8
7
  - forj team
@@ -13,70 +12,102 @@ date: 2014-06-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
- requirement: &4634460 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.16.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *4634460
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.16.0
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: nokogiri
27
- requirement: &4633120 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: 1.5.11
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *4633120
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.11
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: fog
38
- requirement: &4629760 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
47
  version: 1.19.0
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *4629760
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.19.0
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: hpcloud
49
- requirement: &4629180 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: 2.0.8
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *4629180
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.8
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: git
60
- requirement: &4628460 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ! '>='
73
+ - - '>='
64
74
  - !ruby/object:Gem::Version
65
75
  version: 1.2.7
66
76
  type: :runtime
67
77
  prerelease: false
68
- version_requirements: *4628460
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.2.7
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rbx-require-relative
71
- requirement: &4627320 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
87
  - - ~>
75
88
  - !ruby/object:Gem::Version
76
89
  version: 0.0.7
77
90
  type: :runtime
78
91
  prerelease: false
79
- version_requirements: *4627320
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.0.7
97
+ - !ruby/object:Gem::Dependency
98
+ name: highline
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 1.6.21
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 1.6.21
80
111
  description: forj command line
81
112
  email:
82
113
  - forj@forj.io
@@ -91,7 +122,7 @@ files:
91
122
  - lib/network.rb
92
123
  - lib/security.rb
93
124
  - lib/yaml_parse.rb
94
- - lib/catalog.yaml
125
+ - lib/defaults.yaml
95
126
  - lib/down.rb
96
127
  - lib/boot.rb
97
128
  - lib/setup.rb
@@ -116,26 +147,25 @@ files:
116
147
  homepage: https://forj.io
117
148
  licenses:
118
149
  - Apache License, Version 2.0.
150
+ metadata: {}
119
151
  post_install_message: Go to docs.forj.io for more information on how to use forj cli
120
152
  rdoc_options: []
121
153
  require_paths:
122
154
  - lib
123
155
  required_ruby_version: !ruby/object:Gem::Requirement
124
- none: false
125
156
  requirements:
126
- - - ! '>='
157
+ - - '>='
127
158
  - !ruby/object:Gem::Version
128
159
  version: 1.8.5
129
160
  required_rubygems_version: !ruby/object:Gem::Requirement
130
- none: false
131
161
  requirements:
132
- - - ! '>='
162
+ - - '>='
133
163
  - !ruby/object:Gem::Version
134
164
  version: '0'
135
165
  requirements: []
136
166
  rubyforge_project:
137
- rubygems_version: 1.8.11
167
+ rubygems_version: 2.1.11
138
168
  signing_key:
139
- specification_version: 3
169
+ specification_version: 4
140
170
  summary: forj command line
141
171
  test_files: []