lorj 0.2.0 → 1.0.0
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +46 -0
- data/Gemfile +15 -15
- data/README.md +22 -17
- data/Rakefile +12 -2
- data/bin/cloud_test.rb +13 -65
- data/example/students_1/process/students.rb +39 -0
- data/example/students_1/students.rb +22 -5
- data/example/students_2/process/students.rb +48 -0
- data/example/students_2/students.rb +39 -16
- data/example/students_3/controller/yaml_students.rb +50 -43
- data/example/students_3/controller/yaml_students_controller.rb +100 -87
- data/example/students_3/process/students.rb +161 -97
- data/example/students_3/students.rb +85 -56
- data/example/yaml_students/students.rb +40 -40
- data/example/yaml_students/yaml_students.rb +103 -90
- data/lib/core/core.rb +356 -696
- data/lib/core/core_controller.rb +227 -0
- data/lib/core/core_internal.rb +339 -0
- data/lib/core/core_model.rb +328 -0
- data/lib/core/core_object_data.rb +330 -0
- data/lib/core/core_object_params.rb +230 -0
- data/lib/core/core_process.rb +391 -0
- data/lib/core/core_process_setup.rb +353 -0
- data/lib/core/core_setup_ask.rb +241 -0
- data/lib/core/core_setup_encrypt.rb +146 -0
- data/lib/core/core_setup_init.rb +229 -0
- data/lib/core/core_setup_list.rb +160 -0
- data/lib/core/definition.rb +647 -469
- data/lib/core/definition_internal.rb +264 -308
- data/lib/core/lorj_basecontroller.rb +95 -0
- data/lib/core/lorj_basedefinition.rb +307 -0
- data/lib/core/lorj_baseprocess.rb +265 -0
- data/lib/core/lorj_data.rb +583 -0
- data/lib/core/lorj_keypath.rb +119 -0
- data/lib/core_process/cloud/process/common.rb +63 -0
- data/lib/core_process/cloud/process/connection.rb +93 -0
- data/lib/core_process/cloud/process/external_network.rb +94 -0
- data/lib/core_process/cloud/process/flavor.rb +99 -0
- data/lib/core_process/cloud/process/images.rb +87 -0
- data/lib/core_process/cloud/process/internet_network.rb +34 -0
- data/lib/core_process/cloud/process/internet_server.rb +30 -0
- data/lib/core_process/cloud/process/keypairs.rb +276 -0
- data/lib/core_process/cloud/process/network.rb +108 -0
- data/lib/core_process/cloud/process/public_ip.rb +100 -0
- data/lib/core_process/cloud/process/router.rb +260 -0
- data/lib/core_process/cloud/process/rules.rb +120 -0
- data/lib/core_process/cloud/process/security_groups.rb +121 -0
- data/lib/core_process/cloud/process/server.rb +127 -0
- data/lib/core_process/cloud/process/server_log.rb +35 -0
- data/lib/core_process/cloud/process/subnetwork.rb +108 -0
- data/lib/core_process/cloud_process.rb +30 -0
- data/lib/logging.rb +298 -0
- data/lib/lorj/version.rb +18 -1
- data/lib/lorj.rb +58 -18
- data/lib/lorj_account.rb +556 -0
- data/lib/lorj_config.rb +468 -0
- data/lib/lorj_defaults.rb +278 -0
- data/lib/prc.rb +136 -104
- data/lib/prc_base_config.rb +285 -0
- data/lib/prc_core_config.rb +878 -0
- data/lib/prc_section_config.rb +57 -0
- data/lib/providers/hpcloud/compute.rb +81 -93
- data/lib/providers/hpcloud/hpcloud.rb +462 -0
- data/lib/providers/hpcloud/network.rb +96 -98
- data/lib/providers/hpcloud/security_groups.rb +41 -40
- data/lib/providers/mock/mock.rb +144 -0
- data/lib/providers/openstack/openstack.rb +45 -0
- data/lib/providers/templates/compute.rb +21 -23
- data/lib/providers/templates/mycloud.rb +72 -0
- data/lib/providers/templates/network.rb +11 -12
- data/lib/rh.rb +339 -0
- data/lorj-spec/defaults.yaml +4 -0
- data/lorj.gemspec +6 -0
- data/spec/00_lorj_log_spec.rb +53 -0
- data/spec/01_hash_rh_spec.rb +243 -0
- data/spec/02_prc_base_config_spec.rb +216 -0
- data/spec/04_prc_core_config_spec.rb +83 -0
- data/spec/11_lorj_config_spec.rb +263 -0
- data/spec/12_lorj_account_spec.rb +181 -0
- metadata +76 -28
- data/Gemfile.lock +0 -37
- data/example/students_1/process/Students.rb +0 -20
- data/example/students_2/process/Students.rb +0 -27
- data/example/students_4/controller/yaml_students.rb +0 -82
- data/example/students_4/controller/yaml_students_controller.rb +0 -141
- data/example/students_4/process/students.rb +0 -112
- data/example/students_4/students.rb +0 -103
- data/lib/core/lorj-basecontroller.rb +0 -90
- data/lib/core/lorj-basedefinition.rb +0 -1139
- data/lib/core/lorj-baseprocess.rb +0 -236
- data/lib/core/lorj-data.rb +0 -567
- data/lib/core/lorj-keypath.rb +0 -115
- data/lib/core_process/CloudProcess.rb +0 -337
- data/lib/core_process/global_process.rb +0 -502
- data/lib/core_process/network_process.rb +0 -605
- data/lib/prc-account.rb +0 -339
- data/lib/prc-config.rb +0 -1030
- data/lib/prc-logging.rb +0 -261
- data/lib/providers/hpcloud/Hpcloud.rb +0 -426
- data/lib/providers/mock/Mock.rb +0 -141
- data/lib/providers/openstack/Openstack.rb +0 -47
- data/lib/providers/templates/core.rb +0 -61
- data/spec/forj-account_spec.rb +0 -75
- data/spec/forj-config_spec.rb +0 -196
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eeba3dfb1287558282764e42fab9e32628ebbbd3
|
|
4
|
+
data.tar.gz: 27119784fb89ca8911f2cc722f1a2d09454d5e7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d936b458e2a74c00f165a3b3d41d914aab89602ef250cc08c4ede8fc0f649aba765818f3fe2e1beab5abfe72ac03f9a96e73f86230a38f962313818eb1c5eaa6
|
|
7
|
+
data.tar.gz: ad7e7604d301400b754c1811de06d5711f11563c2e35663cc2bb1f3ce46168772139cdc9979167ca655602f229af954d6bb15cf47beab7754b03bfb3a82a114d
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# use: rubocop --show-cops
|
|
16
|
+
# to validate configuration.
|
|
17
|
+
# rubocop config
|
|
18
|
+
AllCops:
|
|
19
|
+
Include:
|
|
20
|
+
- '**/Rakefile'
|
|
21
|
+
- '**/config.ru'
|
|
22
|
+
Exclude:
|
|
23
|
+
- 'docker/**/*'
|
|
24
|
+
- 'bin/scripts/**/*'
|
|
25
|
+
- 'git/**/*'
|
|
26
|
+
- 'tmp/**/*'
|
|
27
|
+
#Documentation:
|
|
28
|
+
# Enabled: false
|
|
29
|
+
#Metrics/LineLength:
|
|
30
|
+
# Max: 99
|
|
31
|
+
Style/HashSyntax:
|
|
32
|
+
EnforcedStyle: hash_rockets
|
|
33
|
+
|
|
34
|
+
# lets start with 40, but 10 is way to small..
|
|
35
|
+
Metrics/MethodLength:
|
|
36
|
+
Max: 40
|
|
37
|
+
# If Method length is increased, class length need to be extended as well.
|
|
38
|
+
Metrics/ClassLength:
|
|
39
|
+
Max: 150
|
|
40
|
+
|
|
41
|
+
# allow arguments to be longer than 15
|
|
42
|
+
Metrics/AbcSize:
|
|
43
|
+
Max: 40
|
|
44
|
+
# forj-docker binary name gets an exception
|
|
45
|
+
Style/FileName:
|
|
46
|
+
Exclude: ['bin/forj-docker', 'lib/**/forj-docker.rb']
|
data/Gemfile
CHANGED
|
@@ -3,23 +3,23 @@ source 'https://rubygems.org'
|
|
|
3
3
|
# Specify your gem's dependencies in procontrol.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
#group(:development, :test) do
|
|
6
|
+
# group(:development, :test) do
|
|
7
7
|
# gem 'rake'
|
|
8
8
|
# gem 'debugger'
|
|
9
9
|
# gem 'byebug'
|
|
10
10
|
# gem 'rspec', "~> 3.1.0", :require => false
|
|
11
|
-
#end
|
|
11
|
+
# end
|
|
12
12
|
|
|
13
|
-
#gem 'mime-types','1.25.1'
|
|
14
|
-
#gem 'excon','0.31.0'
|
|
15
|
-
#gem 'json','1.7.5'
|
|
16
|
-
#gem 'nokogiri','1.5.11'
|
|
17
|
-
#gem 'fog', '1.19.0'
|
|
18
|
-
#gem 'git', '>=1.2.7'
|
|
19
|
-
#gem 'rainbow'
|
|
20
|
-
#gem 'rbx-require-relative', '~> 0.0.7'
|
|
21
|
-
#gem 'thor', '>=0.16.0'
|
|
22
|
-
#gem 'hpcloud', '~>2.0.9'
|
|
23
|
-
#gem 'highline','>=1.6.21'
|
|
24
|
-
#gem 'ansi','>=1.4.3'
|
|
25
|
-
#gem 'encryptor','>=1.3.0'
|
|
13
|
+
# gem 'mime-types','1.25.1'
|
|
14
|
+
# gem 'excon','0.31.0'
|
|
15
|
+
# gem 'json','1.7.5'
|
|
16
|
+
# gem 'nokogiri','1.5.11'
|
|
17
|
+
# gem 'fog', '1.19.0'
|
|
18
|
+
# gem 'git', '>=1.2.7'
|
|
19
|
+
# gem 'rainbow'
|
|
20
|
+
# gem 'rbx-require-relative', '~> 0.0.7'
|
|
21
|
+
# gem 'thor', '>=0.16.0'
|
|
22
|
+
# gem 'hpcloud', '~>2.0.9'
|
|
23
|
+
# gem 'highline','>=1.6.21'
|
|
24
|
+
# gem 'ansi','>=1.4.3'
|
|
25
|
+
# gem 'encryptor','>=1.3.0'
|
data/README.md
CHANGED
|
@@ -153,14 +153,14 @@ Currently, this model do nothing except printing out.
|
|
|
153
153
|
#####typical output
|
|
154
154
|
|
|
155
155
|
$ example/students_1/students.rb
|
|
156
|
-
WARNING: PrcLib.app_defaults is not set. Application defaults won't be loaded.
|
|
156
|
+
WARNING: PrcLib.app_defaults is not set. Application defaults won't be loaded.
|
|
157
157
|
Running creation process for object 'student' = 'Robert Redford'
|
|
158
158
|
WARNING: 'create_student' has returned no data for object Lorj::Data 'student'!
|
|
159
159
|
|
|
160
|
-
There is 2 warnings.
|
|
160
|
+
There is 2 warnings.
|
|
161
161
|
|
|
162
162
|
* **PrcLib.app_defaults** represents the application name. It is used to keep your application configuration data in ~/.{PrcLib.app_defaults}/ directory. Defining this data in your main, will eliminate this warning.
|
|
163
|
-
* **create_student** function in your process has returned nothing. while lorj is called to create an object, it assumes to get the object data created. Lorj keep those data in a cache. In this example, **create_student** returned nil, and lorj raise a warning about that.
|
|
163
|
+
* **create_student** function in your process has returned nothing. while lorj is called to create an object, it assumes to get the object data created. Lorj keep those data in a cache. In this example, **create_student** returned nil, and lorj raise a warning about that.
|
|
164
164
|
|
|
165
165
|
---
|
|
166
166
|
#### Writing student version 2
|
|
@@ -235,7 +235,7 @@ The update your main and add those lines. In the following, we create 3 students
|
|
|
235
235
|
#####typical output:
|
|
236
236
|
|
|
237
237
|
$ example/students_2/students.rb
|
|
238
|
-
WARNING: PrcLib.app_defaults is not set. Application defaults won't be loaded.
|
|
238
|
+
WARNING: PrcLib.app_defaults is not set. Application defaults won't be loaded.
|
|
239
239
|
2 students found
|
|
240
240
|
0: Robert Redford
|
|
241
241
|
1: Robert Redford
|
|
@@ -515,11 +515,14 @@ We need to write the controller part, now. As I said, it is like a wrapper. Let'
|
|
|
515
515
|
# extract the information requested by the framework.
|
|
516
516
|
# Those data will be mapped to the process data model.
|
|
517
517
|
# The key is an array, to get data from a level tree.
|
|
518
|
-
# [data_l1, data_l2, data_l3] => should retrieve data from structure
|
|
518
|
+
# [data_l1, data_l2, data_l3] => should retrieve data from structure
|
|
519
|
+
# like data[ data_l2 [ data_l3 ] ]
|
|
519
520
|
begin
|
|
520
521
|
attributes = oControlerObject
|
|
521
|
-
raise "get_attr: attribute '%s' is unknown in '%s'. Valid one are : '%s'"
|
|
522
|
-
|
|
522
|
+
raise "get_attr: attribute '%s' is unknown in '%s'. Valid one are : '%s'",
|
|
523
|
+
key[0], oControlerObject.class,
|
|
524
|
+
@@valid_attributes unless @@valid_attributes.include?(key[0])
|
|
525
|
+
Lorj::rh_get(attributes, key)
|
|
523
526
|
rescue => e
|
|
524
527
|
Error "get_attr: Unable to map '%s'. %s" % [key, e.message]
|
|
525
528
|
end
|
|
@@ -528,8 +531,10 @@ We need to write the controller part, now. As I said, it is like a wrapper. Let'
|
|
|
528
531
|
def set_attr(oControlerObject, key, value)
|
|
529
532
|
begin
|
|
530
533
|
attributes = oControlerObject
|
|
531
|
-
raise "set_attr: attribute '%s' is unknown in '%s'. Valid one are : '%s'"
|
|
532
|
-
|
|
534
|
+
raise "set_attr: attribute '%s' is unknown in '%s'. Valid one are : '%s'",
|
|
535
|
+
key[0], oControlerObject.class,
|
|
536
|
+
@@valid_attributes unless @@valid_attributes.include?(key[0])
|
|
537
|
+
Lorj::rh_set(attributes, value, key)
|
|
533
538
|
rescue => e
|
|
534
539
|
Error "set_attr: Unable to map '%s' on '%s'" % [key, sObjectType]
|
|
535
540
|
end
|
|
@@ -575,11 +580,11 @@ And we need to write some mapping stuff to the controller. We have to add this
|
|
|
575
580
|
define_obj(:connection,{
|
|
576
581
|
:create_e => :controller_create # Nothing complex to do. So, simply call the controller create.
|
|
577
582
|
})
|
|
578
|
-
|
|
583
|
+
|
|
579
584
|
obj_needs :data, :connection_string, :mapping => :file_name
|
|
580
585
|
undefine_attribute :id # Do not return any predefined ID
|
|
581
586
|
undefine_attribute :name # Do not return any predefined NAME
|
|
582
|
-
|
|
587
|
+
|
|
583
588
|
# The student model have to be expanded.
|
|
584
589
|
define_obj(:student)
|
|
585
590
|
# It requires to create a connection to the data, ie opening the yaml file.
|
|
@@ -587,18 +592,18 @@ And we need to write some mapping stuff to the controller. We have to add this
|
|
|
587
592
|
# This connection will be loaded in the memory and provided to the controller
|
|
588
593
|
# when needed.
|
|
589
594
|
obj_needs :CloudObject, :connection
|
|
590
|
-
|
|
595
|
+
|
|
591
596
|
# To simplify controller wrapper, we use hdata built by lorj, and passed to the API
|
|
592
597
|
# This hdata is a hash containing mapped data, thanks to set_hdata.
|
|
593
598
|
set_hdata :first_name
|
|
594
599
|
set_hdata :last_name
|
|
595
600
|
# Instead of 'course', the yaml API uses 'training'
|
|
596
601
|
set_hdata :course, :mapping => :training
|
|
597
|
-
|
|
602
|
+
|
|
598
603
|
get_attr_mapping :course, :training
|
|
599
604
|
# instead of 'student_name', the yaml API uses 'name'
|
|
600
605
|
get_attr_mapping :student_name, :name
|
|
601
|
-
|
|
606
|
+
|
|
602
607
|
# This controller will know how to manage a student file with those data.
|
|
603
608
|
# But note that the file can have a lot of more data than what the process
|
|
604
609
|
# usually manage. It is up to you to increase your process to manage more data.
|
|
@@ -609,8 +614,8 @@ And we need to write some mapping stuff to the controller. We have to add this
|
|
|
609
614
|
That's it!
|
|
610
615
|
|
|
611
616
|
#####typical output:
|
|
612
|
-
$ example/students_3/students.rb
|
|
613
|
-
WARNING: PrcLib.app_defaults is not set. Application defaults won't be loaded.
|
|
617
|
+
$ example/students_3/students.rb
|
|
618
|
+
WARNING: PrcLib.app_defaults is not set. Application defaults won't be loaded.
|
|
614
619
|
Create 1st student:
|
|
615
620
|
Create 2nd student:
|
|
616
621
|
Create 3rd student:
|
|
@@ -623,7 +628,7 @@ That's it!
|
|
|
623
628
|
{:id=>2, :course=>"Art Drama", :student_name=>"Marilyn Monroe", :first_name=>"Marilyn", :last_name=>"Monroe", :status=>:active}
|
|
624
629
|
Deleted students:
|
|
625
630
|
{:id=>3, :course=>"what ever you want!!!", :student_name=>"Anthony Mistake", :first_name=>"Anthony", :last_name=>"Mistake", :status=>:removed}
|
|
626
|
-
|
|
631
|
+
|
|
627
632
|
## What next?
|
|
628
633
|
|
|
629
634
|
Check the code in the `examples/students_3/`. It provides a little more than is written here.
|
data/Rakefile
CHANGED
|
@@ -14,11 +14,21 @@
|
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
|
-
require
|
|
17
|
+
require 'bundler/gem_tasks'
|
|
18
18
|
require 'rspec/core/rake_task'
|
|
19
|
+
require 'rubocop/rake_task'
|
|
20
|
+
|
|
21
|
+
task :default => [:lint, :spec]
|
|
19
22
|
|
|
20
23
|
desc 'Run the specs.'
|
|
21
|
-
RSpec::Core::RakeTask.new do |t|
|
|
24
|
+
RSpec::Core::RakeTask.new do |t|
|
|
22
25
|
t.pattern = 'spec/*_spec.rb'
|
|
26
|
+
t.rspec_opts = '-f doc'
|
|
23
27
|
end
|
|
24
28
|
|
|
29
|
+
desc 'Run RuboCop on the project'
|
|
30
|
+
RuboCop::RakeTask.new(:lint) do |task|
|
|
31
|
+
task.formatters = ['progress']
|
|
32
|
+
task.verbose = true
|
|
33
|
+
task.fail_on_error = true
|
|
34
|
+
end
|
data/bin/cloud_test.rb
CHANGED
|
@@ -1,81 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
#require 'byebug'
|
|
3
|
+
# require 'byebug'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
app_path = File.dirname(__FILE__)
|
|
6
|
+
lib_path = File.expand_path(File.join(File.dirname(app_path), 'lib'))
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
load_path << lib_path
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
require 'appinit.rb'
|
|
13
|
-
|
|
14
|
-
# Initialize forj paths
|
|
15
|
-
AppInit::forj_initialize()
|
|
16
|
-
|
|
17
|
-
# Initialize global Log object
|
|
18
|
-
$FORJ_LOGGER=LorjLog.new()
|
|
19
|
-
|
|
20
|
-
require 'lib-forj.rb'
|
|
21
|
-
|
|
22
|
-
Logging.set_level(Logger::DEBUG)
|
|
10
|
+
require 'lorj.rb'
|
|
23
11
|
|
|
24
12
|
# Load global Config
|
|
25
|
-
|
|
13
|
+
oconfig = ForjConfig.new
|
|
26
14
|
|
|
27
|
-
|
|
15
|
+
processes = []
|
|
28
16
|
|
|
29
17
|
# Defines how to manage Maestro and forges
|
|
30
18
|
# create a maestro box. Identify a forge instance, delete it,...
|
|
31
|
-
|
|
19
|
+
processes << File.join(lib_path, 'forj', 'ForjCore.rb')
|
|
32
20
|
|
|
33
21
|
# Defines how cli will control FORJ features
|
|
34
22
|
# boot/down/ssh/...
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
$LIB_FORJ_DEBUG = 3 # verbose
|
|
38
|
-
|
|
39
|
-
infra_dir = File.expand_path(oConfig.get(:infra_repo))
|
|
40
|
-
|
|
41
|
-
# Ask information if needed.
|
|
42
|
-
if not Dir.exist?(File.expand_path(infra_dir))
|
|
43
|
-
Logging.warning(<<-END
|
|
44
|
-
Your infra workspace directory is missing.
|
|
45
|
-
|
|
46
|
-
Forj uses an infra workspace directory to store any kind of data that are private to you.
|
|
47
|
-
We provides ways to send those data securily to your new Forge instance, as metadata.
|
|
48
|
-
In production case, we suggest you to keep it safe in your SCM preferred database.
|
|
49
|
-
|
|
50
|
-
If you already have an existing infra workspace, use 'forj set infra_repo=<PathToYourRepo>' to set it and restart.
|
|
51
|
-
|
|
52
|
-
Otherwise, we will build a new one with some predefined data, you can review and update later.
|
|
53
|
-
END
|
|
54
|
-
)
|
|
55
|
-
sAsk = "Do you want to create a new one from Maestro (yes/no)?" % [infra_dir]
|
|
56
|
-
bBuildInfra=agree(sAsk)
|
|
57
|
-
if not bBuildInfra
|
|
58
|
-
puts 'Process aborted on your demand.'
|
|
59
|
-
exit 0
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
oCloud = ForjCloud.new(oConfig, 'hpcloud', aProcesses)
|
|
64
|
-
|
|
65
|
-
#oConfig.set(:instance_name, "test")
|
|
66
|
-
#oCloud.Create(:metadata)
|
|
67
|
-
#oCloud.Create(:infra_repository)
|
|
68
|
-
#oCloud.Create(:userdata)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
#oCloud.Setup(:server, 'hpcloud')
|
|
72
|
-
#oCloud.Setup(:forge, 'hpcloud')
|
|
73
|
-
|
|
74
|
-
#oCloud.Create(:forge)
|
|
23
|
+
processes << File.join(lib_path, 'forj', 'ForjCli.rb')
|
|
75
24
|
|
|
76
|
-
|
|
77
|
-
oConfig.set(:box, 'maestro')
|
|
78
|
-
#oConfig.Create(:server)
|
|
79
|
-
oCloud.Create(:ssh)
|
|
25
|
+
ocloud = ForjCloud.new(oconfig, 'hpcloud', processes)
|
|
80
26
|
|
|
81
|
-
|
|
27
|
+
oconfig.set(:box_name, '183')
|
|
28
|
+
oconfig.set(:box, 'maestro')
|
|
29
|
+
ocloud.Create(:ssh)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# Students process
|
|
18
|
+
class StudentsProcess
|
|
19
|
+
def create_student(sObjectType, hParams)
|
|
20
|
+
puts format("Running creation process for object '%s' = '%s'",
|
|
21
|
+
sObjectType, hParams[:student_name])
|
|
22
|
+
# If you prefer to print out to the log system instead:
|
|
23
|
+
# PrcLib::debug(format("Running creation process for object '%s' = '%s'",
|
|
24
|
+
# sObjectType, hParams[:student_name] ))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Declaring your data model and handlers.
|
|
29
|
+
# Rubocop: Disabling Style/ClassAndModuleChildren to avoid un-needed indentation
|
|
30
|
+
class Lorj::BaseDefinition # rubocop:disable Style/ClassAndModuleChildren
|
|
31
|
+
# We need to define the student object and the handler to use while we need
|
|
32
|
+
# to create it.
|
|
33
|
+
define_obj(:student,
|
|
34
|
+
# The function to call in the class Students
|
|
35
|
+
:create_e => :create_student
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
obj_needs :data, :student_name, :for => [:create_e]
|
|
39
|
+
end
|
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
app_path = File.dirname(__FILE__)
|
|
2
19
|
|
|
3
|
-
$APP_PATH = File.dirname(__FILE__)
|
|
4
20
|
require 'lorj'
|
|
5
21
|
|
|
6
|
-
# If you want to see what is happening in the framework, uncomment debug
|
|
22
|
+
# If you want to see what is happening in the framework, uncomment debug
|
|
23
|
+
# settings.
|
|
7
24
|
# PrcLib.level = Logger::DEBUG # Printed out to your console.
|
|
8
25
|
# PrcLib.core_level = 3 # framework debug levels.
|
|
9
26
|
|
|
10
27
|
# Initialize the framework
|
|
11
|
-
|
|
28
|
+
processes = [File.join(app_path, 'process', 'students.rb')]
|
|
12
29
|
|
|
13
|
-
|
|
30
|
+
student_core = Lorj::Core.new(nil, processes)
|
|
14
31
|
|
|
15
32
|
# Ask the framework to create the object student 'Robert Redford'
|
|
16
|
-
|
|
33
|
+
student_core.create(:student, :student_name => 'Robert Redford')
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# Students process
|
|
18
|
+
class StudentsProcess
|
|
19
|
+
def create_student(sObjectType, hParams)
|
|
20
|
+
PrcLib.state(format("Running creation process for object '%s' = '%s'",
|
|
21
|
+
sObjectType, hParams[:student_name]))
|
|
22
|
+
|
|
23
|
+
object = controller_create(sObjectType)
|
|
24
|
+
fail format("Student '%s' not created.",
|
|
25
|
+
hParams[:student_name]) if object.nil?
|
|
26
|
+
PrcLib.info(format("'%s': '%s' created with id %s",
|
|
27
|
+
sObjectType, hParams[:student_name], object[:id]))
|
|
28
|
+
object
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Declaring your data model and handlers.
|
|
33
|
+
class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
|
|
34
|
+
# We need to define the student object and the handler to use while we need to
|
|
35
|
+
# create it.
|
|
36
|
+
define_obj(:student,
|
|
37
|
+
# The function to call in the class Students
|
|
38
|
+
:create_e => :create_student,
|
|
39
|
+
# We use predefined call to the controller query
|
|
40
|
+
:query_e => :controller_query,
|
|
41
|
+
# We use predefined call to the controller get
|
|
42
|
+
:get_e => :controller_get,
|
|
43
|
+
# We use predefined call to the controller delete
|
|
44
|
+
:delete_e => :controller_delete
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
obj_needs :data, :student_name, :for => [:create_e], :mapping => :name
|
|
48
|
+
end
|
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
app_path = File.dirname(__FILE__)
|
|
19
|
+
|
|
20
|
+
if ENV['LORJ_DEV']
|
|
21
|
+
require 'byebug'
|
|
22
|
+
lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
|
|
23
|
+
$LOAD_PATH << lib_path
|
|
24
|
+
end
|
|
2
25
|
|
|
3
|
-
$APP_PATH = File.dirname(__FILE__)
|
|
4
26
|
require 'lorj'
|
|
5
27
|
|
|
6
|
-
# If you want to see what is happening in the framework, uncomment debug
|
|
7
|
-
#
|
|
8
|
-
|
|
28
|
+
# If you want to see what is happening in the framework, uncomment debug
|
|
29
|
+
# settings.
|
|
30
|
+
PrcLib.level = Logger::DEBUG # Printed out to your console.
|
|
31
|
+
PrcLib.core_level = 3 # framework debug levels.
|
|
9
32
|
|
|
10
33
|
# Initialize the framework
|
|
11
|
-
|
|
34
|
+
processes = [File.join(app_path, 'process', 'students.rb')]
|
|
12
35
|
|
|
13
|
-
|
|
36
|
+
student_core = Lorj::Core.new(nil, processes, :mock)
|
|
14
37
|
|
|
15
38
|
# Ask the framework to create the object student 'Robert Redford'
|
|
16
|
-
|
|
39
|
+
student_core.create(:student, :student_name => 'Robert Redford')
|
|
17
40
|
|
|
18
41
|
# Want to create a duplicated student 'Robert Redford'?
|
|
19
|
-
|
|
42
|
+
student_core.create(:student)
|
|
20
43
|
# no problem. The key is the key in the Mock controller array.
|
|
21
44
|
|
|
22
|
-
|
|
45
|
+
student_core.create(:student, :student_name => 'Anthony Hopkins')
|
|
23
46
|
|
|
24
47
|
# Let's create a third different student.
|
|
25
|
-
|
|
48
|
+
students = student_core.query(:student, :name => 'Robert Redford')
|
|
26
49
|
|
|
27
|
-
puts
|
|
50
|
+
puts format('%s students found', students.length)
|
|
28
51
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
students.each do | a_student |
|
|
53
|
+
puts format('%s: %s', a_student[:id], a_student[:name])
|
|
54
|
+
end
|
|
32
55
|
|
|
33
56
|
# let's check the get function, who is the ID 2?
|
|
34
|
-
|
|
57
|
+
student = student_core.get(:student, 2)
|
|
35
58
|
|
|
36
|
-
puts
|
|
59
|
+
puts format('The student ID 2 is %s', student[:name])
|