rabbah closed pull request #3145: Support CLI for s390x linux
URL: https://github.com/apache/incubator-openwhisk/pull/3145
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 5cde947173..ffe752b313 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -179,7 +179,7 @@ nginx:
confdir: "{{ config_root_dir }}/nginx"
dir:
become: "{{ nginx_dir_become | default(false) }}"
- version: 1.11
+ version: "{{ nginx_version | default(1.11) }}"
port:
http: 80
api: 443
@@ -321,18 +321,16 @@ openwhisk_cli:
dest_name: OpenWhisk_CLI
location:
"https://github.com/apache/incubator-openwhisk-cli/releases/download/{{
openwhisk_cli_tag }}"
-# The list of operating systems for which openwhisk cli binaries are
downloaded,
+# The list of operating systems and architectures for which openwhisk cli
binaries are downloaded,
# if the installation_mode is remote.
-cli_os:
- - linux
- - mac
- - windows
-
-# The list of architectures for which openwhisk cli binaries are downloaded,
-# if the installation_mode is remote.
-cli_arch:
- - amd64
- - 386
+cli_os_arch:
+ - [ "linux", "amd64" ]
+ - [ "linux", "386" ]
+ - [ "linux", "s390x" ]
+ - [ "mac", "amd64" ]
+ - [ "mac", "386" ]
+ - [ "windows", "amd64" ]
+ - [ "windows", "386" ]
# Controls access to log directories
logs:
diff --git a/ansible/roles/cli/files/createContentJson.sh
b/ansible/roles/cli/files/createContentJson.sh
index 9f0c492c79..7942adf96f 100755
--- a/ansible/roles/cli/files/createContentJson.sh
+++ b/ansible/roles/cli/files/createContentJson.sh
@@ -35,35 +35,45 @@ get_binary_path() {
create_cli_packages() {
local dirIndex="{\"cli\":{"
- for platform in $platforms; do
- dirIndex="$dirIndex\"$platform\":{"
+ # I'm making a nasty assumption here that it's sorted by platforms
+ old_platform='' # Not really necessary, but here to be explicit &
transparent
+ for platform_arch in $platforms; do
- for arch in $archs; do
- comp_name=$(get_compressed_name $platform $arch $zip_name)
- comp_path=$(get_binary_path $comp_name $platform $arch)
+ IFS="," read platform arch <<<"${platform_arch}"
- if [ $arch = $default_arch ]; then
- dirIndex="$dirIndex\"default\":{\"path\":\"$comp_path\"},";
+ # Control-break processing for platform changes
+ if [ "$platform" != "$old_platform" ]; then
+ if [ "$old_platform" != "" ]; then
+ dirIndex="${dirIndex%','}" # Remove trailing comma
+ dirIndex+="}," # And replace with end-brace comma
fi
+ dirIndex+="\"$platform\":{"
+ fi
+ old_platform=$platform
+
+ comp_name=$(get_compressed_name $platform $arch $zip_name)
+ comp_path=$(get_binary_path $comp_name $platform $arch)
- dirIndex="$dirIndex\"$arch\":{\"path\":\"$comp_path\"},";
- done
+ if [ $arch = $default_arch ]; then
+ dirIndex+="\"default\":{\"path\":\"$comp_path\"},";
+ fi
- dirIndex="$(echo $dirIndex | rev | cut -c2- | rev)"
- dirIndex="$dirIndex},";
+ dirIndex+="\"$arch\":{\"path\":\"$comp_path\"},";
done
- dirIndex="$(echo $dirIndex | rev | cut -c2- | rev)"
- dirIndex="$dirIndex}}"
+ #dirIndex="$(echo $dirIndex | rev | cut -c2- | rev)"
+ dirIndex="${dirIndex%','}" # Remove trailing comma
+ dirIndex+="}}}" # And replace with end-braces
mkdir -p "${PATH_CONTENT_JSON}"
echo $dirIndex > "${PATH_CONTENT_JSON}/content.json"
};
-archs="386 amd64";
default_arch="amd64"
PATH_CONTENT_JSON=$1
+# 'shellcheck' pointed out that BINARY_TAG is unused. I'm leaving it for now
+# because the future of content.json is in flux.
BINARY_TAG=$2
platforms=$3
zip_name=$4
diff --git a/ansible/roles/cli/tasks/cli_remote_mode.yml
b/ansible/roles/cli/tasks/cli_remote_mode.yml
index 063ac5144e..7d16c8a109 100644
--- a/ansible/roles/cli/tasks/cli_remote_mode.yml
+++ b/ansible/roles/cli/tasks/cli_remote_mode.yml
@@ -4,12 +4,11 @@
- name: "download the binaries from the release page of OpenWhisk CLI"
include: download_openwhisk_cli.yml
- with_nested:
- - "{{ cli_os }}"
- - "{{ cli_arch }}"
+ with_items:
+ - "{{ cli_os_arch }}"
- name: "generate content.json locally for Nginx CLI directory"
- local_action: shell "./createContentJson.sh" "{{ config_root_dir }}" "{{
openwhisk_cli_tag }}" "{{ cli_os | join(" ") }}" "{{
openwhisk_cli.remote.dest_name }}" chdir="{{ openwhisk_home
}}/ansible/roles/cli/files"
+ local_action: shell "./createContentJson.sh" "{{ config_root_dir }}" "{{
openwhisk_cli_tag }}" "{{ cli_os_arch | sort | map('join', ',') | join(' ') }}"
"{{ openwhisk_cli.remote.dest_name }}" chdir="{{ openwhisk_home
}}/ansible/roles/cli/files"
- name: "ensure Nginx cli directory is writable"
file:
@@ -17,7 +16,7 @@
state: directory
mode: 0777
become: "{{ cli.dir.become }}"
-
+
- name: "copy the local content.json to the remote node"
copy: src={{ config_root_dir }}/content.json dest={{ cli.nginxdir }}/
diff --git a/ansible/roles/cli/tasks/deploy.yml
b/ansible/roles/cli/tasks/deploy.yml
index 3961ab84c0..dc2d1dc12b 100644
--- a/ansible/roles/cli/tasks/deploy.yml
+++ b/ansible/roles/cli/tasks/deploy.yml
@@ -19,10 +19,11 @@
- name: "copy the binaries from a local directory to Nginx directory"
include: copy_local_openwhisk_cli.yml
when: cli_installation_mode == "local"
- with_items: "{{ cli_os }}"
+ with_items: "{{ cli_os_arch | first | unique }}"
- name: "copy the local content.json from a local directory to Nginx directory"
copy: src={{ openwhisk_cli.local.location }}/content.json dest={{
cli.nginxdir }}/
when: cli_installation_mode == "local"
- include: download_cli.yml
+ when: cli_installation_mode == "remote"
diff --git a/ansible/roles/cli/tasks/download_cli.yml
b/ansible/roles/cli/tasks/download_cli.yml
index 6024b0682d..4d2d872f54 100644
--- a/ansible/roles/cli/tasks/download_cli.yml
+++ b/ansible/roles/cli/tasks/download_cli.yml
@@ -2,10 +2,19 @@
# Download the cli to openwhisk_home
+- name: "Use ansible fact to determine wsk architecture"
+ set_fact:
+ cli_arch: "{{ ansible_machine }}"
+
+- name: "If architecture is x86_64, change it to amd64"
+ set_fact:
+ cli_arch: "amd64"
+ when: ansible_machine == "x86_64"
+
- name: "download cli (linux) to openwhisk home at {{ openwhisk_home }}"
local_action: >
get_url
- url="https://{{ groups['edge'] | first }}/cli/go/download/linux/amd64/wsk"
+ url="https://{{ groups['edge'] | first }}/cli/go/download/linux/{{
cli_arch }}/wsk"
dest="{{ openwhisk_home }}/bin/wsk"
mode=0755
validate_certs=False
@@ -15,7 +24,7 @@
- name: "download cli for mac (docker-machine or Docker for Mac) to openwhisk
home at {{ openwhisk_home }}"
local_action: >
get_url
- url="https://{{ groups['edge'] | first }}/cli/go/download/mac/amd64/wsk"
+ url="https://{{ groups['edge'] | first }}/cli/go/download/mac/{{ cli_arch
}}/wsk"
dest="{{ openwhisk_home }}/bin/wsk"
mode=0755
validate_certs=False
diff --git a/ansible/roles/cli/tasks/download_openwhisk_cli.yml
b/ansible/roles/cli/tasks/download_openwhisk_cli.yml
index 7ea209bedb..1dff7d1836 100644
--- a/ansible/roles/cli/tasks/download_openwhisk_cli.yml
+++ b/ansible/roles/cli/tasks/download_openwhisk_cli.yml
@@ -17,12 +17,16 @@
set_fact:
source_name="{{ openwhisk_cli.remote.name }}-{{ openwhisk_cli_tag }}-{{ os
}}-{{ arc }}.{{ suffix }}"
+- name: "set the destination file name locally (default)"
+ set_fact:
+ dest_name="{{ openwhisk_cli.remote.dest_name }}-{{ os }}-{{arc}}.{{ suffix
}}"
+
- name: "set the destination file name locally after download for 32 bit"
set_fact:
dest_name="{{ openwhisk_cli.remote.dest_name }}-{{ os }}-32bit.{{ suffix
}}"
when: arc == "386"
-- name: "set the destination file name locally after download for 64 bit"
+- name: "set the destination file name locally after download for amd64"
set_fact:
dest_name="{{ openwhisk_cli.remote.dest_name }}-{{ os }}.{{ suffix }}"
when: arc == "amd64"
@@ -70,4 +74,3 @@
args:
chdir: "{{ cli.nginxdir }}/{{ os }}/{{ arc }}/"
when: os == "linux"
-
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services