lorj 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.gitreview +4 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +14 -0
- data/README.md +652 -0
- data/Rakefile +24 -0
- data/bin/cloud_test.rb +81 -0
- data/example/students_1/process/Students.rb +20 -0
- data/example/students_1/students.rb +16 -0
- data/example/students_2/process/Students.rb +27 -0
- data/example/students_2/students.rb +36 -0
- data/example/students_3/controller/yaml_students.rb +94 -0
- data/example/students_3/controller/yaml_students_controller.rb +123 -0
- data/example/students_3/process/students.rb +118 -0
- data/example/students_3/students.rb +93 -0
- data/example/students_4/controller/yaml_students.rb +82 -0
- data/example/students_4/controller/yaml_students_controller.rb +141 -0
- data/example/students_4/process/students.rb +112 -0
- data/example/students_4/students.rb +103 -0
- data/example/yaml_students/students.rb +78 -0
- data/example/yaml_students/yaml_students.rb +115 -0
- data/lib/concept.md +111 -0
- data/lib/core/core.rb +723 -0
- data/lib/core/definition.rb +505 -0
- data/lib/core/definition_internal.rb +338 -0
- data/lib/core/lorj-basecontroller.rb +90 -0
- data/lib/core/lorj-basedefinition.rb +1079 -0
- data/lib/core/lorj-baseprocess.rb +231 -0
- data/lib/core/lorj-data.rb +567 -0
- data/lib/core/lorj-keypath.rb +115 -0
- data/lib/core_process/CloudProcess.rb +334 -0
- data/lib/core_process/global_process.rb +406 -0
- data/lib/core_process/network_process.rb +603 -0
- data/lib/img/.directory +4 -0
- data/lib/img/account_data_access.png +0 -0
- data/lib/img/config_data_access.png +0 -0
- data/lib/img/forj-lib-concept.png +0 -0
- data/lib/lorj/version.rb +3 -0
- data/lib/lorj.rb +51 -0
- data/lib/prc-account.rb +339 -0
- data/lib/prc-config.rb +1023 -0
- data/lib/prc-logging.rb +183 -0
- data/lib/prc.rb +108 -0
- data/lib/providers/hpcloud/Hpcloud.rb +419 -0
- data/lib/providers/hpcloud/compute.rb +108 -0
- data/lib/providers/hpcloud/network.rb +117 -0
- data/lib/providers/hpcloud/security_groups.rb +67 -0
- data/lib/providers/mock/Mock.rb +141 -0
- data/lib/providers/openstack/Openstack.rb +47 -0
- data/lib/providers/templates/compute.rb +42 -0
- data/lib/providers/templates/core.rb +61 -0
- data/lib/providers/templates/network.rb +33 -0
- data/lorj-spec/defaults.yaml +26 -0
- data/lorj.gemspec +39 -0
- data/spec/forj-account_spec.rb +75 -0
- data/spec/forj-config_spec.rb +196 -0
- metadata +164 -0
@@ -0,0 +1,108 @@
|
|
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
|
+
module HPCompute
|
18
|
+
def HPCompute.get_server(oComputeConnect, sId)
|
19
|
+
oComputeConnect.servers.get(sId)
|
20
|
+
end
|
21
|
+
|
22
|
+
def HPCompute.query_addresses(oComputeConnect, sQuery)
|
23
|
+
oComputeConnect.addresses.all(sQuery)
|
24
|
+
end
|
25
|
+
|
26
|
+
def HPCompute.query_server(oComputeConnect, sQuery)
|
27
|
+
oComputeConnect.servers.all(sQuery)
|
28
|
+
end
|
29
|
+
|
30
|
+
def HPCompute.query_image(oComputeConnect, sQuery)
|
31
|
+
# HP Fog query is exact matching. No way to filter with a Regexp
|
32
|
+
# Testing it and filtering it.
|
33
|
+
# TODO: Be able to support Regexp in queries then extract all and filter.
|
34
|
+
oComputeConnect.images.all(sQuery)
|
35
|
+
end
|
36
|
+
|
37
|
+
def HPCompute.query_flavor(oComputeConnect, sQuery)
|
38
|
+
oComputeConnect.flavors.all(sQuery)
|
39
|
+
end
|
40
|
+
|
41
|
+
def HPCompute.create_server(oComputeConnect,
|
42
|
+
sServerName, oSecurity_groups,
|
43
|
+
oImage, oNetwork,
|
44
|
+
oFlavor, oKeypairs,
|
45
|
+
oUser_data, oMeta_data)
|
46
|
+
|
47
|
+
options = {
|
48
|
+
:name => sServerName,
|
49
|
+
:flavor_id => oFlavor.id,
|
50
|
+
:image_id => oImage.id,
|
51
|
+
:key_name => oKeypairs.name,
|
52
|
+
:security_groups => [oSecurity_groups.name],
|
53
|
+
:networks => [oNetwork.id]
|
54
|
+
}
|
55
|
+
options[:user_data_encoded] = Base64.strict_encode64(oUser_data) if oUser_data
|
56
|
+
options[:metadata] = oMeta_data if oMeta_data
|
57
|
+
server = oComputeConnect.servers.create(options)
|
58
|
+
HPCompute.get_server(oComputeConnect, server.id ) if server
|
59
|
+
end
|
60
|
+
|
61
|
+
def HPCompute.query_server_assigned_addresses(oComputeConnect, oServer, sQuery)
|
62
|
+
# CloudProcess used a simplified way to manage IPs.
|
63
|
+
# Following is the translation to get the public IPs for the server
|
64
|
+
|
65
|
+
result = []
|
66
|
+
oAddresses = oComputeConnect.addresses.all()
|
67
|
+
oAddresses.each { | oElem |
|
68
|
+
bFound = true
|
69
|
+
sQuery.each { | key, value |
|
70
|
+
if not oElem.attributes.key?(key) or oElem.attributes[key] != value
|
71
|
+
bFound = false
|
72
|
+
break
|
73
|
+
end
|
74
|
+
}
|
75
|
+
result << oElem if bFound
|
76
|
+
}
|
77
|
+
result
|
78
|
+
end
|
79
|
+
|
80
|
+
def HPCompute.server_assign_address(oComputeConnect, oServer)
|
81
|
+
|
82
|
+
while oServer.state != 'ACTIVE'
|
83
|
+
sleep(5)
|
84
|
+
oServer = oComputeConnect.servers.get(oServer.id)
|
85
|
+
end
|
86
|
+
|
87
|
+
oAddresses = oComputeConnect.addresses.all()
|
88
|
+
oAddress = nil
|
89
|
+
# Search for an available IP
|
90
|
+
oAddresses.each { | oElem |
|
91
|
+
if oElem.fixed_ip.nil?
|
92
|
+
oAddress = oElem
|
93
|
+
break
|
94
|
+
end
|
95
|
+
}
|
96
|
+
|
97
|
+
if oAddress.nil?
|
98
|
+
# Create a new public IP to add in the pool.
|
99
|
+
oAddress = oComputeConnect.addresses.create
|
100
|
+
end
|
101
|
+
raise "No Public IP to assign to server '%s'" % oServer.name if oAddress.nil?
|
102
|
+
oAddress.server = oServer # associate the server
|
103
|
+
oAddress.reload
|
104
|
+
# This function needs to returns a list of object.
|
105
|
+
# This list must support the each function.
|
106
|
+
oAddress
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,117 @@
|
|
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
|
+
|
18
|
+
module HPNetwork
|
19
|
+
# Network driver
|
20
|
+
def HPNetwork.query_network(oNetworkConnect, sQuery)
|
21
|
+
oNetworkConnect.networks.all(sQuery)
|
22
|
+
end
|
23
|
+
|
24
|
+
def HPNetwork.create_network(oNetworkConnect, name)
|
25
|
+
oNetworkConnect.networks.create(:name => name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def HPNetwork.delete_network(oNetworkConnect, oNetwork)
|
29
|
+
oNetworkConnect.networks.get(oNetwork.id).destroy
|
30
|
+
end
|
31
|
+
|
32
|
+
# SubNetwork driver
|
33
|
+
def HPNetwork.query_subnetwork(oNetworkConnect, sQuery)
|
34
|
+
oNetworkConnect.subnets.all(sQuery)
|
35
|
+
end
|
36
|
+
|
37
|
+
def HPNetwork.create_subnetwork(oNetworkConnect, oNetwork, name)
|
38
|
+
oNetworkConnect.subnets.create(
|
39
|
+
:network_id => oNetwork.id,
|
40
|
+
:name => name,
|
41
|
+
:cidr => get_next_subnet(oNetworkConnect),
|
42
|
+
:ip_version => '4'
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def HPNetwork.delete_subnetwork(oNetworkConnect, oSubNetwork)
|
47
|
+
oNetworkConnect.subnets.get(oSubNetwork.id).destroy
|
48
|
+
end
|
49
|
+
|
50
|
+
def HPNetwork.get_next_subnet(oNetworkConnect)
|
51
|
+
begin
|
52
|
+
subnet_values = Array.new
|
53
|
+
subnets = oNetworkConnect.subnets.all
|
54
|
+
|
55
|
+
subnets.each do|s|
|
56
|
+
subnet_values.push(s.cidr)
|
57
|
+
end
|
58
|
+
|
59
|
+
gap = false
|
60
|
+
count = 0
|
61
|
+
range_used = Array.new
|
62
|
+
new_subnet = 0
|
63
|
+
new_cidr = ''
|
64
|
+
|
65
|
+
subnet_values = subnet_values.sort!
|
66
|
+
|
67
|
+
subnet_values.each do|value|
|
68
|
+
range_used.push(value[5])
|
69
|
+
end
|
70
|
+
|
71
|
+
range_used.each do |n|
|
72
|
+
if count.to_i == n.to_i
|
73
|
+
else
|
74
|
+
new_subnet = count
|
75
|
+
gap = true
|
76
|
+
break
|
77
|
+
end
|
78
|
+
count += 1
|
79
|
+
end
|
80
|
+
|
81
|
+
if gap
|
82
|
+
new_cidr = '10.0.%s.0/24' % [count]
|
83
|
+
else
|
84
|
+
max_value = range_used.max
|
85
|
+
new_subnet = max_value.to_i + 1
|
86
|
+
new_cidr = '10.0.%s.0/24' % [new_subnet]
|
87
|
+
end
|
88
|
+
new_cidr
|
89
|
+
rescue => e
|
90
|
+
Logging.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# router driver
|
95
|
+
def HPNetwork.query_router(oNetworkConnect, sQuery)
|
96
|
+
oNetworkConnect.routers.all(sQuery)
|
97
|
+
end
|
98
|
+
|
99
|
+
def HPNetwork.update_router(oRouters)
|
100
|
+
oRouters.save
|
101
|
+
end
|
102
|
+
|
103
|
+
def HPNetwork.create_router(oNetwork, hOptions)
|
104
|
+
oNetwork.routers.create(hOptions)
|
105
|
+
end
|
106
|
+
|
107
|
+
# router interface
|
108
|
+
|
109
|
+
def HPNetwork.add_interface(oRouter, oSubNetwork)
|
110
|
+
oRouter.add_interface(oSubNetwork.id, nil)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Port driver
|
114
|
+
def HPNetwork.query_port(oNetworkConnect, sQuery)
|
115
|
+
oNetworkConnect.ports.all(sQuery)
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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
|
+
module HPSecurityGroups
|
18
|
+
def HPSecurityGroups.query_sg(oNetworkConnect, sQuery)
|
19
|
+
oNetworkConnect.security_groups.all(sQuery)
|
20
|
+
end
|
21
|
+
|
22
|
+
def HPSecurityGroups.create_sg(oNetwork, name, description)
|
23
|
+
params = {:name => name}
|
24
|
+
params[:description] = description if description
|
25
|
+
oNetwork.security_groups.create( params )
|
26
|
+
end
|
27
|
+
|
28
|
+
def HPSecurityGroups.create_rule(oNetwork, hData)
|
29
|
+
oNetwork.security_group_rules.create( hData )
|
30
|
+
end
|
31
|
+
|
32
|
+
def HPSecurityGroups.query_rule(oNetwork, sQuery)
|
33
|
+
oNetwork.security_group_rules.all(sQuery)
|
34
|
+
end
|
35
|
+
|
36
|
+
def HPSecurityGroups.delete_rule(oNetwork, rule_id)
|
37
|
+
oNetwork.security_group_rules.get(rule_id).destroy
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module HPKeyPairs
|
42
|
+
def HPKeyPairs.query_keypair(oComputeConnect, sQuery)
|
43
|
+
cKeyPairs = oComputeConnect.key_pairs.all()
|
44
|
+
aResults = []
|
45
|
+
cKeyPairs.each { |sElem|
|
46
|
+
bSelect = true
|
47
|
+
attributes = sElem.instance_variable_get(:@attributes)
|
48
|
+
sQuery.each { | key, value |
|
49
|
+
if attributes[key] != value
|
50
|
+
bSelect = false
|
51
|
+
break
|
52
|
+
end
|
53
|
+
}
|
54
|
+
aResults.push sElem if bSelect
|
55
|
+
}
|
56
|
+
aResults
|
57
|
+
end
|
58
|
+
|
59
|
+
def HPKeyPairs.get_keypair(oComputeConnect, sId)
|
60
|
+
#byebug
|
61
|
+
oComputeConnect.key_pairs.get(sId)
|
62
|
+
end
|
63
|
+
|
64
|
+
def HPKeyPairs.create_keypair(oComputeConnect, name, pubkey)
|
65
|
+
oComputeConnect.key_pairs.create( :name => name, :public_key => pubkey)
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,141 @@
|
|
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
|
+
|
18
|
+
# This class describes how to process some actions, and will do everything prior
|
19
|
+
# this task to make it to work.
|
20
|
+
|
21
|
+
# This Mock controller keep the data in memory in hash/Array data.
|
22
|
+
|
23
|
+
class Mock
|
24
|
+
# mock do not need to use any mapping. It adapts itself to what the process has defined.
|
25
|
+
end
|
26
|
+
|
27
|
+
class MockController
|
28
|
+
|
29
|
+
@@data = {}
|
30
|
+
|
31
|
+
def create(sObjectType, hParams)
|
32
|
+
PrcLib::debug("Mock: create object '%s' with parameters (hdata) '%s'" % [sObjectType, hParams[:hdata]])
|
33
|
+
|
34
|
+
result = {}
|
35
|
+
hParams[].keys.each { |key|
|
36
|
+
next if key == :hdata
|
37
|
+
result[key] = hParams[key]
|
38
|
+
}
|
39
|
+
result.merge!(hParams[:hdata])
|
40
|
+
|
41
|
+
unless @@data.key?(sObjectType)
|
42
|
+
@@data[sObjectType] = []
|
43
|
+
end
|
44
|
+
aArr = @@data[sObjectType]
|
45
|
+
|
46
|
+
aArr.each { | value |
|
47
|
+
raise if value.key?(result[:name])
|
48
|
+
}
|
49
|
+
aArr << result
|
50
|
+
|
51
|
+
result[:id] = aArr.length()-1
|
52
|
+
|
53
|
+
# Typical code:
|
54
|
+
#~ case sObjectType
|
55
|
+
#~ when :public_ip
|
56
|
+
# Following function can be executed to ensure the object :connection exists.
|
57
|
+
#~ required?(hParams, :connection)
|
58
|
+
#~ required?(hParams, :server)
|
59
|
+
#~ ... CODE to create
|
60
|
+
#~ else
|
61
|
+
#~ Error "'%s' is not a valid object for 'create'" % sObjectType
|
62
|
+
#~ end
|
63
|
+
# The code should return some data
|
64
|
+
# This data will be encapsulated in Lorj::Data object.
|
65
|
+
# data will be extracted by the framework with the controller get_attr function and mapped.
|
66
|
+
PrcLib::debug("Mock: object '%s' = '%s' is created." % [sObjectType, result])
|
67
|
+
result
|
68
|
+
end
|
69
|
+
|
70
|
+
# This function return a collection which have to provide:
|
71
|
+
# functions: [], length, each
|
72
|
+
# Used by network process.
|
73
|
+
def query(sObjectType, sQuery, hParams)
|
74
|
+
PrcLib::debug("Mock: query object '%s' with hdata '%s' using query '%s'" % [sObjectType, hParams[:hdata], sQuery])
|
75
|
+
|
76
|
+
return [] unless @@data.key?(sObjectType)
|
77
|
+
|
78
|
+
result = []
|
79
|
+
|
80
|
+
@@data[sObjectType].each { | value |
|
81
|
+
hElem = value
|
82
|
+
sQuery.each { | query_key, query_value |
|
83
|
+
hElem = nil if not value.key?(query_key) or value[query_key] != query_value
|
84
|
+
}
|
85
|
+
result << hElem if hElem
|
86
|
+
}
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
def delete(sObjectType, hParams)
|
91
|
+
PrcLib::debug("Mock: delete object '%s' with hdata '%s'" % [sObjectType, hParams[:hdata]])
|
92
|
+
return nil unless @@data.key?(sObjectType)
|
93
|
+
|
94
|
+
return false if not hParams.exist?(sObjectType) or hParams[sObjectType].nil?
|
95
|
+
@@data[sObjectType].delete(hParams[sObjectType])
|
96
|
+
PrcLib::debug("Mock: object '%s' = '%s' is deleted." % [sObjectType, hParams[sObjectType]])
|
97
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
def get(sObjectType, sUniqId, hParams)
|
101
|
+
PrcLib::debug("Mock: Get object '%s' = '%s' with hdata '%s'" % [sObjectType, sUniqId, hParams[:hdata]])
|
102
|
+
return nil unless @@data.key?(sObjectType)
|
103
|
+
@@data[sObjectType][sUniqId]
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_attr(oControlerObject, key)
|
107
|
+
# This controller function read the data and
|
108
|
+
# extract the information requested by the framework.
|
109
|
+
# Those data will be mapped to the process data model.
|
110
|
+
# The key is an array, to get data from a level tree.
|
111
|
+
# [data_l1, data_l2, data_l3] => should retrieve data from structure like data[ data_l2[ data_l3 ] ]
|
112
|
+
begin
|
113
|
+
attributes = oControlerObject
|
114
|
+
# raise "attribute '%s' is unknown in '%s'. Valid one are : '%s'" % [key[0], oControlerObject.class, oControlerObject.keys ] unless oControlerObject.include?(key[0])
|
115
|
+
Lorj::rhGet(attributes, key)
|
116
|
+
rescue => e
|
117
|
+
Error "Unable to map '%s'. %s" % [key, e.message]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def set_attr(oControlerObject, key, value)
|
122
|
+
begin
|
123
|
+
attributes = oControlerObject
|
124
|
+
# raise "attribute '%s' is unknown in '%s'. Valid one are : '%s'" % [key[0], oControlerObject.class, oControlerObject.keys ] unless oControlerObject.include?(key[0])
|
125
|
+
Lorj::rhSet(attributes, value, key)
|
126
|
+
rescue => e
|
127
|
+
Error "Unable to map '%s' on '%s'" % [key, sObjectType]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
def update(sObjectType, oObject, hParams)
|
133
|
+
PrcLib::debug("Mock: Update object '%s' = '%s' with hdata '%s'" % [sObjectType, sUniqId, hParams[:hdata]])
|
134
|
+
return false unless @@data.key?(sObjectType)
|
135
|
+
|
136
|
+
return false unless @@data[sObjectType][oObject[:id]].nil?
|
137
|
+
# Considered hash object is already updated.
|
138
|
+
# This action emule the object save which doesn't make sense in this empty Mock controller.
|
139
|
+
true
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
|
18
|
+
# This class describes how to process some actions, and will do everything prior
|
19
|
+
# this task to make it to work.
|
20
|
+
|
21
|
+
|
22
|
+
class Openstack < BaseDefinition
|
23
|
+
def initialize()
|
24
|
+
superclass.provides([:compute, :network])
|
25
|
+
end
|
26
|
+
|
27
|
+
def compute()
|
28
|
+
Fog::Compute.new({
|
29
|
+
:provider => :openstack,
|
30
|
+
:openstack_api_key => superclass.oForjAccount.get(:account_id),
|
31
|
+
:openstack_username => superclass.oForjAccount.get(:account_key),
|
32
|
+
:openstack_auth_url => superclass.oForjAccount.get(:auth_uri),
|
33
|
+
:openstack_tenant => superclass.oForjAccount.get(:tenant_id),
|
34
|
+
:openstack_region => superclass.oForjAccount.get(:compute)
|
35
|
+
})
|
36
|
+
end
|
37
|
+
def network()
|
38
|
+
Fog::Network.new({
|
39
|
+
:provider => :openstack,
|
40
|
+
:openstack_api_key => superclass.oForjAccount.get(:account_id),
|
41
|
+
:openstack_username => superclass.oForjAccount.get(:account_key),
|
42
|
+
:openstack_auth_url => superclass.oForjAccount.get(:auth_uri),
|
43
|
+
:openstack_tenant => superclass.oForjAccount.get(:tenant_id),
|
44
|
+
:openstack_region => superclass.oForjAccount.get(:network)
|
45
|
+
})
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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
|
+
# This file is given as an example.
|
18
|
+
|
19
|
+
class Mycloud # This class is automatically derived from ForjCloudBase and ForjProcess
|
20
|
+
|
21
|
+
def provider_compute_new
|
22
|
+
# My fog connection
|
23
|
+
# hget_cloudObjMapping() is a ForjCloudBase function which will build a
|
24
|
+
# hash from data required with needed mapped keys(see core.rb)
|
25
|
+
Fog::Compute.new({:provider => :mycloud}.merge(hget_cloudObjMapping()))
|
26
|
+
|
27
|
+
# If you do not want to get data mapped automatically, you can use
|
28
|
+
# @oForjAccount.get()
|
29
|
+
# This means in following declaration in your core.rb:
|
30
|
+
# obj_needs(:data, :<CloudDataKey},{:mapping => :<MyCloudKeyMapped>})
|
31
|
+
# can be updated by removing the mapping => <Value>
|
32
|
+
Fog::Compute.new({
|
33
|
+
:provider => :mycloud,
|
34
|
+
:user => @oForjAccount.get(:account_id),
|
35
|
+
:pwd => @oForjAccount.get(:account_key),
|
36
|
+
:auth_uri => @oForjAccount.get(:auth_uri),
|
37
|
+
:project => @oForjAccount.get(:tenant),
|
38
|
+
:compute_service => @oForjAccount.get(:compute),
|
39
|
+
})
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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
|
+
|
18
|
+
# This file is given as an example.
|
19
|
+
|
20
|
+
require File.join($PROVIDER_PATH, "compute.rb")
|
21
|
+
require File.join($PROVIDER_PATH, "network.rb")
|
22
|
+
|
23
|
+
# Defines Meta MyCloud object
|
24
|
+
class Mycloud
|
25
|
+
|
26
|
+
# Defines Object structure and function stored on the Hpcloud class object.
|
27
|
+
|
28
|
+
# ForjCloud has a list of predefined object, like compute_connection, network, ...
|
29
|
+
# See lib/providers/core/cloud_data_pref.rb
|
30
|
+
|
31
|
+
# Compute Object
|
32
|
+
define_obj :compute_connection
|
33
|
+
# Defines Data used by compute.
|
34
|
+
obj_needs(:data, :account_id, { :mapping => :user})
|
35
|
+
obj_needs(:data, :account_key, { :mapping => :pwd})
|
36
|
+
obj_needs(:data, :auth_uri, { :mapping => :auth_uri})
|
37
|
+
obj_needs(:data, :tenant, { :mapping => :project})
|
38
|
+
obj_needs(:data, :compute, { :mapping => :compute_service})
|
39
|
+
|
40
|
+
define_obj :network_connection
|
41
|
+
obj_needs(:data, :account_id, { :mapping => :user})
|
42
|
+
obj_needs(:data, :account_key, { :mapping => :pwd})
|
43
|
+
obj_needs(:data, :auth_uri, { :mapping => :auth_uri})
|
44
|
+
obj_needs(:data, :tenant, { :mapping => :project})
|
45
|
+
obj_needs(:data, :network, { :mapping => :network_service})
|
46
|
+
|
47
|
+
define_obj :network
|
48
|
+
obj_needs(:CloudObject, :network_connection)
|
49
|
+
obj_needs(:data, :network_name)
|
50
|
+
|
51
|
+
# defines setup Cloud data
|
52
|
+
# This definition is required only if you need to change the predefined data.
|
53
|
+
# To get details on what kind of parameters can be applied to a CloudData, see lib/defaults.yaml
|
54
|
+
define_data(:account_id, {:provisioned_by => :setup, :desc => 'MyCloud username'})
|
55
|
+
define_data(:account_key, {:provisioned_by => :setup, :desc => 'HPCloud secret Key'})
|
56
|
+
define_data(:auth_uri, {:provisioned_by => :setup, :desc => 'HPCloud Authentication service URL'})
|
57
|
+
define_data(:tenant, {:provisioned_by => :setup, :desc => 'HPCloud Tenant ID'})
|
58
|
+
define_data(:compute, {:provisioned_by => :setup, :desc => 'HPCloud Compute service zone (Ex: region-a.geo-1)'})
|
59
|
+
define_data(:network, {:provisioned_by => :setup, :desc => 'HPCloud Network service zone (Ex: region-a.geo-1)'})
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
# This file is given as an example.
|
18
|
+
|
19
|
+
class Mycloud # This class is automatically derived from ForjCloudBase and ForjProcess
|
20
|
+
|
21
|
+
def provider_network_new
|
22
|
+
Fog::Network.new({:provider => :mycloud}.merge(hget_cloudObjMapping()))
|
23
|
+
end
|
24
|
+
|
25
|
+
def provider_query_network(oNetwork, name)
|
26
|
+
oNetwork.networks.all(:name => name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def provider_create_network(oNetwork, name)
|
30
|
+
oNetwork.networks.create(:name => name)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# (c) Copyright 2014 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
|
+
# Defaults yaml file used for rspec.
|
16
|
+
:default:
|
17
|
+
:maestro_url: http://example.org
|
18
|
+
|
19
|
+
:description:
|
20
|
+
:FORJ_HPC: Testing extra application default value.
|
21
|
+
|
22
|
+
:sections:
|
23
|
+
:credentials:
|
24
|
+
:keypair_name:
|
25
|
+
:maestro:
|
26
|
+
:maestro_url:
|
data/lorj.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lorj/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lorj"
|
8
|
+
spec.version = Lorj::VERSION
|
9
|
+
spec.authors = ["forj team"]
|
10
|
+
spec.email = ["forj@forj.io"]
|
11
|
+
spec.summary = %q{Process Controllers framework system}
|
12
|
+
spec.description = %q{Framework to create/maintain uniform process, against any kind of controller.}
|
13
|
+
spec.homepage = "https://github.com/forj-oss/lorj"
|
14
|
+
spec.license = "Apache License, Version 2.0."
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
24
|
+
spec.rdoc_options << '--title' << 'Lorj - The Process Controllers framework system' <<
|
25
|
+
'--main' << 'README.md'
|
26
|
+
|
27
|
+
# spec.add_runtime_dependency 'thor', '~>0.16.0'
|
28
|
+
# spec.add_runtime_dependency 'nokogiri', '~>1.5.11'
|
29
|
+
# spec.add_runtime_dependency 'fog', '~>1.19.0'
|
30
|
+
# spec.add_runtime_dependency 'hpcloud', '~>2.0.9'
|
31
|
+
# spec.add_runtime_dependency 'git', '>=1.2.7'
|
32
|
+
# spec.add_runtime_dependency 'rbx-require-relative', '~>0.0.7'
|
33
|
+
# spec.add_runtime_dependency 'highline', '~> 1.6.21'
|
34
|
+
spec.add_runtime_dependency 'ansi', '>= 1.4.3'
|
35
|
+
# spec.add_runtime_dependency 'bundler'
|
36
|
+
# spec.add_runtime_dependency 'encryptor', '1.3.0'
|
37
|
+
# spec.add_runtime_dependency 'json', '1.7.5'
|
38
|
+
|
39
|
+
end
|