add samples for edge-orchestration depending on archi 94/214594/1 accepted/tizen/unified/20190925.033659 submit/tizen/20190924.085251
authorwansu.yoo <wansu.yoo@samsung.com>
Tue, 24 Sep 2019 08:04:47 +0000 (17:04 +0900)
committerwansu.yoo <wansu.yoo@samsung.com>
Tue, 24 Sep 2019 08:07:32 +0000 (17:07 +0900)
Change-Id: I8c5c5fa1f79fecf55a5d9797c332c403fee317bd
Signed-off-by: wansu.yoo <wansu.yoo@samsung.com>
Makefile
libedge-orchestration/Makefile
libedge-orchestration/sample/Renderer/Renderer.conf [new file with mode: 0644]
libedge-orchestration/sample/main_android.c [new file with mode: 0644]
libedge-orchestration/sample/main_chrome.c
libedge-orchestration/sample/main_container.c [new file with mode: 0644]
packaging/edge-orchestration.spec

index 3e78d19..f3a8b7b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,10 @@ LIBSCORE_SAMPLE_2                    := myscoring2
 LIBSCORE_SAMPLE_2_CONF         := myscoring2.conf
 LIBSCORE_SAMPLE_2_DIR          := $(LIBPKG_SAMPLE_DIR)/$(LIBSCORE_SAMPLE_2)
 
+LIBSCORE_SAMPLE_3                      := Renderer
+LIBSCORE_SAMPLE_3_CONF         := Renderer.conf
+LIBSCORE_SAMPLE_3_DIR          := $(LIBPKG_SAMPLE_DIR)/$(LIBSCORE_SAMPLE_3)
+
 TARGET_LIBSCORE_DIR                    := /etc/edge-orchestration/apps
 
 
@@ -65,6 +69,8 @@ install:
        install -m 755 $(CMAIN_BIN_DIR)/$(CMAIN_BIN_FILE) $(DESTDIR)/usr/bin/$(CMAIN_BIN_FILE)
        install -m 755 $(LIBPKG_SAMPLE_DIR)/output/orchestration_sample $(DESTDIR)/usr/bin/orchestration_sample
        install -m 755 $(LIBPKG_SAMPLE_DIR)/output/orchestration_chrome_sample $(DESTDIR)/usr/bin/orchestration_chrome_sample
+       install -m 755 $(LIBPKG_SAMPLE_DIR)/output/orchestration_container_sample $(DESTDIR)/usr/bin/orchestration_container_sample
+       install -m 755 $(LIBPKG_SAMPLE_DIR)/output/orchestration_android_sample $(DESTDIR)/usr/bin/orchestration_android_sample
        install -m 644 $(BASE_DIR)/$(SERVICE_FILE) $(DESTDIR)/usr/lib/systemd/system/$(SERVICE_FILE)
        ln -s ../$(SERVICE_FILE) $(DESTDIR)/usr/lib/systemd/system/multi-user.target.wants/
 
@@ -81,8 +87,10 @@ install:
 
        install -d $(DESTDIR)/$(TARGET_LIBSCORE_DIR)/$(LIBSCORE_SAMPLE)
        install -d $(DESTDIR)/$(TARGET_LIBSCORE_DIR)/$(LIBSCORE_SAMPLE_2)
+       install -d $(DESTDIR)/$(TARGET_LIBSCORE_DIR)/$(LIBSCORE_SAMPLE_3)
        install -m 644 $(LIBSCORE_SAMPLE_DIR)/$(LIBSCORE_SAMPLE_CONF) $(DESTDIR)/$(TARGET_LIBSCORE_DIR)/$(LIBSCORE_SAMPLE)/
        install -m 644 $(LIBSCORE_SAMPLE_2_DIR)/$(LIBSCORE_SAMPLE_2_CONF) $(DESTDIR)/$(TARGET_LIBSCORE_DIR)/$(LIBSCORE_SAMPLE_2)/
+       install -m 644 $(LIBSCORE_SAMPLE_3_DIR)/$(LIBSCORE_SAMPLE_3_CONF) $(DESTDIR)/$(TARGET_LIBSCORE_DIR)/$(LIBSCORE_SAMPLE_3)/
 
 ## c test and coverage
 test:
index a3b0a2f..f5be7df 100644 (file)
@@ -24,6 +24,8 @@ build-sample: build
        mkdir -p $(SAMPLE_DIR)/output
        $(CC) -Wall -fPIE -pie $(SAMPLE_DIR)/main.c -o $(SAMPLE_DIR)/output/orchestration_sample -I$(INC_DIR) -L$(LIB_DIR) -lorchestration-client `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0`
        $(CC) -Wall -fPIE -pie $(SAMPLE_DIR)/main_chrome.c -o $(SAMPLE_DIR)/output/orchestration_chrome_sample -I$(INC_DIR) -L$(LIB_DIR) -lorchestration-client `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0`
+       $(CC) -Wall -fPIE -pie $(SAMPLE_DIR)/main_container.c -o $(SAMPLE_DIR)/output/orchestration_container_sample -I$(INC_DIR) -L$(LIB_DIR) -lorchestration-client `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0`
+       $(CC) -Wall -fPIE -pie $(SAMPLE_DIR)/main_android.c -o $(SAMPLE_DIR)/output/orchestration_android_sample -I$(INC_DIR) -L$(LIB_DIR) -lorchestration-client `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0`
        -rm -f ./sample/*.o
 
 build:
diff --git a/libedge-orchestration/sample/Renderer/Renderer.conf b/libedge-orchestration/sample/Renderer/Renderer.conf
new file mode 100644 (file)
index 0000000..e638be0
--- /dev/null
@@ -0,0 +1,9 @@
+# Description of service that will be requested
+[Version]
+ConfVersion=v0.0                                        ; Version of Configuration file
+
+[ServiceInfo]
+ServiceName=Renderer                              ; Name of distributed service
+
+[ScoringMethod]
+IntervalTimeMs=1000                                     ; Interval time of get resource
diff --git a/libedge-orchestration/sample/main_android.c b/libedge-orchestration/sample/main_android.c
new file mode 100644 (file)
index 0000000..2114f05
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright 2019 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************/
+
+#include <stdio.h>
+#include <orchestration_client.h>
+
+#define SERVICE_NAME "Renderer"
+#define PACKAGE_NAME "com.samsung.renderer.sample/com.samsung.renderer.sample.MainActivity"
+
+void status_cb(orchestration_service_status_e staus, void* user_data)
+{
+
+}
+
+int main() {
+    orchestration_service_info_s service_info;
+    service_info.count = 1;
+    service_info.services[0].exec_type = "android";
+    service_info.services[0].exec_parameter = PACKAGE_NAME;
+    orchestration_request_service(SERVICE_NAME, service_info, status_cb, NULL);
+    return 0;
+}
\ No newline at end of file
index 420b15a..6b63fc3 100644 (file)
 #include <net/if.h>
 #include <arpa/inet.h>
 
+#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+
 int get_ip_addr(char ipstr[40]) {
     int fd;
     struct ifreq ifr;
-    char *addr;
+    char *addr = {0, };
 
     fd = socket(AF_INET, SOCK_DGRAM, 0);
     ifr.ifr_addr.sa_family = AF_INET;
@@ -41,7 +44,7 @@ int get_ip_addr(char ipstr[40]) {
     close(fd);
 
     addr = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
-    strncpy(ipstr, addr, strlen(addr));
+    strncpy(ipstr, addr, MIN(strlen(addr), 40 - 1));
     return 0;
 }
 
@@ -51,7 +54,7 @@ void status_cb(orchestration_service_status_e staus, void* user_data)
 }
 
 int main() {
-    char command[256] = "/usr/share/chromium-efl/bin/efl_webprocess --type=renderer --enable-castanets=";
+    char command[256] = "/usr/bin/efl_webprocess --type=renderer --enable-castanets=";
     char ipstr[40] = {0, };
     if (get_ip_addr(ipstr) != 0) {
         printf("error from getting ip addr\n");
diff --git a/libedge-orchestration/sample/main_container.c b/libedge-orchestration/sample/main_container.c
new file mode 100644 (file)
index 0000000..96de957
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2019 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************/
+
+#include <stdio.h>
+#include <orchestration_client.h>
+
+void status_cb(orchestration_service_status_e staus, void* user_data)
+{
+
+}
+
+int main() {
+    orchestration_service_info_s service_info;
+    service_info.count = 1;
+    service_info.services[0].exec_type = "container";
+    service_info.services[0].exec_parameter = "docker run hello-world";
+    orchestration_request_service("hello", service_info, status_cb, NULL);
+    return 0;
+}
\ No newline at end of file
index b37efad..3c57fdd 100644 (file)
@@ -120,5 +120,9 @@ systemctl restart %{name}
 # orchestration sample
 %attr(755,system_fw,system_fw)%{_bindir}/orchestration_sample
 %attr(755,system_fw,system_fw)%{_bindir}/orchestration_chrome_sample
+%attr(755,system_fw,system_fw)%{_bindir}/orchestration_container_sample
+%attr(755,system_fw,system_fw)%{_bindir}/orchestration_android_sample
 %attr(755,system_fw,system_fw)%{_sysconfdir}/%{name}/apps/myscoring/*
 %attr(755,system_fw,system_fw)%{_sysconfdir}/%{name}/apps/myscoring2/*
+%attr(755,system_fw,system_fw)%{_sysconfdir}/%{name}/apps/Renderer/*
+