Browse code

edgex: new package

This is initial version of EdgeX Go Services.
Extra: Modified consul service file to run it as server.

Change-Id: I6bd3b55cf5d21c0bf6f79dfae11f8d2838c2b27f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5331
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Alexey Makhalov authored on 2018/07/10 09:21:40
Showing 6 changed files
... ...
@@ -4,7 +4,10 @@ Requires=network.target
4 4
 After=network.target
5 5
 
6 6
 [Service]
7
-ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d -dev -advertise 127.0.0.1
7
+ExecStartPre=/usr/bin/rm -rf /var/lib/consul/*
8
+ExecStartPre=/usr/bin/mkdir -p /var/lib/consul/config
9
+ExecStartPre=/usr/bin/mkdir -p /var/lib/consul/data
10
+ExecStart=/usr/bin/consul agent -config-dir=/var/lib/consul/config -data-dir=/var/lib/consul/data -server -client=0.0.0.0 -advertise=127.0.0.1 -bootstrap -ui
8 11
 ExecReload=/usr/bin/kill -HUP $MAINPID
9 12
 KillSignal=SIGINT
10 13
 User=consul
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Consul is a tool for service discovery and configuration.
2 2
 Name:           consul
3 3
 Version:        1.1.0
4
-Release:        1%{?dist}
4
+Release:        2%{?dist}
5 5
 License:        Mozilla Public License, version 2.0
6 6
 Group:          System Environment/Daemons
7 7
 Vendor:         VMware, Inc.
... ...
@@ -101,5 +101,7 @@ rm -rf %{buildroot}
101 101
 %dir %{_sysconfdir}/%{name}.d
102 102
 
103 103
 %changelog
104
-*       Thu Jun 28 2018 Ankit Jain <ankitja@vmware.com> 1.1.0-1
105
--       Initial build.  First version
104
+*  Mon Jul 09 2018 Alexey Makhalov <amakhalov@vmware.com> 1.1.0-2
105
+-  Modify command line parameters in .service file.
106
+*  Thu Jun 28 2018 Ankit Jain <ankitja@vmware.com> 1.1.0-1
107
+-  Initial build.  First version
106 108
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+[Unit]
1
+Description=EdgeX core-config-seed
2
+Requires=network.target
3
+After=network.target consul.service
4
+
5
+[Service]
6
+Type=oneshot
7
+RemainAfterExit=yes
8
+ExecStart=/usr/bin/edgex-core-config-seed
9
+WorkingDirectory=/usr/share/edgex/core-config-seed
10
+
11
+[Install]
12
+WantedBy=multi-user.target
0 13
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+[Unit]
1
+Description=EdgeX SERVICE_NAME
2
+Requires=network.target
3
+After=network.target consul.service edgex-core-config-seed.service
4
+
5
+[Service]
6
+ExecStart=/usr/bin/edgex-SERVICE_NAME -c
7
+ExecReload=/usr/bin/kill -HUP $MAINPID
8
+KillSignal=SIGINT
9
+Restart=on-failure
10
+WorkingDirectory=/var/log/edgex/SERVICE_NAME
11
+
12
+[Install]
13
+WantedBy=multi-user.target
0 14
new file mode 100644
... ...
@@ -0,0 +1,97 @@
0
+%global security_hardening nopie
1
+%define debug_package %{nil}
2
+%define __os_install_post %{nil}
3
+Summary:        EdgeX Foundry Go Services
4
+Name:           edgex
5
+Version:        0.6.0
6
+Release:        1%{?dist}
7
+License:        Apache-2.0
8
+URL:            https://github.com/edgexfoundry/edgex-go
9
+Group:          Applications/System
10
+Vendor:         VMware, Inc.
11
+Distribution:   Photon
12
+# Wait for official release. For now use git archive to createa tarball:
13
+# git config tar.tar.xz.command "xz -c"
14
+# git archive -o edgex-0.6.0-1261522.tar.xz HEAD
15
+Source0:	edgex-0.6.0-1261522.tar.xz
16
+%define sha1 edgex=b91017f85e263af8a7b2e49282c3dbb0048f5b67
17
+# glide installed dependencies all in one tarball generated by:
18
+# tar -cJf glide-tarball-for-edgex-0.6.0-1261522.tar.xz vendor/ glide.lock
19
+Source1:	glide-tarball-for-edgex-0.6.0-1261522.tar.xz
20
+%define sha1 glide-tarball-for-edgex=0f4926ccd32f9db6a69d51db77dc84cad65f5b35
21
+Source2:	core-config-seed-go-0.6.0-a45a3a8.tar.xz
22
+%define sha1 core=0fa76e0fbc2ae12649f3fbdf2f26e83aa261bb64
23
+Source3:	glide-tarball-for-core-config-seed-go-0.6.0-a45a3a8.tar.xz
24
+%define sha1 glide-tarball-for-core=c04b619026be35221ee0500ea0fc30bf18ba3fea
25
+Source4:	edgex-template.service
26
+Source5:	edgex-core-config-seed.service
27
+# Origin https://github.com/edgexfoundry/developer-scripts
28
+Source6:	init_mongo.js
29
+
30
+BuildRequires:  go >= 1.9
31
+BuildRequires:  make
32
+BuildRequires:  systemd-devel
33
+BuildRequires:  zeromq-devel
34
+Requires:       systemd
35
+Requires:       mongodb
36
+Requires:       consul
37
+
38
+%description
39
+EdgeX Foundry Go Services
40
+
41
+%prep
42
+%setup -c -T -a 0 -n src/github.com/edgexfoundry/edgex-go
43
+%setup -D -c -T -a 1 -n src/github.com/edgexfoundry/edgex-go
44
+%setup -D -c -T -a 2 -n src/github.com/edgexfoundry/core-config-seed-go
45
+%setup -D -c -T -a 3 -n src/github.com/edgexfoundry/core-config-seed-go
46
+
47
+%build
48
+cd %{_builddir}/src/github.com/edgexfoundry/edgex-go
49
+GOPATH=%{_builddir} make build %{?_smp_mflags}
50
+
51
+cd %{_builddir}/src/github.com/edgexfoundry/core-config-seed-go
52
+GOPATH=%{_builddir} make build %{?_smp_mflags}
53
+
54
+%install
55
+# edgex-go
56
+cd %{_builddir}/src/github.com/edgexfoundry/edgex-go
57
+
58
+install -d -m755 %{buildroot}%{_bindir}
59
+install -d -m755 %{buildroot}%{_datadir}/%{name}
60
+install -d -m755 %{buildroot}%{_libdir}/systemd/system
61
+
62
+# install binary
63
+for srv in core-command core-data core-metadata export-client export-distro support-logging ; do
64
+install -p -m755 cmd/${srv}/${srv} %{buildroot}%{_bindir}/edgex-${srv}
65
+install -d -m755 %{buildroot}%{_datadir}/%{name}/${srv}/res
66
+install -p -m644 cmd/${srv}/res/configuration.toml %{buildroot}%{_datadir}/%{name}/${srv}/res/configuration.toml
67
+# workdir for the service
68
+install -d -m755 %{buildroot}%{_var}/log/%{name}/${srv}
69
+ln -s %{_datadir}/%{name}/${srv}/res %{buildroot}%{_var}/log/%{name}/${srv}/res
70
+
71
+sed "s/SERVICE_NAME/${srv}/" %{SOURCE4} > %{buildroot}%{_libdir}/systemd/system/edgex-${srv}.service
72
+done
73
+
74
+# core-config-seed-go
75
+cd %{_builddir}/src/github.com/edgexfoundry/core-config-seed-go
76
+install -p -m755 core-config-seed-go %{buildroot}%{_bindir}/edgex-core-config-seed
77
+install -d -m755 %{buildroot}%{_datadir}/%{name}/core-config-seed/res
78
+install -p -m644 res/configuration.toml %{buildroot}%{_datadir}/%{name}/core-config-seed/res/configuration.toml
79
+install -p -m644 res/banner.txt %{buildroot}%{_datadir}/%{name}/core-config-seed/res/banner.txt
80
+cp -a config %{buildroot}%{_datadir}/%{name}/core-config-seed/
81
+install -p -m644 %{SOURCE5} %{buildroot}%{_libdir}/systemd/system/`basename %{SOURCE5}`
82
+
83
+# init mongo script
84
+install -d -m755 %{buildroot}%{_datadir}/%{name}/scripts/
85
+install -p -m644 %{SOURCE6} %{buildroot}%{_datadir}/%{name}/scripts/`basename %{SOURCE6}`
86
+
87
+%files
88
+%defattr(-,root,root)
89
+%{_bindir}/*
90
+%{_datadir}/*
91
+%{_libdir}/*
92
+%{_var}/log/*
93
+
94
+%changelog
95
+*   Fri Jul 06 2018 Alexey Makhalov <amakhalov@vmware.com> 0.6.0-1
96
+-   Initial version
0 97
new file mode 100644
... ...
@@ -0,0 +1,113 @@
0
+//###############################################################################
1
+//# Copyright 2016-2017 Dell Inc.
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
+//###############################################################################
16
+//EdgeX Mongo DB initialization script
17
+//version 1
18
+//author:  Jim White
19
+//Create user for security service in Mongo
20
+db=db.getSiblingDB('admin')
21
+db=db.getSiblingDB('authorization')
22
+db.createUser({ user: "admin",pwd: "password",roles: [ { role: "readWrite", db: "authorization" } ]});
23
+//Create keystore collection
24
+db.createCollection("keyStore");
25
+db.keyStore.insert( { xDellAuthKey: "x-dell-auth-key", secretKey: "EDGEX_SECRET_KEY" } );
26
+//Create Service Mapping
27
+db.createCollection("serviceMapping");
28
+db.serviceMapping.insert( { serviceName: "coredata", serviceUrl: "http://localhost:48080/" });
29
+db.serviceMapping.insert( { serviceName: "metadata", serviceUrl: "http://localhost:48081/" });
30
+db.serviceMapping.insert( { serviceName: "command", serviceUrl: "http://localhost:48082/" });
31
+db.serviceMapping.insert( { serviceName: "rules", serviceUrl: "http://localhost:48084/" });
32
+db.serviceMapping.insert( { serviceName: "notifications", serviceUrl: "http://localhost:48060/" });
33
+db.serviceMapping.insert( { serviceName: "logging", serviceUrl: "http://localhost:48061/" });
34
+
35
+db=db.getSiblingDB('admin')
36
+db.system.users.remove({});
37
+db.system.version.remove({});
38
+db.system.version.insert({ "_id" : "authSchema", "currentVersion" : 3 });
39
+db=db.getSiblingDB('admin')
40
+db.createUser({ user: "admin",
41
+  pwd: "password",
42
+  roles: [
43
+    { role: "readWrite", db: "admin" }
44
+  ]
45
+});
46
+
47
+db=db.getSiblingDB('metadata')
48
+db.createUser({ user: "meta",
49
+  pwd: "password",
50
+  roles: [
51
+    { role: "readWrite", db: "metadata" }
52
+  ]
53
+});
54
+db.createCollection("addressable");
55
+db.addressable.createIndex({name: 1}, {unique: true});
56
+db.createCollection("command");
57
+db.createCollection("device");
58
+db.device.createIndex({name: 1}, {unique: true});
59
+db.createCollection("deviceProfile");
60
+db.deviceProfile.createIndex({name: 1}, {unique: true});
61
+db.createCollection("deviceReport");
62
+db.deviceReport.createIndex({name: 1}, {unique: true});
63
+db.createCollection("deviceService");
64
+db.deviceService.createIndex({name: 1}, {unique: true});
65
+db.createCollection("provisionWatcher");
66
+db.provisionWatcher.createIndex({name: 1}, {unique: true});
67
+db.createCollection("schedule");
68
+db.schedule.createIndex({name: 1}, {unique: true});
69
+db.createCollection("scheduleEvent");
70
+db.scheduleEvent.createIndex({name: 1}, {unique: true});
71
+
72
+db=db.getSiblingDB('coredata')
73
+db.createUser({ user: "core",
74
+  pwd: "password",
75
+  roles: [
76
+    { role: "readWrite", db: "coredata" }
77
+  ]
78
+});
79
+db.createCollection("event");
80
+db.createCollection("reading");
81
+db.createCollection("valueDescriptor");
82
+db.valueDescriptor.createIndex({name: 1}, {unique: true});
83
+
84
+db=db.getSiblingDB('rules_engine_db')
85
+db.createUser({ user: "rules_engine_user",
86
+  pwd: "password",
87
+  roles: [
88
+    { role: "readWrite", db: "rules_engine_db" }
89
+  ]
90
+});
91
+
92
+db=db.getSiblingDB('notifications')
93
+db.createUser({ user: "notifications",
94
+  pwd: "password",
95
+  roles: [
96
+    { role: "readWrite", db: "notifications" }
97
+  ]
98
+});
99
+db.createCollection("notification");
100
+db.createCollection("transmission");
101
+db.createCollection("subscription");
102
+db.notification.createIndex({slug: 1}, {unique: true});
103
+db.subscription.createIndex({slug: 1}, {unique: true});
104
+
105
+db=db.getSiblingDB('logging')
106
+db.createUser({ user: "logging",
107
+  pwd: "password",
108
+  roles: [
109
+    { role: "readWrite", db: "logging" }
110
+  ]
111
+});
112
+db.createCollection("logEntry");