mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
Add LINK attribute to marketapps lint marketplace
This commit is contained in:
parent
bcbcbceb06
commit
acf6454c6e
@ -890,7 +890,8 @@ RUBY_AUTH_LIB_FILES="src/authm_mad/remotes/ssh/ssh_auth.rb \
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
MAD_SH_LIB_FILES="src/mad/sh/scripts_common.sh \
|
||||
src/mad/sh/create_container_image.sh"
|
||||
src/mad/sh/create_container_image.sh \
|
||||
src/mad/sh/create_docker_image.sh"
|
||||
|
||||
MAD_RUBY_LIB_FILES="src/mad/ruby/scripts_common.rb"
|
||||
|
||||
|
@ -5,7 +5,7 @@ Cmnd_Alias ONE_CEPH = /usr/bin/rbd
|
||||
Cmnd_Alias ONE_FIRECRACKER = /usr/bin/jailer, /usr/bin/mount, /usr/sbin/one-clean-firecracker-domain
|
||||
Cmnd_Alias ONE_HA = /usr/bin/systemctl start opennebula-flow, /usr/bin/systemctl stop opennebula-flow, /usr/bin/systemctl start opennebula-gate, /usr/bin/systemctl stop opennebula-gate, /usr/bin/systemctl start opennebula-hem, /usr/bin/systemctl stop opennebula-hem, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop, /usr/sbin/service opennebula-hem start, /usr/sbin/service opennebula-hem stop, /usr/sbin/arping, /usr/sbin/ip address *
|
||||
Cmnd_Alias ONE_LVM = /usr/sbin/lvcreate, /usr/sbin/lvremove, /usr/sbin/lvs, /usr/sbin/vgdisplay, /usr/sbin/lvchange, /usr/sbin/lvscan, /usr/sbin/lvextend
|
||||
Cmnd_Alias ONE_MARKET = /usr/lib/one/sh/create_container_image.sh
|
||||
Cmnd_Alias ONE_MARKET = /usr/lib/one/sh/create_container_image.sh, /usr/lib/one/sh/create_docker_image.sh
|
||||
Cmnd_Alias ONE_NET = /usr/sbin/ebtables, /usr/sbin/iptables, /usr/sbin/ip6tables, /usr/sbin/ipset, /usr/sbin/ip link *, /usr/sbin/ip tuntap *
|
||||
Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl
|
||||
|
||||
|
@ -6,7 +6,7 @@ Cmnd_Alias ONE_FIRECRACKER = /usr/bin/jailer, /bin/mount, /usr/sbin/one-clean-fi
|
||||
Cmnd_Alias ONE_HA = /bin/systemctl start opennebula-flow, /bin/systemctl stop opennebula-flow, /bin/systemctl start opennebula-gate, /bin/systemctl stop opennebula-gate, /bin/systemctl start opennebula-hem, /bin/systemctl stop opennebula-hem, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop, /usr/sbin/service opennebula-hem start, /usr/sbin/service opennebula-hem stop, /usr/bin/arping, /sbin/ip address *
|
||||
Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvs, /sbin/vgdisplay, /sbin/lvchange, /sbin/lvscan, /sbin/lvextend
|
||||
Cmnd_Alias ONE_LXD = /snap/bin/lxc, /usr/bin/catfstab, /bin/mount, /bin/umount, /bin/mkdir, /bin/lsblk, /sbin/losetup, /sbin/kpartx, /usr/bin/qemu-nbd, /sbin/blkid, /sbin/e2fsck, /sbin/resize2fs, /usr/sbin/xfs_growfs, /usr/bin/rbd-nbd, /usr/sbin/xfs_admin, /sbin/tune2fs
|
||||
Cmnd_Alias ONE_MARKET = /usr/lib/one/sh/create_container_image.sh
|
||||
Cmnd_Alias ONE_MARKET = /usr/lib/one/sh/create_container_image.sh, /usr/lib/one/sh/create_docker_image.sh
|
||||
Cmnd_Alias ONE_NET = /sbin/ebtables, /sbin/iptables, /sbin/ip6tables, /sbin/ipset, /sbin/ip link *, /sbin/ip tuntap *
|
||||
Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl
|
||||
|
||||
|
@ -58,7 +58,8 @@ class Sudoers
|
||||
'arping',
|
||||
'ip address *'
|
||||
],
|
||||
:MARKET => %W[#{lib_location}/sh/create_container_image.sh],
|
||||
:MARKET => %W[#{lib_location}/sh/create_container_image.sh
|
||||
#{lib_location}/sh/create_docker_image.sh ],
|
||||
:FIRECRACKER => %w[/usr/bin/jailer
|
||||
mount
|
||||
/usr/sbin/one-clean-firecracker-domain]
|
||||
|
@ -32,6 +32,8 @@ fi
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
MARKET_URL=$1
|
||||
|
||||
MK_DOCKER=$LIB_LOCATION/sh/create_docker_image.sh
|
||||
|
||||
# URL with the context releases
|
||||
CONTEXT_API="https://api.github.com/repos/OpenNebula/addon-context-linux/releases"
|
||||
CONTEXT_URL="https://github.com/OpenNebula/addon-context-linux/releases/download"
|
||||
@ -90,7 +92,7 @@ function clean {
|
||||
|
||||
# Unmount mnt directory (if necessary)
|
||||
if grep -qs "$dockerdir/mnt" /proc/mounts; then
|
||||
sudo -n umount "$dockerdir/mnt"
|
||||
sudo -n $MK_DOCKER -a "CLEAN" -d $dockerdir
|
||||
fi
|
||||
|
||||
rm -rf $dockerdir
|
||||
@ -306,13 +308,8 @@ esac
|
||||
#-------------------------------------------------------------------------------
|
||||
# Mount container disk image and untar rootfs contents to it
|
||||
#-------------------------------------------------------------------------------
|
||||
sudo -n mount $img_raw $dockerdir/mnt > /dev/null 2>&1
|
||||
sudo -n chmod o+w $dockerdir/mnt
|
||||
sudo -n tar xpf $tarball -C $dockerdir/mnt > /dev/null 2>&1
|
||||
|
||||
sync
|
||||
|
||||
sudo -n umount $dockerdir/mnt
|
||||
sudo -n $MK_DOCKER -a "CREATE" -d $dockerdir -i $img_raw -t $tarball
|
||||
|
||||
if [ "$format" == "qcow2" ]; then
|
||||
qemu-img convert -f raw -O qcow2 $img_raw $img_qcow > /dev/null 2>&1
|
||||
|
59
src/mad/sh/create_docker_image.sh
Executable file
59
src/mad/sh/create_docker_image.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# exit when any command fails
|
||||
set -e
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configuration attributes and parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
img_raw=""
|
||||
dockerdir=""
|
||||
tarball=""
|
||||
action=""
|
||||
|
||||
while getopts ":i:d:t:a:" opt; do
|
||||
case $opt in
|
||||
i) img_raw="$OPTARG" ;;
|
||||
d) dockerdir="$OPTARG" ;;
|
||||
t) tarball="$OPTARG" ;;
|
||||
a) action="$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$action" ]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ $action == "CREATE" ]; then
|
||||
# Mount container disk image and untar rootfs contents to it
|
||||
mount -o noexec,nodev $img_raw $dockerdir/mnt > /dev/null 2>&1
|
||||
chmod o+w $dockerdir/mnt
|
||||
tar xpf $tarball -C $dockerdir/mnt > /dev/null 2>&1
|
||||
|
||||
sync
|
||||
|
||||
umount $dockerdir/mnt
|
||||
|
||||
exit 0
|
||||
elif [ $action == "CLEAN" ]; then
|
||||
umount "$dockerdir/mnt"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
@ -53,6 +53,9 @@ CONTEXT = [
|
||||
NETWORK =\"YES\",
|
||||
SSH_PUBLIC_KEY =\"$USER[SSH_PUBLIC_KEY]\",
|
||||
SET_HOSTNAME =\"$NAME\"
|
||||
]
|
||||
OS = [
|
||||
KERNEL_CMD=\"console=ttyS0 reboot=k panic=1 pci=off\"
|
||||
]"
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
@ -161,7 +161,9 @@ CONTEXT = [
|
||||
'VERSION' => '1.0',
|
||||
'TYPE' => 'IMAGE',
|
||||
'DESCRIPTION' => description,
|
||||
'TAGS' => ''
|
||||
'TAGS' => '',
|
||||
'LINK' => "#{@options[:url]}#{path}"
|
||||
.gsub('/rootfs.tar.xz', '')
|
||||
}
|
||||
|
||||
tmpl = ''
|
||||
|
@ -76,8 +76,8 @@ class OneMarket
|
||||
|
||||
applist['appliances'].each do |app|
|
||||
id = app['_id']['$oid']
|
||||
source = "#{@url}/appliance/#{id}/download/0"
|
||||
|
||||
link = "#{@url}/appliance/#{id}".gsub('//', '/')
|
||||
source = "#{link}/download/0"
|
||||
tmpl = ''
|
||||
|
||||
app['type'] = 'IMAGE' unless app['type']
|
||||
@ -93,6 +93,7 @@ class OneMarket
|
||||
print_var(tmpl, 'VERSION', app['version'])
|
||||
print_var(tmpl, 'TAGS', app['tags'].join(', '))
|
||||
print_var(tmpl, 'REGTIME', app['creation_time'])
|
||||
print_var(tmpl, 'LINK', link)
|
||||
|
||||
if !app['files'].nil? && !app['files'][0].nil?
|
||||
file = app['files'][0]
|
||||
|
@ -176,7 +176,8 @@ class TurnkeyLinux
|
||||
'TAGS' => '',
|
||||
'REGTIME' => regt,
|
||||
'SIZE' => @options[:sizemb],
|
||||
'DESCRIPTION' => "Based on #{image[0]}-#{image[1]}"
|
||||
'DESCRIPTION' => "Based on #{image[0]}-#{image[1]}",
|
||||
'LINK' => "#{@options[:url]}/#{@options[:platform]}/#{path}"
|
||||
}
|
||||
|
||||
tmpl = ''
|
||||
|
@ -28,12 +28,13 @@ module Migrator
|
||||
|
||||
def up
|
||||
feature_3600
|
||||
feature_4089
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
#Rename acl column name from user to userset to support postgresql
|
||||
# Rename acl column name from user to userset to support postgresql
|
||||
def feature_3600
|
||||
@db.run 'DROP TABLE IF EXISTS old_acl;'
|
||||
@db.run 'ALTER TABLE acl RENAME TO old_acl;'
|
||||
@ -51,4 +52,44 @@ module Migrator
|
||||
@db.run "DROP TABLE old_acl;"
|
||||
end
|
||||
|
||||
# Add DockerHub marketplace
|
||||
def feature_4089
|
||||
@db.transaction do
|
||||
@db.fetch('SELECT max(oid) as maxid FROM marketplace_pool') do |row|
|
||||
next_oid = row[:maxid] + 1
|
||||
|
||||
body = "<MARKETPLACE><ID>#{next_oid}</ID><UID>0</UID><GID>0" \
|
||||
'</GID><UNAME>oneadmin</UNAME><GNAME>oneadmin' \
|
||||
'</GNAME><NAME>DockerHub</NAME><MARKET_MAD>' \
|
||||
'<![CDATA[dockerhub]]></MARKET_MAD><ZONE_ID>' \
|
||||
'<![CDATA[0]]></ZONE_ID><TOTAL_MB>0</TOTAL_MB>' \
|
||||
'<FREE_MB>0</FREE_MB><USED_MB>0</USED_MB>' \
|
||||
'<MARKETPLACEAPPS/><PERMISSIONS><OWNER_U>1</OWNER_U>' \
|
||||
'<OWNER_M>1</OWNER_M><OWNER_A>1</OWNER_A>' \
|
||||
'<GROUP_U>1</GROUP_U><GROUP_M>0</GROUP_M>' \
|
||||
'<GROUP_A>0</GROUP_A><OTHER_U>1</OTHER_U>' \
|
||||
'<OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A>' \
|
||||
'</PERMISSIONS><TEMPLATE>' \
|
||||
'<DESCRIPTION><![CDATA[DockerHub is the world\'s' \
|
||||
' largest library and community for container' \
|
||||
' images hosted at hub.docker.com/]]></DESCRIPTION>' \
|
||||
'<MARKET_MAD><![CDATA[dockerhub]]></MARKET_MAD>' \
|
||||
'</TEMPLATE></MARKETPLACE>'
|
||||
|
||||
new_row = {
|
||||
:oid => next_oid,
|
||||
:name => 'DockerHub',
|
||||
:body => body,
|
||||
:uid => 0,
|
||||
:gid => 0,
|
||||
:owner_u => 1,
|
||||
:group_u => 1,
|
||||
:other_u => 1
|
||||
}
|
||||
|
||||
@db[:marketplace_pool].insert(new_row)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user