Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SmartOS 20111019 update

  • Loading branch information...
commit f1641aa6a59720b6fc3d406042ff03dd17e4c4d8 1 parent 49b86bb
@JohnSonnenschein JohnSonnenschein authored
Showing with 6,430 additions and 20,519 deletions.
  1. +50 −0 .gitignore
  2. +25 −3 Makefile
  3. +13 −0 configure
  4. +4 −2 configure.smartos
  5. +1 −0  man/man/man
  6. +1 −1  man/man/man1/zonestat.1
  7. +1 −1  man/man/man1m/vfsstat.1m
  8. +1 −1  man/man/man1m/ziostat.1m
  9. +1 −1  man/man/man1m/zonestatd.1m
  10. +1 −1  man/man/man7/ronn-format.7
  11. +1 −0  man/man/share
  12. +1 −0  man/man/usr
  13. +0 −1  man/usr/share/man
  14. +0 −18,766 manifest
  15. +0 −2  overlay/etc/cron.d/crontabs/root
  16. +0 −54 overlay/etc/nsswitch.conf
  17. 0  overlay/{ → generic}/etc/bash/bash_completion
  18. 0  overlay/{ → generic}/etc/bash/bash_completion.d/machines
  19. +1 −1  overlay/{ → generic}/etc/bash/bash_completion.d/vms
  20. 0  overlay/{ → generic}/etc/bash/bash_completion.d/zones
  21. 0  overlay/{ → generic}/etc/bash/bashrc.example
  22. 0  overlay/{ → generic}/etc/bash/inputrc.example
  23. +6 −0 overlay/generic/etc/cron.d/crontabs/root
  24. 0  overlay/{ → generic}/etc/crypto/pkcs11.conf
  25. 0  overlay/{ → generic}/etc/curl/curlCA
  26. 0  overlay/{ → generic}/etc/default/init
  27. 0  overlay/{ → generic}/etc/default/login
  28. 0  overlay/{ → generic}/etc/default/passwd
  29. 0  overlay/{ → generic}/etc/dispadmin.conf
  30. 0  overlay/{ → generic}/etc/driver_aliases
  31. 0  overlay/{ → generic}/etc/driver_classes
  32. 0  overlay/{ → generic}/etc/dumpadm.conf
  33. 0  overlay/{ → generic}/etc/group
  34. 0  overlay/{ → generic}/etc/inet/ntp.conf
  35. 0  overlay/{ → generic}/etc/inittab
  36. 0  overlay/{ → generic}/etc/issue
  37. 0  overlay/{ → generic}/etc/logadm.conf
  38. 0  overlay/{ → generic}/etc/minor_perm
  39. 0  overlay/{ → generic}/etc/motd
  40. 0  overlay/{ → generic}/etc/name_to_major
  41. 0  overlay/{ → generic}/etc/nodename
  42. 0  overlay/{ → generic}/etc/notices/COPYRIGHT
  43. 0  overlay/{ → generic}/etc/opasswd
  44. 0  overlay/{ → generic}/etc/ouser_attr
  45. 0  overlay/{ → generic}/etc/passwd
  46. 0  overlay/{ → generic}/etc/path_to_inst
  47. 0  overlay/{ → generic}/etc/release
  48. 0  overlay/{ → generic}/etc/resolv.conf
  49. 0  overlay/{ → generic}/etc/rtc_config
  50. 0  overlay/{ → generic}/etc/shadow
  51. 0  overlay/{ → generic}/etc/skel/.bashrc
  52. 0  overlay/{ → generic}/etc/ssh/sshd_config
  53. 0  overlay/{ → generic}/etc/svc/profile/generic.xml
  54. 0  overlay/{ → generic}/etc/svc/profile/platform.xml
  55. 0  overlay/{ → generic}/etc/system
  56. 0  overlay/{ → generic}/etc/user_attr
  57. 0  overlay/{ → generic}/etc/vfstab
  58. 0  overlay/{ → generic}/etc/zones/SUNWdefault.xml
  59. 0  overlay/{ → generic}/etc/zshrc
  60. 0  overlay/{ → generic}/kernel/drv/amd64/bnx
  61. 0  overlay/{ → generic}/kernel/drv/amd64/cpqary3
  62. 0  overlay/{ → generic}/kernel/drv/cpqary3.conf
  63. 0  overlay/{ → generic}/lib/sdc/config.sh
  64. 0  overlay/{ → generic}/lib/sdc/network.sh
  65. 0  overlay/{ → generic}/lib/sdc/zone.sh
  66. 0  overlay/{ → generic}/lib/svc/manifest/network/forwarding.xml
  67. 0  overlay/{ → generic}/lib/svc/manifest/network/ipfilter.xml
  68. 0  overlay/{ → generic}/lib/svc/manifest/network/network-location.xml
  69. 0  overlay/{ → generic}/lib/svc/manifest/network/network-physical.xml
  70. 0  overlay/{ → generic}/lib/svc/manifest/network/nfs/client.xml
  71. 0  overlay/{ → generic}/lib/svc/manifest/network/nfs/nlockmgr.xml
  72. 0  overlay/{ → generic}/lib/svc/manifest/network/nfs/server.xml
  73. 0  overlay/{ → generic}/lib/svc/manifest/system/auditd.xml
  74. 0  overlay/{ → generic}/lib/svc/manifest/system/console-login.xml
  75. 0  overlay/{ → generic}/lib/svc/manifest/system/coreadm.xml
  76. 0  overlay/{ → generic}/lib/svc/manifest/system/filesystem/joyent-fs.xml
  77. 0  overlay/{ → generic}/lib/svc/manifest/system/filesystem/minimal-fs.xml
  78. +52 −0 overlay/generic/lib/svc/manifest/system/smartdc-beacon.xml
  79. 0  overlay/{ → generic}/lib/svc/manifest/system/smartdc-config.xml
  80. 0  overlay/{ → generic}/lib/svc/manifest/system/smartdc-init.xml
  81. 0  overlay/{ → generic}/lib/svc/manifest/system/smartdc-vmadmd.xml
  82. 0  overlay/{ → generic}/lib/svc/manifest/system/sysidtool.xml
  83. 0  overlay/{ → generic}/lib/svc/method/console-login
  84. 0  overlay/{ → generic}/lib/svc/method/fs-root
  85. 0  overlay/{ → generic}/lib/svc/method/fs-usr
  86. 0  overlay/{ → generic}/lib/svc/method/identity-node
  87. 0  overlay/{ → generic}/lib/svc/method/ipfilter
  88. 0  overlay/{ → generic}/lib/svc/method/manifest-import
  89. +3 −1 overlay/{ → generic}/lib/svc/method/smartdc-init
  90. 0  overlay/{ → generic}/lib/svc/method/smartdc-vmadmd
  91. 0  overlay/{ → generic}/lib/svc/method/sshd
  92. 0  overlay/{ → generic}/lib/svc/method/sysidtool-net
  93. 0  overlay/{ → generic}/lib/svc/method/sysidtool-system
  94. +116 −0 overlay/generic/manifest
  95. 0  overlay/{ → generic}/usr/bin/ack
  96. +109 −303 overlay/{ → generic}/usr/bin/json
  97. 0  overlay/{ → generic}/usr/include/usb.h
  98. 0  overlay/{ → generic}/usr/lib/brand/joyent/manifests
  99. 0  overlay/{ → generic}/usr/lib/localedef/extensions/UTF-8.x
  100. +116 −0 overlay/generic/usr/sbin/joycomm
  101. 0  overlay/{ → generic}/usr/sbin/zonememstat
  102. 0  overlay/{ → generic}/usr/share/man/man1/ack.1
  103. 0  overlay/{ → generic}/usr/share/man/man1/json.1
  104. 0  overlay/{ → generic}/var/ld/amd64/ld.config
  105. 0  overlay/{ → generic}/var/ld/ld.config
  106. +12 −6 overlay/{ → smartos}/lib/svc/method/fs-joyent
  107. 0  overlay/{ → smartos}/lib/svc/method/net-physical
  108. 0  overlay/{ → smartos}/lib/svc/method/smartdc-config
  109. +13 −0 overlay/smartos/manifest
  110. 0  overlay/{admin → smartos/root}/.bash_profile
  111. 0  overlay/{admin → smartos/root}/.bashrc
  112. 0  overlay/{admin → smartos/root}/.profile
  113. 0  overlay/{ → smartos}/smartdc/bin/smartos_prompt_config.sh
  114. BIN  overlay/usr/lib/amd64/libCrun.so.1
  115. BIN  overlay/usr/lib/libCrun.so.1
  116. +9 −3 src/Makefile
  117. +256 −63 src/{create-machine.js → machine/machine-create.js}
  118. +56 −9 src/machine/machine-json.js
  119. +310 −0 src/machine/machine-lookup.js
  120. +179 −0 src/manifest
  121. +341 −0 src/node-kstat/kstat.cc
  122. +17 −0 src/node-kstat/wscript
  123. +115 −0 src/node_modules/system.js
  124. +94 −243 src/sysinfo
  125. +3 −1 src/vmadm.js
  126. +59 −13 src/vmadmd.js
  127. +10 −3 src/vmcfg.js
  128. +7 −3 tools/build_illumos
  129. +4 −8 tools/build_iso
  130. +73 −0 tools/build_manifest
  131. +1 −1  tools/builder/Makefile
  132. +10 −0 tools/builder/build_users_c.sh
  133. +1 −0  tools/builder/file_cp.c
  134. +1 −0  tools/get_status
  135. +4,353 −1,027 tools/pwgen-2.06/configure
  136. +3 −1 tools/sorter
View
50 .gitignore
@@ -0,0 +1,50 @@
+/configure.*
+/configure-*
+/output
+/projects
+/proto
+/log
+/src/bootparams
+/src/disk_size
+/src/removable_disk
+/src/disklist
+/src/node-kstat/.lock-wscript
+/src/node-kstat/build
+/tools/builder/builder
+/tools/builder/*.o
+/tools/builder/users.c
+/tools/builder/users.c.tmp
+/tools/cryptpass
+/tools/pwgen
+/tools/pwgen-2.06/configure
+/0-*-stamp
+/manifest.new
+zonestat.1
+zonestatd.1m
+ronn-format.7
+man/man/man1m/vfsstat.1m
+man/man/man1m/ziostat.1m
+src/has_hvx
+src/marco
+src/polo
+src_addon/bind/bind-9.8.0/
+src_addon/ipmi/ipmitool-1.8.11/
+src_addon/libreadline/config.log
+src_addon/libreadline/config.status
+src_addon/libreadline/*.o
+src_addon/libreadline/*.a
+src_addon/libreadline/shlib/*.so
+src_addon/libusb/*.1
+src_addon/cpp/cpp
+src_addon/cpp/cpp.o
+src_addon/cpp/y.tab.c
+src_addon/cpp/y.tab.o
+src_addon/libreadline/shlib/libhistory.so.5
+src_addon/libreadline/shlib/libreadline.so.5
+src_addon/libusb/wr_libusb.o
+tools/pwgen-2.06/Makefile
+tools/pwgen-2.06/autom4te.cache
+manifest.gen
+manifest.d/
+overlay/order
+overlay/sdc
View
28 Makefile
@@ -2,16 +2,33 @@
ROOT=$(PWD)
PROTO=$(ROOT)/proto
+MPROTO=$(ROOT)/manifest.d
PATH=/opt/local/bin:/opt/local/sbin:/opt/local/gcc34/bin:/usr/xpg4/bin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/openwin/bin:/opt/SUNWspro/bin:/usr/ccs/bin
LOCAL_SUBDIRS:=$(shell ls projects/local)
+MANIFEST=manifest.gen
+OVERLAYS:=$(shell cat overlay/order)
world: 0-illumos-stamp 0-extra-stamp 0-livesrc-stamp 0-local-stamp \
0-tools-stamp 0-man-stamp 0-devpro-stamp
-live: world
+live: world manifest
(cd $(ROOT)/src_addon && gmake DESTDIR=$(PROTO) install)
mkdir -p ${ROOT}/log
- (cd $(ROOT) && pfexec ./tools/build_live $(ROOT)/manifest $(ROOT)/output $(ROOT)/overlay $(ROOT)/proto $(ROOT)/man/)
+ (cd $(ROOT) && pfexec ./tools/build_live $(ROOT)/$(MANIFEST) $(ROOT)/output $(OVERLAYS) $(ROOT)/proto $(ROOT)/man/man)
+
+manifest:
+ rm -f $(MANIFEST) $(MPROTO)/*
+ -[ ! -d $(MPROTO) ] && mkdir $(MPROTO)
+ cp src/manifest $(MPROTO)/live.manifest
+ cp projects/illumos/manifest $(MPROTO)/illumos.manifest
+ gmake DESTDIR=$(MPROTO) DESTNAME=illumos-extra.manifest -C projects/illumos-extra manifest
+ [ ! -d projects/local ] || for dir in $(LOCAL_SUBDIRS); do \
+ cd $(ROOT)/projects/local/$${dir}; \
+ if [[ -f Makefile.joyent ]]; then \
+ gmake DESTDIR=$(MPROTO) DESTNAME=$${dir}.manifest -f Makefile.joyent \
+ manifest; else gmake DESTDIR=$(MPROTO) DESTNAME=$${dir}.manifest manifest; fi; done
+ for dir in $(OVERLAYS); do cp $${dir}/manifest $(MPROTO)/overlay-$$(basename $${dir}).manifest; done
+ ./tools/build_manifest
update:
./tools/update_base
@@ -53,12 +70,15 @@ update:
(cd $(ROOT)/tools/builder && gmake builder)
0-pwgen-stamp:
- (cd ${ROOT}/tools/pwgen-* && ./configure && make && cp pwgen ${ROOT}/tools)
+ (cd ${ROOT}/tools/pwgen-* && autoconf && ./configure \
+ && make && cp pwgen ${ROOT}/tools)
tools/cryptpass: tools/cryptpass.c
(cd ${ROOT}/tools && gcc -Wall -W -O2 -o cryptpass cryptpass.c)
clean:
+ rm -f $(MANIFEST)
+ rm -rf $(ROOT)/$(MPROTO)/*
(cd $(ROOT)/src && gmake clean)
[ ! -d $(ROOT)/projects/illumos-extra ] || (cd $(ROOT)/projects/illumos-extra && gmake clean)
[ ! -d projects/local ] || for dir in $(LOCAL_SUBDIRS); do \
@@ -68,3 +88,5 @@ clean:
(cd $(ROOT) && rm -rf $(PROTO))
(cd $(ROOT) && mkdir -p $(PROTO))
rm -f 0-*-stamp
+
+.PHONY: manifest
View
13 configure
@@ -156,6 +156,19 @@ if [ ! -f "projects/illumos-extra/Makefile" ]; then
fi
ROOT=`pwd`
+echo "==> Setting up overlay"
+
+if [ -z "${OVERLAYS}" ]; then
+ echo "FATAL: overlay order not specified"
+ exit 1
+fi
+
+rm -f ${ROOT}/overlay/order
+touch ${ROOT}/overlay/order
+for entry in ${OVERLAYS}; do
+ echo -n "${ROOT}/overlay/${entry} " >> ${ROOT}/overlay/order
+done
+
echo "==> Setting up illumos-gate"
cd ${ROOT}/projects/illumos
View
6 configure.smartos
@@ -41,10 +41,12 @@ EOF
fi
PUBLISHER="illumos"
-RELEASE_VER="joyent_147"
+RELEASE_VER="smartos_20111019"
SUNW_SPRO12_URL=""
SUNW_SPRO12u1_URL=""
ON_CLOSED_BINS_URL="http://dlc.sun.com/osol/on/downloads/20100817/on-closed-bins.i386.tar.bz2"
ON_CLOSED_BINS_ND_URL="http://dlc.sun.com/osol/on/downloads/20100817/on-closed-bins-nd.i386.tar.bz2"
-GET_ILLUMOS="(git clone https://github.com/joyent/illumos-joyent.git illumos)"
+GET_ILLUMOS="(git clone https://github.com/joyent/illumos-joyent illumos)"
GET_ILLUMOS_EXTRA="git clone https://github.com/joyent/illumos-extra.git illumos-extra"
+
+OVERLAYS="smartos generic"
View
1  man/man/man
View
2  man/man/man1/zonestat.1
@@ -1,7 +1,7 @@
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "ZONESTAT" "1" "September 2011" "" ""
+.TH "ZONESTAT" "1" "October 2011" "" ""
.
.SH "NAME"
\fBzonestat\fR \-\- report active zone statistics\.
View
2  man/man/man1m/vfsstat.1m
@@ -1,7 +1,7 @@
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "VFSSTAT" "1m" "September 2011" "" ""
+.TH "VFSSTAT" "1m" "October 2011" "" ""
.
.SH "NAME"
\fBvfsstat\fR \-\- Report VFS read and write activity
View
2  man/man/man1m/ziostat.1m
@@ -1,7 +1,7 @@
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "ZIOSTAT" "1m" "September 2011" "" ""
+.TH "ZIOSTAT" "1m" "October 2011" "" ""
.
.SH "NAME"
\fBziostat\fR \-\- Report ZFS read I/O activity
View
2  man/man/man1m/zonestatd.1m
@@ -1,7 +1,7 @@
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "ZONESTATD" "1m" "September 2011" "" ""
+.TH "ZONESTATD" "1m" "October 2011" "" ""
.
.SH "NAME"
\fBzonestatd\fR \-\- zones monitoring daemon
View
2  man/man/man7/ronn-format.7
@@ -1,7 +1,7 @@
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "RONN\-FORMAT" "7" "September 2011" "" ""
+.TH "RONN\-FORMAT" "7" "October 2011" "" ""
.
.SH "NAME"
\fBronn-format\fR \-\- manual authoring format based on Markdown
View
1  man/man/share
View
1  man/man/usr
View
1  man/usr/share/man
View
18,766 manifest
0 additions, 18,766 deletions not shown
View
2  overlay/etc/cron.d/crontabs/root
@@ -1,2 +0,0 @@
-## Rotate and trim the regular logs nightly at 10 after midnight.
-10 0 * * * /usr/sbin/logadm
View
54 overlay/etc/nsswitch.conf
@@ -1,54 +0,0 @@
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# /etc/nsswitch.conf:
-#
-# "hosts:" and "services:" in this file are used only if the
-# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.
-
-passwd: files
-group: files
-hosts: files mdns
-ipnodes: files mdns dns
-networks: files
-protocols: files
-rpc: files
-ethers: files
-netmasks: files
-bootparams: files
-publickey: files
-# At present there isn't a 'files' backend for netgroup; the system will
-# figure it out pretty quickly, and won't use netgroups at all.
-netgroup: files
-automount: files
-aliases: files
-services: files
-printers: user files
-
-auth_attr: files
-prof_attr: files
-project: files
-
-tnrhtp: files
-tnrhdb: files
View
0  overlay/etc/bash/bash_completion → overlay/generic/etc/bash/bash_completion
File renamed without changes
View
0  overlay/etc/bash/bash_completion.d/machines → overlay/generic/etc/bash/bash_completion.d/machines
File renamed without changes
View
2  overlay/etc/bash/bash_completion.d/vms → overlay/generic/etc/bash/bash_completion.d/vms
@@ -21,7 +21,7 @@ _vmadm()
/usr/xpg4/bin/grep -e "${up_patterns}" | cut -d ' ' -f1)
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
;;
- halt|reboot|reset|nmi)
+ halt|reboot|reset|nmi|screenshot)
local running=$(vmadm list -v | grep -v "^UUID" | \
grep " running *$" | cut -d ' ' -f1)
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
View
0  overlay/etc/bash/bash_completion.d/zones → overlay/generic/etc/bash/bash_completion.d/zones
File renamed without changes
View
0  overlay/etc/bash/bashrc.example → overlay/generic/etc/bash/bashrc.example
File renamed without changes
View
0  overlay/etc/bash/inputrc.example → overlay/generic/etc/bash/inputrc.example
File renamed without changes
View
6 overlay/generic/etc/cron.d/crontabs/root
@@ -0,0 +1,6 @@
+## Rotate and trim the audit logs nightly at midnight.
+0 0 * * * /usr/sbin/joycomm -R 30
+## Rotate and trim the regular logs nightly at 10 after midnight.
+10 0 * * * /usr/sbin/logadm
+## Headnode should phone home at 1a UTC
+0 1 * * * /smartdc/bin/sdc-phonehome
View
0  overlay/etc/crypto/pkcs11.conf → overlay/generic/etc/crypto/pkcs11.conf
File renamed without changes
View
0  overlay/etc/curl/curlCA → overlay/generic/etc/curl/curlCA
File renamed without changes
View
0  overlay/etc/default/init → overlay/generic/etc/default/init
File renamed without changes
View
0  overlay/etc/default/login → overlay/generic/etc/default/login
File renamed without changes
View
0  overlay/etc/default/passwd → overlay/generic/etc/default/passwd
File renamed without changes
View
0  overlay/etc/dispadmin.conf → overlay/generic/etc/dispadmin.conf
File renamed without changes
View
0  overlay/etc/driver_aliases → overlay/generic/etc/driver_aliases
File renamed without changes
View
0  overlay/etc/driver_classes → overlay/generic/etc/driver_classes
File renamed without changes
View
0  overlay/etc/dumpadm.conf → overlay/generic/etc/dumpadm.conf
File renamed without changes
View
0  overlay/etc/group → overlay/generic/etc/group
File renamed without changes
View
0  overlay/etc/inet/ntp.conf → overlay/generic/etc/inet/ntp.conf
File renamed without changes
View
0  overlay/etc/inittab → overlay/generic/etc/inittab
File renamed without changes
View
0  overlay/etc/issue → overlay/generic/etc/issue
File renamed without changes
View
0  overlay/etc/logadm.conf → overlay/generic/etc/logadm.conf
File renamed without changes
View
0  overlay/etc/minor_perm → overlay/generic/etc/minor_perm
File renamed without changes
View
0  overlay/etc/motd → overlay/generic/etc/motd
File renamed without changes
View
0  overlay/etc/name_to_major → overlay/generic/etc/name_to_major
File renamed without changes
View
0  overlay/etc/nodename → overlay/generic/etc/nodename
File renamed without changes
View
0  overlay/etc/notices/COPYRIGHT → overlay/generic/etc/notices/COPYRIGHT
File renamed without changes
View
0  overlay/etc/opasswd → overlay/generic/etc/opasswd
File renamed without changes
View
0  overlay/etc/ouser_attr → overlay/generic/etc/ouser_attr
File renamed without changes
View
0  overlay/etc/passwd → overlay/generic/etc/passwd
File renamed without changes
View
0  overlay/etc/path_to_inst → overlay/generic/etc/path_to_inst
File renamed without changes
View
0  overlay/etc/release → overlay/generic/etc/release
File renamed without changes
View
0  overlay/etc/resolv.conf → overlay/generic/etc/resolv.conf
File renamed without changes
View
0  overlay/etc/rtc_config → overlay/generic/etc/rtc_config
File renamed without changes
View
0  overlay/etc/shadow → overlay/generic/etc/shadow
File renamed without changes
View
0  overlay/etc/skel/.bashrc → overlay/generic/etc/skel/.bashrc
File renamed without changes
View
0  overlay/etc/ssh/sshd_config → overlay/generic/etc/ssh/sshd_config
File renamed without changes
View
0  overlay/etc/svc/profile/generic.xml → overlay/generic/etc/svc/profile/generic.xml
File renamed without changes
View
0  overlay/etc/svc/profile/platform.xml → overlay/generic/etc/svc/profile/platform.xml
File renamed without changes
View
0  overlay/etc/system → overlay/generic/etc/system
File renamed without changes
View
0  overlay/etc/user_attr → overlay/generic/etc/user_attr
File renamed without changes
View
0  overlay/etc/vfstab → overlay/generic/etc/vfstab
File renamed without changes
View
0  overlay/etc/zones/SUNWdefault.xml → overlay/generic/etc/zones/SUNWdefault.xml
File renamed without changes
View
0  overlay/etc/zshrc → overlay/generic/etc/zshrc
File renamed without changes
View
0  overlay/kernel/drv/amd64/bnx → overlay/generic/kernel/drv/amd64/bnx
File renamed without changes
View
0  overlay/kernel/drv/amd64/cpqary3 → overlay/generic/kernel/drv/amd64/cpqary3
File renamed without changes
View
0  overlay/kernel/drv/cpqary3.conf → overlay/generic/kernel/drv/cpqary3.conf
File renamed without changes
View
0  overlay/lib/sdc/config.sh → overlay/generic/lib/sdc/config.sh
File renamed without changes
View
0  overlay/lib/sdc/network.sh → overlay/generic/lib/sdc/network.sh
File renamed without changes
View
0  overlay/lib/sdc/zone.sh → overlay/generic/lib/sdc/zone.sh
File renamed without changes
View
0  overlay/lib/svc/manifest/network/forwarding.xml → ...y/generic/lib/svc/manifest/network/forwarding.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/network/ipfilter.xml → ...lay/generic/lib/svc/manifest/network/ipfilter.xml
File renamed without changes
View
0  ...lay/lib/svc/manifest/network/network-location.xml → ...ric/lib/svc/manifest/network/network-location.xml
File renamed without changes
View
0  ...lay/lib/svc/manifest/network/network-physical.xml → ...ric/lib/svc/manifest/network/network-physical.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/network/nfs/client.xml → ...y/generic/lib/svc/manifest/network/nfs/client.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/network/nfs/nlockmgr.xml → ...generic/lib/svc/manifest/network/nfs/nlockmgr.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/network/nfs/server.xml → ...y/generic/lib/svc/manifest/network/nfs/server.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/system/auditd.xml → overlay/generic/lib/svc/manifest/system/auditd.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/system/console-login.xml → ...generic/lib/svc/manifest/system/console-login.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/system/coreadm.xml → overlay/generic/lib/svc/manifest/system/coreadm.xml
File renamed without changes
View
0  .../lib/svc/manifest/system/filesystem/joyent-fs.xml → .../lib/svc/manifest/system/filesystem/joyent-fs.xml
File renamed without changes
View
0  ...lib/svc/manifest/system/filesystem/minimal-fs.xml → ...lib/svc/manifest/system/filesystem/minimal-fs.xml
File renamed without changes
View
52 overlay/generic/lib/svc/manifest/system/smartdc-beacon.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type="manifest" name="beacon">
+ <service name="smartdc/system/beacon" type="service" version="0.0.1">
+
+ <create_default_instance enabled="true"/>
+ <single_instance/>
+
+ <dependency name="smartdc-init" grouping="require_all" restart_on="error" type="service">
+ <service_fmri value="svc:/system/smartdc/init"/>
+ </dependency>
+
+ <exec_method
+ type="method"
+ name="start"
+ exec="/lib/svc/method/smartdc-beacon %m"
+ timeout_seconds="60">
+ <method_context>
+ <method_credential user="root" group="staff"/>
+ </method_context>
+ </exec_method>
+
+ <exec_method type="method" name="restart" exec=":kill" timeout_seconds="60">
+ <method_context>
+ <method_credential user="root" group="staff"/>
+ </method_context>
+ </exec_method>
+
+ <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60">
+ <method_context>
+ <method_credential user="root" group="staff"/>
+ </method_context>
+ </exec_method>
+
+ <property_group name="startd" type="framework">
+ <propval name="ignore_error" type="astring" value="core,signal"/>
+ </property_group>
+
+ <property_group name="application" type="application">
+ </property_group>
+
+ <stability value="Evolving"/>
+
+ <template>
+ <common_name>
+ <loctext xml:lang="C">Beacon</loctext>
+ </common_name>
+ </template>
+
+ </service>
+
+</service_bundle>
View
0  overlay/lib/svc/manifest/system/smartdc-config.xml → ...eneric/lib/svc/manifest/system/smartdc-config.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/system/smartdc-init.xml → .../generic/lib/svc/manifest/system/smartdc-init.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/system/smartdc-vmadmd.xml → ...eneric/lib/svc/manifest/system/smartdc-vmadmd.xml
File renamed without changes
View
0  overlay/lib/svc/manifest/system/sysidtool.xml → ...lay/generic/lib/svc/manifest/system/sysidtool.xml
File renamed without changes
View
0  overlay/lib/svc/method/console-login → overlay/generic/lib/svc/method/console-login
File renamed without changes
View
0  overlay/lib/svc/method/fs-root → overlay/generic/lib/svc/method/fs-root
File renamed without changes
View
0  overlay/lib/svc/method/fs-usr → overlay/generic/lib/svc/method/fs-usr
File renamed without changes
View
0  overlay/lib/svc/method/identity-node → overlay/generic/lib/svc/method/identity-node
File renamed without changes
View
0  overlay/lib/svc/method/ipfilter → overlay/generic/lib/svc/method/ipfilter
File renamed without changes
View
0  overlay/lib/svc/method/manifest-import → overlay/generic/lib/svc/method/manifest-import
File renamed without changes
View
4 overlay/lib/svc/method/smartdc-init → overlay/generic/lib/svc/method/smartdc-init
@@ -93,7 +93,9 @@ case "$1" in
exit $SMF_EXIT_OK
fi
- if /bin/bootparams | grep "^smartos=true" > /dev/null 2>&1; then
+ # If we're a headnode, we'll not have AMQP args on the cmdline, and we want
+ # to run an initial_script first anyway.
+ if /bin/bootparams | grep "^headnode=true" > /dev/null 2>&1; then
USBMOUNT=/mnt/`svcprop -p joyentfs/usb_mountpoint svc:/system/filesystem/smartdc:default`
# No config file (e.g. user quit during interactive configuration), so
View
0  overlay/lib/svc/method/smartdc-vmadmd → overlay/generic/lib/svc/method/smartdc-vmadmd
File renamed without changes
View
0  overlay/lib/svc/method/sshd → overlay/generic/lib/svc/method/sshd
File renamed without changes
View
0  overlay/lib/svc/method/sysidtool-net → overlay/generic/lib/svc/method/sysidtool-net
File renamed without changes
View
0  overlay/lib/svc/method/sysidtool-system → overlay/generic/lib/svc/method/sysidtool-system
File renamed without changes
View
116 overlay/generic/manifest
@@ -0,0 +1,116 @@
+# overlay
+f etc/path_to_inst 0444 root root
+f etc/nsswitch.conf 0644 root sys
+d etc/crypto 0755 root sys
+f etc/crypto/pkcs11.conf 0644 root sys
+f etc/ouser_attr 0644 root sys
+f etc/inet/ntp.conf 0644 root sys
+d etc/inet 0755 root sys
+f etc/opasswd 0644 root sys
+f etc/driver_aliases 0644 root sys
+f etc/logadm.conf 0644 root sys
+f etc/group 0644 root sys
+f etc/inittab 0644 root sys
+f etc/system 0644 root sys
+f etc/driver_classes 0644 root sys
+f etc/user_attr 0644 root sys
+f etc/motd 0644 root sys
+d etc/notices 0755 root sys
+f etc/notices/COPYRIGHT 0444 root sys
+f etc/name_to_major 0644 root sys
+f etc/passwd 0644 root sys
+f etc/release 0444 root sys
+f etc/nodename 0644 root root
+d etc/svc 0755 root sys
+d etc/svc/profile 0755 root sys
+f etc/svc/profile/generic.xml 0444 root sys
+f etc/svc/profile/platform.xml 0444 root sys
+d etc/cron.d 0755 root sys
+d etc/cron.d/crontabs 0755 root sys
+f etc/cron.d/crontabs/root 0600 root root
+f etc/rtc_config 0644 root root
+f etc/minor_perm 0644 root sys
+d etc/default 0755 root sys
+f etc/default/init 0644 root sys
+f etc/default/login 0644 root sys
+f etc/default/passwd 0644 root sys
+d etc/bash 0755 root sys
+f etc/bash/bash_completion 0644 root sys
+d etc/bash/bash_completion.d 0755 root sys
+f etc/bash/bash_completion.d/machines 0644 root sys
+f etc/bash/bash_completion.d/vms 0644 root sys
+f etc/bash/bash_completion.d/zones 0644 root sys
+d etc/curl 0555 root sys
+f etc/curl/curlCA 0444 root sys
+f etc/dispadmin.conf 0644 root sys
+d etc/ssh 0755 root sys
+f etc/ssh/sshd_config 0644 root sys
+f etc/vfstab 0644 root sys
+f etc/shadow 0400 root sys
+f etc/zshrc 0644 root bin
+f etc/issue 0644 root sys
+d etc/skel 0755 root sys
+f etc/skel/.bashrc 0644 root other
+f etc/dumpadm.conf 0644 root other
+d etc/zones 0755 root sys
+f etc/zones/SUNWdefault.xml 0444 root bin
+f etc/resolv.conf 0644 netadm netadm
+d kernel/drv 0755 root sys
+f kernel/drv/cpqary3.conf 0644 root sys
+f kernel/drv/amd64/cpqary3 0755 root sys
+f kernel/drv/amd64/bnx 0755 root sys
+d usr/lib/localedef 0755 root bin
+d usr/lib/localedef/extensions 0755 root bin
+f usr/lib/localedef/extensions/UTF-8.x 0444 root bin
+d usr/lib/brand 0755 root bin
+d usr/lib/brand/joyent 0755 root bin
+f usr/lib/brand/joyent/manifests 0444 root root
+f usr/sbin/zonememstat 0555 root bin
+f usr/sbin/joycomm 0555 root bin
+f usr/bin/ack 0555 root bin
+f usr/bin/json 0555 root bin
+f usr/include/usb.h 0444 root bin
+f usr/share/man/man1/ack.1 0444 root bin
+f usr/share/man/man1/json.1 0444 root bin
+d lib/sdc 0755 root bin
+f lib/sdc/config.sh 0444 root bin
+f lib/sdc/network.sh 0444 root bin
+f lib/sdc/zone.sh 0444 root bin
+d lib/svc 0755 root bin
+f lib/svc/method/ipfilter 0555 root sys
+f lib/svc/method/sshd 0555 root bin
+f lib/svc/method/fs-usr 0555 root bin
+f lib/svc/method/smartdc-init 0555 root bin
+f lib/svc/method/identity-node 0555 root bin
+f lib/svc/method/manifest-import 0555 root bin
+f lib/svc/method/console-login 0555 root bin
+f lib/svc/method/sysidtool-net 0555 root bin
+f lib/svc/method/sysidtool-system 0555 root bin
+f lib/svc/method/fs-root 0555 root bin
+f lib/svc/method/smartdc-vmadmd 0555 root bin
+d lib/svc/manifest 0755 root sys
+d lib/svc/manifest/system 0755 root sys
+d lib/svc/manifest/network 0755 root sys
+d lib/svc/manifest/system 0755 root sys
+f lib/svc/manifest/system/smartdc-vmadmd.xml 0444 root bin
+f lib/svc/manifest/system/sysidtool.xml 0444 root sys
+f lib/svc/manifest/system/auditd.xml 0444 root sys
+d lib/svc/manifest/system/filesystem 0755 root sys
+f lib/svc/manifest/system/filesystem/joyent-fs.xml 0444 root sys
+f lib/svc/manifest/system/filesystem/minimal-fs.xml 0444 root sys
+f lib/svc/manifest/system/smartdc-config.xml 0444 root sys
+f lib/svc/manifest/system/smartdc-init.xml 0444 root sys
+f lib/svc/manifest/system/coreadm.xml 0444 root sys
+f lib/svc/manifest/system/console-login.xml 0444 root sys
+f lib/svc/manifest/network/network-physical.xml 0444 root sys
+f lib/svc/manifest/network/ipfilter.xml 0444 root sys
+d lib/svc/manifest/network/nfs 0755 root sys
+f lib/svc/manifest/network/nfs/client.xml 0444 root sys
+f lib/svc/manifest/network/nfs/nlockmgr.xml 0444 root sys
+f lib/svc/manifest/network/nfs/server.xml 0444 root sys
+f lib/svc/manifest/network/forwarding.xml 0444 root sys
+d var/ld 0755 root bin
+s var/ld/32=.
+s var/ld/64=amd64
+d var/ld/amd64 0755 root bin
+f var/ld/amd64/ld.config 0644 root root
View
0  overlay/usr/bin/ack → overlay/generic/usr/bin/ack
File renamed without changes
View
412 overlay/usr/bin/json → overlay/generic/usr/bin/json
@@ -5,7 +5,7 @@
// See <https://github.com/trentm/json>.
//
-var VERSION = "1.3.4";
+var VERSION = "1.4.1";
var sys = require('sys');
var pathlib = require('path');
@@ -39,13 +39,13 @@ function getVersion() {
}
function printHelp() {
- sys.puts("Usage: <something generating JSON on stdout> | json [options] [lookup]");
+ sys.puts("Usage: <something generating JSON on stdout> | json [options] [lookups...]");
sys.puts("");
- sys.puts("Pipe in your JSON for nicer output. Or supply a `lookup` to extract");
- sys.puts("a subset of the JSON. HTTP header blocks are skipped by default");
- sys.puts("(as from `curl -i`) by default.");
+ sys.puts("Pipe in your JSON for nicer output. Or supply one or more `lookups`");
+ sys.puts("to extract a subset of the JSON. HTTP header blocks (as from `curl -i`)");
+ sys.puts("are skipped by default.");
sys.puts("");
- sys.puts("By default, the output is JSON-y: JSON except for a simple string return");
+ sys.puts("By default, the output is JSON-y: JSON, except for a simple string return");
sys.puts("value, which is printed without quotes. Use '-j' or '-i' to override.");
sys.puts("");
sys.puts("Options:");
@@ -66,18 +66,20 @@ function printHelp() {
}
-// Parse the command-line options and arguments into an object.
-//
-// {
-// 'lookup': '...' // the first arg: lookup
-// 'extra': [...] // extra args put here
-// 'help': true, // true if '-h' option given
-// // etc.
-// }
+/**
+ * Parse the command-line options and arguments into an object.
+ *
+ * {
+ * 'args': [...] // arguments
+ * 'help': true, // true if '-h' option given
+ * // etc.
+ * }
+ *
+ * @return {Object} The parsed options. `.args` is the argument list.
+ */
function parseArgv(argv) {
var parsed = {
- lookup: null,
- extra: [],
+ args: [],
help: false,
quiet: false,
dropHeaders: false,
@@ -125,11 +127,7 @@ function parseArgv(argv) {
parsed.experimental = true;
break;
default: // arguments
- if (parsed.lookup === null) {
- parsed.lookup = arg;
- } else {
- parsed.extra.push(arg);
- }
+ parsed.args.push(arg);
break;
}
}
@@ -259,32 +257,28 @@ function parseLookup(lookup) {
* Process the input JSON object.
*
* @argument datum {Object} The parsed JSON object.
- * @argument args {Object} Command-line args from parseArgv.
+ * @argument rawLookup {String} The lookup string. Might be empty.
* @returns {Array} Array of filtered data.
*/
-//TODO: s/args/lookup/
-function processDatum(datum, args) {
- if (args.lookup) {
- var bits = parseLookup(args.lookup);
-
- // Put it back together with some convenience transformations.
- lookup = "";
- var isJSIdentifier = /^[$A-Za-z_][0-9A-Za-z_]*$/;
- for (var i=0; i < bits.length; i++) {
- var bit = bits[i];
- if (bit[0] === '[') {
- lookup += bit;
- } else if (! isJSIdentifier.exec(bits[i])) {
- // Allow a non-JS-indentifier token, e.g. `json foo-bar`.
- lookup += '["' + bits[i].replace('"', '\\"') + '"]';
- } else {
- lookup += '.' + bits[i];
- }
+function processDatum(datum, rawLookup) {
+ var bits = parseLookup(rawLookup);
+
+ // Put it back together with some convenience transformations.
+ lookup = "";
+ var isJSIdentifier = /^[$A-Za-z_][0-9A-Za-z_]*$/;
+ for (var i=0; i < bits.length; i++) {
+ var bit = bits[i];
+ if (bit[0] === '[') {
+ lookup += bit;
+ } else if (! isJSIdentifier.exec(bits[i])) {
+ // Allow a non-JS-indentifier token, e.g. `json foo-bar`.
+ lookup += '["' + bits[i].replace('"', '\\"') + '"]';
+ } else {
+ lookup += '.' + bits[i];
}
-
- datum = runInNewContext("(" + JSON.stringify(datum) + ")" + lookup);
}
-
+
+ datum = runInNewContext("(" + JSON.stringify(datum) + ")" + lookup);
return [datum];
}
@@ -295,61 +289,59 @@ function processDatum(datum, args) {
* - add support for '*' in lookup
*
* @argument datum {Object} The parsed JSON object.
- * @argument args {Object} Command-line args from parseArgv.
+ * @argument rawLookup {String} The lookup string. Might be empty.
* @returns {Array} Array of filtered data.
*/
-function processDatumExperimental(datum, args) {
+function processDatumExperimental(datum, rawLookup) {
var data = [datum];
- if (args.lookup) {
- var bits = parseLookup(args.lookup);
-
- var isJSIdentifier = /^[$A-Za-z_][0-9A-Za-z_]*$/;
- var i = 0;
- var lookup = "";
- while (i < bits.length) {
- var bit = bits[i];
- if (bit === '*') {
- if (lookup) {
- data = data.map(function(d) {
- return runInNewContext("(" + JSON.stringify(d) + ")" + lookup);
- }).filter(function(d) { return d !== undefined });
- lookup = "";
- }
- var newdata = [];
- data.forEach(function(d) {
- newdata = newdata.concat(d);
- });
- data = newdata;
- } else if (bit[0] === '[') {
- lookup += bit;
- } else if (! isJSIdentifier.exec(bits[i])) {
- // Allow a non-JS-indentifier token, e.g. `json foo-bar`.
- lookup += '["' + bits[i].replace('"', '\\"') + '"]';
- } else {
- lookup += '.' + bits[i];
- }
- i++;
- }
- if (lookup) {
- data = data.map(function(d) {
+ var bits = parseLookup(rawLookup);
+
+ var isJSIdentifier = /^[$A-Za-z_][0-9A-Za-z_]*$/;
+ var i = 0;
+ var lookup = "";
+ while (i < bits.length) {
+ var bit = bits[i];
+ if (bit === '*') {
+ if (lookup) {
+ data = data.map(function(d) {
return runInNewContext("(" + JSON.stringify(d) + ")" + lookup);
- }).filter(function(d) { return d !== null });
+ }).filter(function(d) { return d !== undefined });
+ lookup = "";
+ }
+ var newdata = [];
+ data.forEach(function(d) {
+ newdata = newdata.concat(d);
+ });
+ data = newdata;
+ } else if (bit[0] === '[') {
+ lookup += bit;
+ } else if (! isJSIdentifier.exec(bits[i])) {
+ // Allow a non-JS-indentifier token, e.g. `json foo-bar`.
+ lookup += '["' + bits[i].replace('"', '\\"') + '"]';
+ } else {
+ lookup += '.' + bits[i];
}
- return data;
+ i++;
+ }
+ if (lookup) {
+ data = data.map(function(d) {
+ return runInNewContext("(" + JSON.stringify(d) + ")" + lookup);
+ }).filter(function(d) { return d !== null });
}
+ return data;
}
/**
* TODO: doc this
*/
-function printData(data, args) {
+function printData(data, opts) {
// Print out results.
data.forEach(function(d) {
var output = null;
- if (args.outputSysInspect) {
+ if (opts.outputSysInspect) {
output = sys.inspect(d, false, Infinity, true);
- } else if (args.outputJSON) {
+ } else if (opts.outputJSON) {
if (typeof d !== 'undefined') {
output = JSON.stringify(d, null, 2);
}
@@ -361,234 +353,48 @@ function printData(data, args) {
}
}
if (output && output.length) {
- process.stdout.write(output);
- process.stdout.write('\n');
+ emit(output);
+ emit('\n');
}
})
}
-//---- minimatch
-// Make a regex for a given fnmatch-like string that git uses for .gitignore.
-// See `man 5 gitignore`.
-//
-// (This is `makeRe` from
-// <https://github.com/isaacs/npm/blob/master/lib/utils/minimatch.js>
-// at Isaac's suggestion.)
-
-function makeMinimatchRe (pattern) {
- var braceDepth = 0
- , re = ""
- , escaping = false
- , oneStar = "[^\\/]*?"
- , twoStar = ".*?"
- , reSpecials = "().*{}+?[]^$/\\"
- , patternListStack = []
- , stateChar
- , negate = false
- , negating = false
-
- for ( var i = 0, len = pattern.length, c
- ; (i < len) && (c = pattern.charAt(i))
- ; i ++ ) {
-
- switch (c) {
- case "\\":
- if (escaping) {
- re += "\\\\" // must match literal \
- escaping = false
- } else {
- escaping = true
- }
- continue
-
- case "!":
- if (i === 0 || negating) {
- negate = !negate
- negating = true
- break
- }
- // fallthrough
- case "+":
- case "@":
- case "*":
- case "?":
- negating = false
- if (escaping) {
- re += "\\" + c
- escaping = false
- } else {
- if (c === "*" && stateChar === "*") { // **
- re += twoStar
- stateChar = false
- } else {
- stateChar = c
- }
- }
- continue
-
- case "(":
- if (escaping) {
- re += "\\("
- escaping = false
- } else if (stateChar) {
- plType = stateChar
- patternListStack.push(plType)
- re += stateChar === "!" ? "(?!" : "(:?"
- stateChar = false
- } else {
- re += "\\("
- }
- continue
-
- case ")":
- if (escaping) {
- re += "\\)"
- escaping = false
- } else if (patternListStack.length) {
- re += ")"
- plType = patternListStack.pop()
- switch (plType) {
- case "?":
- case "+":
- case "*": re += plType
- case "!":
- case "@": break
- }
- } else {
- re += "\\)"
- }
- continue
-
- case "|":
- if (escaping) {
- re += "\\|"
- escaping = false
- } else if (patternListStack.length) {
- re += "|"
- } else {
- re += "\\|"
- }
- continue
-
- // turns out these are the same in regexp and glob :)
- case "]":
- case "[":
- if (escaping) {
- re += "\\" + c
- escaping = false
- } else {
- re += c
- }
- continue
-
- case "{":
- if (escaping) {
- re += "\\{"
- escaping = false
- } else {
- re += "(:?"
- braceDepth ++
- }
- continue
-
- case "}":
- if (escaping || braceDepth === 0) {
- re += "\\}"
- escaping = false
- } else {
- re += ")"
- braceDepth --
- }
- continue
-
- case ",":
- if (escaping || braceDepth === 0) {
- re += ","
- escaping = false
- } else {
- re += "|"
- }
- continue
-
- default:
- if (stateChar) {
- // we had some state-tracking character
- // that wasn't consumed by this pass.
- switch (stateChar) {
- case "*":
- re += oneStar
- break
- case "?":
- re += "."
- break
- default:
- re += "\\"+stateChar
- break
- }
- stateChar = false
- }
- if (escaping) {
- // no need
- escaping = false
- } else if (reSpecials.indexOf(c) !== -1) {
- re += "\\"
- }
- re += c
- } // switch
-
- if (negating && c !== "!") negating = false
-
- } // for
-
- // handle trailing things that only matter at the very end.
- if (stateChar) {
- // we had some state-tracking character
- // that wasn't consumed by this pass.
- switch (stateChar) {
- case "*":
- re += oneStar
- break
- case "?":
- re += "."
- break
- default:
- re += "\\"+stateChar
- break
- }
- stateChar = false
- } else if (escaping) {
- re += "\\\\"
+function emit(s) {
+ try {
+ process.stdout.write(s);
+ } catch (e) {
+ // Handle any exceptions in stdout writing in the "error" event above.
}
-
- // must match entire pattern
- // ending in a * or ** will make it less strict.
- re = "^" + re + "$"
-
- // fail on the pattern, but allow anything otherwise.
- if (negate) re = "^(!?" + re + ").*$"
-
- return new RegExp(re)
}
+process.stdout.on("error", function (err) {
+ if (err.code === "EPIPE") {
+ // Pass. See <https://github.com/trentm/json/issues/9>.
+ } else {
+ warn(err)
+ process.exit(1);
+ }
+});
+
//---- mainline
function main(argv) {
- var args = parseArgv(argv);
- //warn(args);
- if (args.help) {
+ var opts = parseArgv(argv);
+ //warn(opts);
+ if (opts.help) {
printHelp();
return;
}
- if (args.version) {
+ if (opts.version) {
sys.puts("json " + getVersion());
return;
}
- if (args.extra.length) {
- sys.puts("json: error: too many arguments: extra="+args.extra);
- process.exit(1);
+ var lookups = opts.args;
+ if (lookups.length == 0) {
+ lookups.push("");
}
var buffer = "";
@@ -610,8 +416,8 @@ function main(argv) {
sepLen = 2;
}
if (index != -1) {
- if (! args.dropHeaders) {
- process.stdout.write(buffer.slice(0, index+sepLen));
+ if (! opts.dropHeaders) {
+ emit(buffer.slice(0, index+sepLen));
}
var is100Continue = (buffer.slice(0, 21) === "HTTP/1.1 100 Continue");
buffer = buffer.slice(index+sepLen);
@@ -632,28 +438,28 @@ function main(argv) {
datum = JSON.parse(buffer);
} catch(ex) {
// Doesn't look like JSON. Just print it out and move on.
- if (! args.quiet) {
+ if (! opts.quiet) {
warn("json: error: doesn't look like JSON: "+ex+" (buffer="+JSON.stringify(buffer)+")");
}
- process.stdout.write(buffer);
+ emit(buffer);
if (buffer.length && buffer[buffer.length-1] !== "\n") {
- process.stdout.write('\n');
+ emit('\n');
}
process.stdout.flush();
process.exit(1);
}
// Process the JSON data.
- if (args.experimental) {
- var outputData = processDatumExperimental(datum, args);
- } else {
- var outputData = processDatum(datum, args);
+ var outputData;
+ var processor = (opts.experimental ? processDatumExperimental : processDatum);
+ for (var i=0; i < lookups.length; i++) {
+ outputData = processor(datum, lookups[i]);
+ // Emit the filtered data.
+ printData(outputData, opts);
}
-
- // Emit the filtered data.
- printData(outputData, args);
});
+ // TODO: this isn't sufficient to ensure all output is flushed.
process.on('exit', function () {
process.stdout.flush();
});
View
0  overlay/usr/include/usb.h → overlay/generic/usr/include/usb.h
File renamed without changes
View
0  overlay/usr/lib/brand/joyent/manifests → overlay/generic/usr/lib/brand/joyent/manifests
File renamed without changes
View
0  overlay/usr/lib/localedef/extensions/UTF-8.x → overlay/generic/usr/lib/localedef/extensions/UTF-8.x
File renamed without changes
View
116 overlay/generic/usr/sbin/joycomm
@@ -0,0 +1,116 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2011 Joyent, Inc. All rights reserved.
+#
+
+PATH=/usr/bin:/usr/sbin
+export PATH
+unset LD_LIBRARY_PATH
+
+OPT_V=0
+OPT_X=0
+while getopts "R:vx" opt
+do
+ case "$opt" in
+ R) DAYS="$OPTARG";;
+ v) OPT_V="1";;
+ x) OPT_X="1";;
+ *) echo "usage: [-R days] [-v] [-x]"
+ exit 1
+ ;;
+ esac
+done
+shift OPTIND-1
+
+if [[ -n $DAYS ]]; then
+ # Rotate and trim the audit logs
+ audit -n
+ cd /var/audit
+ find . -mtime +$DAYS -exec rm -f "{}" \;
+ exit 0
+fi
+
+f=`ls /var/audit/* | wc -l`
+if [ $f -eq 0 ]; then
+ echo "no audit files"
+ exit 0
+fi
+
+if [ $OPT_X -eq 1 ]; then
+ files=/var/audit/*
+else
+ files=`ls -t /var/audit/*not* | head -1`
+fi
+
+for i in $files
+do
+ praudit -x $i | nawk -v verbose=$OPT_V '{
+ if ($1 == "<record") {
+ pos = index($0, "iso8601=");
+ if (pos == 0) {
+ dt = "ND";
+ } else {
+ tstr=substr($0, pos + 9)
+ split(tstr, da);
+ dt = da[1] " " da[2];
+ }
+ printf("%s ", dt);
+
+ if ($3 == "event=\"login")
+ cmd="<login>";
+ else if ($3 == "event=\"logout\"")
+ cmd="<logout>";
+ else if ($3 == "event=\"system")
+ cmd="- - <boot>";
+ } else if ($1 == "<subject") {
+ pos = index($0, "tid=");
+ if (pos == 0) {
+ id = "NID";
+ } else {
+ tstr=substr($0, pos + 5)
+ tstr=substr(tstr, 1, length(tstr) - 3)
+ split(tstr, addr);
+ id = addr[1] " " addr[3];
+ }
+ printf("%s ", id);
+ } else if (substr($1, 1, 6) == "<path>") {
+ if (verbose == 1)
+ next;
+ cmd=substr($1, 7);
+ cmd=substr(cmd, 1, length(cmd) - 7);
+
+ } else if (substr($1, 1, 11) == "<exec_args>") {
+ if (verbose == 0)
+ next;
+ cmd=substr($0, 17)
+ pos = index(cmd, "</arg><arg>");
+ while (pos != 0) {
+ head=substr(cmd, 1, pos - 1);
+ tail=substr(cmd, pos + 11, length(cmd));
+ cmd=head " " tail;
+ pos = index(cmd, "</arg><arg>");
+ }
+ } else if ($1 == "</record>") {
+ printf("%s\n", cmd);
+ }
+ }'
+done
View
0  overlay/usr/sbin/zonememstat → overlay/generic/usr/sbin/zonememstat
File renamed without changes
View
0  overlay/usr/share/man/man1/ack.1 → overlay/generic/usr/share/man/man1/ack.1
File renamed without changes
View
0  overlay/usr/share/man/man1/json.1 → overlay/generic/usr/share/man/man1/json.1
File renamed without changes
View
0  overlay/var/ld/amd64/ld.config → overlay/generic/var/ld/amd64/ld.config
File renamed without changes
View
0  overlay/var/ld/ld.config → overlay/generic/var/ld/ld.config
File renamed without changes
View
18 overlay/lib/svc/method/fs-joyent → overlay/smartos/lib/svc/method/fs-joyent
@@ -50,17 +50,23 @@ if [ $? -ne 0 ]; then
# pool's root dataset), then use that system pool instead.
SYS_ZPOOL=zones
- # Import all zpools available
- for pool in $(zpool import | grep "pool:" | awk '{print $2}') ; do
+ # Import specified zpools, or all zpools available
+ pools=$(/bin/bootparams | egrep "^zpools?=" | cut -d= -f2 | tr , ' ')
+ if [ -z ${pools} ]; then
+ pools=$(zpool import | grep "pool:" | awk '{print $2}')
+ fi
+
+ for pool in $pools; do
zpool import -f $pool
- if [[ -f /$pool/.system_pool ]] ; then
+ if [[ -f /$pool/.system_pool ]]; then
SYS_ZPOOL=$pool
- svccfg -s svc:/system/smartdc/init setprop \
- config/zpool=${SYS_ZPOOL}
- svccfg -s svc:/system/smartdc/init:default refresh
fi
done
+ svccfg -s svc:/system/smartdc/init setprop \
+ config/zpool=${SYS_ZPOOL}
+ svccfg -s svc:/system/smartdc/init:default refresh
+
# If the destroy_zpools boot parameter is set, destroy all zpools
/bin/bootparams | grep "^destroy_zpools=true" >/dev/null
if [ $? -eq 0 ]; then
View
0  overlay/lib/svc/method/net-physical → overlay/smartos/lib/svc/method/net-physical
File renamed without changes
View
0  overlay/lib/svc/method/smartdc-config → overlay/smartos/lib/svc/method/smartdc-config
File renamed without changes
View
13 overlay/smartos/manifest
@@ -0,0 +1,13 @@
+d lib/ 0755 root bin
+d lib/svc 0755 root bin
+d lib/svc/method 0755 root bin
+f lib/svc/method/fs-joyent 0555 root bin
+f lib/svc/method/smartdc-config 0555 root bin
+f lib/svc/method/net-physical 0555 root bin
+d smartdc 0755 root bin
+d smartdc/bin 0755 root bin
+f smartdc/bin/smartos_prompt_config.sh 0555 root bin
+d root 0755 root root
+f root/.bash_profile 0644 root root
+f root/.bashrc 0644 root root
+f root/.profile 0644 root root
View
0  overlay/admin/.bash_profile → overlay/smartos/root/.bash_profile
File renamed without changes
View
0  overlay/admin/.bashrc → overlay/smartos/root/.bashrc
File renamed without changes
View
0  overlay/admin/.profile → overlay/smartos/root/.profile
File renamed without changes
View
0  overlay/smartdc/bin/smartos_prompt_config.sh → overlay/smartos/smartdc/bin/smartos_prompt_config.sh
File renamed without changes
View
BIN  overlay/usr/lib/amd64/libCrun.so.1
Binary file not shown
View
BIN  overlay/usr/lib/libCrun.so.1
Binary file not shown
View
12 src/Makefile
@@ -1,10 +1,11 @@
CC=gcc
CFLAGS=-Wall
-TARGETS=bootparams disklist removable_disk disk_size has_hvx
+TARGETS=bootparams disklist removable_disk disk_size node-kstat/build/default/kstat.node
SMARTDC_TARGETS=has_hvx
DESTDIR=../proto
+NODE_WAF=$(PWD)/../proto/usr/bin/node-waf
-all: $(TARGETS) sysinfo
+all: $(TARGETS) sysinfo $(SMARTDC_TARGETS)
install: $(TARGETS) sysinfo
mkdir -p $(DESTDIR)/usr/bin
@@ -16,10 +17,12 @@ install: $(TARGETS) sysinfo
cp vmadmd.js $(DESTDIR)/usr/lib/vmadmd
cp vmadm.js $(DESTDIR)/usr/sbin/vmadm
cp vmcfg.js $(DESTDIR)/usr/sbin/vmcfg
- cp create-machine.js $(DESTDIR)/usr/sbin/create-machine
+ cp machine/machine-create.js $(DESTDIR)/usr/sbin/machine-create
cp machine/machine-json.js $(DESTDIR)/usr/sbin/machine-json
+ cp machine/machine-lookup.js $(DESTDIR)/usr/sbin/machine-lookup
mkdir -m 0755 -p $(DESTDIR)/usr/node_modules
find node_modules -type f -exec cp {} $(DESTDIR)/usr/node_modules/ \;
+ cp node-kstat/build/default/kstat.node $(DESTDIR)/usr/node_modules/
check:
@tools/node-lint/bin/node-lint *.js \
@@ -37,6 +40,9 @@ disk_size: disk_size.c
has_hvx: has_hvx.c
$(CC) $(CFLAGS) -o $@ $^
+node-kstat/build/default/kstat.node: node-kstat/kstat.cc $(NODE_WAF)
+ (cd node-kstat && $(NODE_WAF) configure && $(NODE_WAF) build)
+
disklist:
cp disklist.sh disklist
chmod 0755 disklist
View
319 src/create-machine.js → src/machine/machine-create.js 100755 → 100644
@@ -77,8 +77,8 @@
* the zone/vm.
* - default: {}
*
- * "default_gateway"
- * - The IP Address of the router that should act as the default gateway
+ * "hostname"
+ * - The hostname for this machine
*
* "limit_priv"
* - a comma separated list of priviledges to give this zone
@@ -107,15 +107,16 @@
* - array of ports on which this nic is prevented from sending traffic.
* - default: []
* nic.gateway
- * - The IPv4 router on this network
+ * - The IPv4 router on this network (not required if using DHCP)
* nic.ip
- * - IPv4 unicast address for this NIC
+ * - IPv4 unicast address for this NIC, or 'dhcp' to obtain address
+ * via DHCP
* nic.mac
* - MAC address of virtual NIC (we'll generate one by default)
* nic.model
* - The driver for this NIC [virtio|e1000|rtl8136|...]
* nic.netmask
- * - The netmask for this NIC's network
+ * - The netmask for this NIC's network (not required if using DHCP)
* nic.vlan_id
* - The vlan with which to tag this NIC's traffic (0 = none)
* - default: 0
@@ -200,13 +201,14 @@
* Zones Only
* ==========
*
+ * "delegate_dataset"
+ * - boolean value (default: false) that determines whether we should also
+ * create a <zonepath>/data dataset and delegate that to the zone.
+ *
* "dns_domain"
* - The DNS domain name of this machine (for /etc/hosts)
* - default here is .local
*
- * "hostname"
- * - The hostname portion of the /etc/hosts entry for this machine
- *
* "tmpfs"
* - The maximum number of MiB to use for the /tmp filesystem
*
@@ -236,7 +238,8 @@
* "model": "virtio",
* "ip": "10.88.88.51",
* "netmask": "255.255.255.0",
- * "gateway": "10.88.88.2"
+ * "gateway": "10.88.88.2",
+ * "primary": 1
* }
* ]
* }
@@ -254,7 +257,8 @@
* "nic_tag": "external",
* "ip": "10.88.88.52",
* "netmask": "255.255.255.0",
- * "gateway": "10.88.88.2"
+ * "gateway": "10.88.88.2",
+ * "primary": 1
* }
* ]
* }
@@ -276,6 +280,7 @@ var net = require('net');
var onlyif = require('onlyif');
var spawn = cp.spawn;
var sys = require('sys');
+var system = require('system');
var logfile = null;
@@ -327,12 +332,29 @@ function debug()
function usage()
{
process.stderr.write('Usage: ' + process.argv[1] +
- '-f <filename.json>\n\n');
+ ' -f <filename.json>\n\n');
process.stderr.write('This tool will create either a VM or Zone based on ' +
'a JSON payload.\n');
process.exit(1);
}
+function ltrim(str, chars) {
+ chars = chars || "\\s";
+ str = str || "";
+ return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
+}
+
+function rtrim(str, chars) {
+ chars = chars || "\\s";
+ str = str || "";
+ return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
+}
+
+function trim(str, chars)
+{
+ return ltrim(rtrim(str, chars), chars);
+}
+
// XXX Lifted from vmadm.js, need to merge the implementations.
function performVmadmdAction(action, data, callback)
{
@@ -461,6 +483,69 @@ function checkDatasets(payload, progress, callback)
});
}
+function checkItemUnused(item, type, lookup_arg, callback)
+{
+ exec('/usr/sbin/machine-lookup ' + lookup_arg + ' ' + item,
+ function (err, stdout, stderr)
+ {
+ if (!err) {
+ // exit 0 means used!
+ return callback(null, false, stdout);
+ }
+ if (err.code === 1) {
+ // does not exist!
+ return callback(null, true);
+ } else {
+ // don't know, so assume unused
+ debug('Warning: unable to determine if ' + type +
+ ' is used, assuming unused.');
+ return callback(null, true);
+ }
+ }
+ );
+}
+
+function checkIpUnused(ip, callback)
+{
+ return checkItemUnused(ip, 'IP', '-i', callback);
+}
+
+function checkMacUnused(mac, callback)
+{
+ return checkItemUnused(mac, 'MAC', '-m', callback);
+}
+
+function checkItemsUnused(items, type, func, callback)
+{
+ async.forEach(items,
+ function (item, cb)
+ {
+ func(item, function (err, unused, stdout) {
+ if (err) {
+ return cb(err);
+ } else if (!unused) {
+ if (stdout) {
+ return cb(type + ' ' + item + ' is already in use by ' +
+ trim(stdout));
+ } else {
+ return cb(type + ' ' + item + ' is already in use.');
+ }
+ } else {
+ return cb();
+ }
+ });
+ },
+ function (err)
+ {
+ // checked all macs.
+ if (err) {
+ return callback(err);
+ }
+ return callback();
+ }
+ );
+}
+
// create a new LVM volume, updating progress
function createVolume(volume, progress, callback)
{
@@ -567,17 +652,26 @@ function saveMetadata(zone, progress, callback)
var zonepath = zone.zone_path = '/' + zone.zfs_storage_pool_name + '/' +
zone.zonename;
var mdata_filename = zonepath + '/config/metadata.json';
- var mdata;
+ var tags_filename = zonepath + '/config/tags.json';
+ var mdata, tags;
if (zone.hasOwnProperty('customer_metadata')) {
- debug('saveMetadata() --', zone.customer_metadata);
+ debug('saveMetadata(customer_metadata) --', zone.customer_metadata);
mdata = {"customer_metadata": zone.customer_metadata};
} else {
debug('saveMetadata() -- no metadata, using {}');
mdata = {"customer_metadata": {}};
}
+ if (zone.hasOwnProperty('tags')) {
+ debug('saveMetadata(tags) --', zone.tags);
+ tags = zone.tags;
+ } else {
+ debug('saveMetadata() -- no tags, using {}');
+ tags = {};
+ }
+
fs.writeFile(mdata_filename, JSON.stringify(mdata, null, 2),
function (err)
{
@@ -585,7 +679,15 @@ function saveMetadata(zone, progress, callback)
return callback(err);
}
debug('wrote metadata to', mdata_filename);
- callback();
+ fs.writeFile(tags_filename, JSON.stringify(tags, null, 2),
+ function (err) {
+ if (err) {
+ return callback(err);
+ }
+ debug('wrote tags to', tags_filename);
+ callback();
+ }
+ );
}
);
}
@@ -664,15 +766,28 @@ function nicZonecfg(nic, idx, callback)
'set global-nic=' + nic.nic_tag + '\n' +
'set mac-addr=' + nic.mac + '\n' +
'add property (name=index, value="' + idx + '")\n' +
- 'add property (name=netmask, value="' + nic.netmask + '")\n' +
- 'add property (name=ip, value="' + nic.ip + '")\n' +
- 'add property (name=gateway, value="' + nic.gateway + '")\n';
+ 'add property (name=ip, value="' + nic.ip + '")\n';
+
+ if (nic.hasOwnProperty('netmask')) {
+ zonecfg = zonecfg +
+ 'add property (name=netmask, value="' + nic.netmask + '")\n';
+ }
+
+ if (nic.hasOwnProperty('gateway') && nic.gateway.length > 0) {
+ zonecfg = zonecfg +
+ 'add property (name=gateway, value="' + nic.gateway + '")\n';
+ }
if (nic.hasOwnProperty('model')) {
zonecfg = zonecfg +
'add property (name=model, value="' + nic.model + '")\n';
}
+ if (nic.hasOwnProperty('primary')) {
+ zonecfg = zonecfg +
+ 'add property (name=primary, value="' + nic.primary + '")\n';
+ }
+
if (nic.hasOwnProperty('vlan_id') && (nic.vlan_id !== "0")) {
zonecfg = zonecfg + 'set vlan-id=' + nic.vlan_id + '\n';
}
@@ -707,16 +822,17 @@ function writeZoneconfig(payload, callback)
'HOSTNAME=' + payload.hostname + '.' + payload.dns_domain + '\n' +
'TMPFS=' + payload.tmpfs + 'm\n';
- if (payload.nics[0]) {
+ if (payload.nics[0] && payload.nics[0].ip != 'dhcp') {
data = data + 'PUBLIC_IP=' + payload.nics[0].ip + '\n';
}
- if (payload.nics[1]) {
+ if (payload.nics[1] && payload.nics[1].ip != 'dhcp') {
data = data + 'PRIVATE_IP=' + payload.nics[1].ip + '\n';
- } else if (payload.nics[0]) {
+ } else if (payload.nics[0] && payload.nics[0].ip != 'dhcp') {
// zoneinit uses private_ip for /etc/hosts, we want to
// make that same as public, if there's no actual private.
data = data + 'PRIVATE_IP=' + payload.nics[0].ip + '\n';
}
+
if (payload.hasOwnProperty('resolvers')) {
// zoneinit appends to resolv.conf rather than overwriting, so just
// add to the zoneconfig and let zoneinit handle it
@@ -724,31 +840,37 @@ function writeZoneconfig(payload, callback)
}
nic_idx = 0;
+ primary_found = false;
for (nic in payload.nics) {
if (payload.nics.hasOwnProperty(nic)) {
n = payload.nics[nic];
+ data = data + 'NET' + nic_idx + '_MAC=' + n.mac + '\n'
+ + 'NET' + nic_idx + '_INTERFACE=NET' + nic_idx + '\n';
- fs.writeFileSync(payload.zone_path + '/root/etc/hostname.net' +
- nic_idx, n.ip + ' netmask ' + n.netmask + ' up' + '\n');
+ if (n.ip != 'dhcp') {
+ fs.writeFileSync(payload.zone_path + '/root/etc/hostname.net' +
+ nic_idx, n.ip + ' netmask ' + n.netmask + ' up' + '\n');
+ data = data + 'NET' + nic_idx + '_IP=' + n.ip + '\n'
+ + 'NET' + nic_idx + '_NETMASK=' + n.netmask + '\n';
+ }
- if (n.hasOwnProperty('gateway')) {
- fs.writeFileSync(payload.zone_path + '/root/etc/defaultrouter',
- n.gateway + '\n');
+ if (n.hasOwnProperty('primary') && !primary_found) {
+ // only allow one primary network
+ primary_found = true;
+ if (n.hasOwnProperty('gateway')) {
+ fs.writeFileSync(payload.zone_path + '/root/etc/defaultrouter',
+ n.gateway + '\n');
+ }
+ if (n.ip == 'dhcp') {
+ fs.writeFileSync(payload.zone_path + '/root/etc/dhcp.net' +
+ nic_idx, '');
+ }
}
- data = data + 'NET' + nic_idx + '_IP=' + n.ip + '\n'
- + 'NET' + nic_idx + '_NETMASK=' + n.netmask + '\n'
- + 'NET' + nic_idx + '_MAC=' + n.mac + '\n'
- + 'NET' + nic_idx + '_INTERFACE=NET' + nic_idx + '\n';
nic_idx++;
}
}
- if (payload.hasOwnProperty('default_gateway')) {
- fs.writeFileSync(payload.zone_path + '/root/etc/defaultrouter',
- payload.default_gateway + '\n');
- }
-
debug('writing extra files to zone root');
fs.writeFileSync(payload.zone_path + '/root/etc/nodename',
payload.hostname);
@@ -1106,6 +1228,12 @@ function applyZoneDefaults(payload)
if (!payload.hasOwnProperty('tmpfs')) {
payload.tmpfs = 256;
}
+ if (!payload.hasOwnProperty('delegate_dataset')) {
+ payload.delegate_dataset = false;
+ } else {
+ // ensure boolean
+ payload.delegate_dataset = !!payload.delegate_dataset;
+ }
}
if (!payload.hasOwnProperty('limit_priv')) {
@@ -1153,15 +1281,22 @@ function applyZoneDefaults(payload)
function checkProperties(payload, callback)
{
- var disk, zvol, nic, n;
+ var disk, zvol, nic, n, macs = [], ips = [];
- // TODO check for missing keys and reused IP addresses
+ if (payload.brand === 'kvm' && payload.hasOwnProperty('available_MiB')) {
+ if (payload.available_MiB < payload.ram) {
+ return callback("VM 'ram' value: " + payload.ram + ' is less than' +
+ ' available memory: ' + payload.available_MiB);
+ } else {
+ debug('memory ok:', payload.ram, 'have:', payload.available_MiB);
+ }
+ }
if (payload.max_locked_memory > payload.max_physical_memory) {
- callback('max_locked_memory must be <= max_physical_memory');
+ return callback('max_locked_memory must be <= max_physical_memory');
}
if (payload.max_swap < payload.max_physical_memory) {
- callback('max_swap must be >= max_physical_memory');
+ return callback('max_swap must be >= max_physical_memory');
}
for (disk in payload.disks) {
@@ -1171,7 +1306,7 @@ function checkProperties(payload, callback)
if (payload.brand === 'kvm' && (!zvol.hasOwnProperty('model') ||
zvol.model === 'undefined')) {
- callback('missing .model option for disk: ' +
+ return callback('missing .model option for disk: ' +
JSON.stringify(zvol));
}
}
@@ -1181,16 +1316,67 @@ function checkProperties(payload, callback)
if (payload.nics.hasOwnProperty(nic)) {
n = payload.nics[nic];
+ if (n.hasOwnProperty('mac')) {
+ macs.push(n.mac);
+ }
+
+ if (n.hasOwnProperty('ip')) {
+ ips.push(n.ip);
+ }
+
if (payload.brand === 'kvm' && (!n.hasOwnProperty('model') ||
n.model === 'undefined')) {
- callback('missing .model option for NIC: ' +
+ return callback('missing .model option for NIC: ' +
JSON.stringify(n));
}
}
}
- callback();
+ // ensure MACs and IPs are not already used on this machine
+ // NOTE: can't check other machines currently.
+
+ checkItemsUnused(macs, 'MAC', checkMacUnused, function (err) {
+ if (err) {
+ return callback(err);
+ }
+ checkItemsUnused(ips, 'IP', checkIpUnused, function (err) {
+ if (err) {
+ return callback(err);
+ }
+ callback();
+ });
+ });
+}
+
+function addDelegatedDataset(payload, callback)
+{
+ var dataset;
+
+ if (payload.delegate_dataset) {
+ dataset = payload.zone_path.substr(1) + '/data';
+ debug('adding delegated dataset ' + dataset);
+
+ exec('zfs create -o compression=on ' + dataset, function (error, stdout, stderr) {
+ if (error) {
+ return callback('failed adding delegated dataset. stdout: ' +
+ stdout + ' stderr: ' + stderr);
+ }
+
+ zoneCfg(payload.zonename, 'add dataset; set name=' + dataset + '; end\n',
+ function (err, stdout, stderr) {
+ if (err) {
+ return callback('Failed to add delegated dataset. ' +
+ 'stdout: ' + stdout + ' stderr: ' + stderr);
+ }
+
+ return callback();
+ }
+ );
+ });
+ } else {
+ return callback();
+ }
}
// create and install a 'joyent' or 'kvm' brand zone.
@@ -1251,13 +1437,6 @@ function createZone(payload, progress, callback)
'"; end\n';
}
- if (payload.hasOwnProperty('tags')) {
- zonecfg = zonecfg + 'add attr; set name="tags"; ' +
- 'set type=string; set value="' +
- new Buffer(JSON.stringify(payload.tags)).toString('base64') +
- '"; end\n';
- }
-
if (payload.hasOwnProperty('tmpfs')) {
zonecfg = zonecfg + 'add attr; set name="tmpfs"; ' +
'set type=string; set value="' + payload.tmpfs.toString() + '"; end\n';
@@ -1406,16 +1585,21 @@ function createZone(payload, progress, callback)
}
if (payload.brand === 'joyent') {
writeZoneconfig(payload, function (err, result) {
- if (payload.autoboot) {
- bootZone(payload, function(e, res) {
- if (e) {
- return callback(e);
- }
+ addDelegatedDataset(payload, function (err) {
+ if (err) {
+ return callback(err);
+ }
+ if (payload.autoboot) {
+ bootZone(payload, function(e, res) {
+ if (e) {
+ return callback(e);
+ }
+ return callback(null, [stdout, stderr]);
+ });
+ } else {
return callback(null, [stdout, stderr]);
- });
- } else {
- return callback(null, [stdout, stderr]);
- }
+ }
+ });
});
} else if (payload.brand === 'kvm') {
// bootZone will only boot kvm zones if autoboot === true, but
@@ -1532,14 +1716,23 @@ function main()
payload = JSON.parse(data.toString());
assignMACs(payload);
applyZoneDefaults(payload);
- checkProperties(payload, function (err) {
+ system.getProvisionableMemory(function (err, available_MiB) {
if (err) {
- output('failure', 'unable to validate properties',
- {'error': err});
- process.exit(1);
+ output('notice', 'WARNING: unable to determine system memory ' +
+ 'usage, assuming we have sufficient memory.');
+ payload.available_MiB = payload.ram;
+ } else {
+ payload.available_MiB = available_MiB;
}
- createMachine(payload);