Skip to content

Commit

Permalink
Make ui plugin installation optional
Browse files Browse the repository at this point in the history
When multiple vic appliances are installed, we need to make
ui plugin installation optional on individual appliance,so
users can decide which ui plugin should be installed or upgraded
for later use.
  • Loading branch information
wjun committed Aug 29, 2018
1 parent 1ce8dbe commit 6ec823c
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 32 deletions.
5 changes: 5 additions & 0 deletions installer/build/bootable/build-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ function build_app {
SOURCE=$(jq '.['$LINE_NUM'] | .source' "${MANIFEST}" | tr -d '"')
DESTINATION=$(echo "${ROOT}/$(cat "${MANIFEST}" | jq '.['$LINE_NUM'] | .destination')" | tr -d '"' )
mkdir -p "$(dirname "$DESTINATION")" && cp -R $SOURCE "$DESTINATION"
if [[ "$DESTINATION" == *"fileserver/html"* ]]; then
pushd $DESTINATION
rm -fr .gitignore karma* package* js/fixtures js/specs
popd
fi
fi
LINE_NUM=$((LINE_NUM+1))
done
Expand Down
2 changes: 2 additions & 0 deletions installer/build/build-ova.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ drone deploy --param VICENGINE=${BUILD_VICENGINE_URL:-} \\
--param VIC_MACHINE_SERVER=${BUILD_VIC_MACHINE_SERVER_REVISION:-} \\
--param ADMIRAL=${BUILD_ADMIRAL_REVISION:-} \\
--param HARBOR=${BUILD_HARBOR_URL:-} \\
--param VICUI=${BUILD_VICUI_URL:-} \\
vmware/vic-product ${DRONE_BUILD_NUMBER:-} staging
EOF
elif [ "deployment" == "${DRONE_BUILD_EVENT}" -a "staging" == "${DRONE_DEPLOY_TO}" ]; then
Expand All @@ -156,6 +157,7 @@ drone deploy --param VICENGINE=${BUILD_VICENGINE_URL:-} \\
--param VIC_MACHINE_SERVER=${BUILD_VIC_MACHINE_SERVER_REVISION:-} \\
--param ADMIRAL=${BUILD_ADMIRAL_REVISION:-} \\
--param HARBOR=${BUILD_HARBOR_URL:-} \\
--param VICUI=${BUILD_VICUI_URL:-} \\
vmware/vic-product ${DRONE_BUILD_NUMBER:-} release
EOF
fi
29 changes: 22 additions & 7 deletions installer/build/scripts/upgrade/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ DESTROY_ENABLED=""
MANUAL_DISK_MOVE=""
EMBEDDED_PSC=""
INSECURE_SKIP_VERIFY=""
UPGRADE_UI_PLUGIN=""

TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S %z %Z")
export REDIRECT_ENABLED=0
Expand Down Expand Up @@ -93,11 +94,13 @@ function callPluginUpgradeEndpoint {
local preset=$1
local vc='{"target":"'"${VCENTER_TARGET}"'","user":"'"${VCENTER_USERNAME}"'","password":"'"${VCENTER_PASSWORD}"'","thumbprint":"'"${VCENTER_FINGERPRINT}"'"}'
local plugin='{"preset":"'"${preset}"'","force":true}'
local payload='{"vc":'${vc}',"plugin":'${plugin}'}'
local payload='{"vc":"${vc}","plugin":"${plugin}"}'
echo "register payload - ${payload}" | sed -e 's/'${VCENTER_PASSWORD}'/***/g' >> $upgrade_log_file 2>&1
/usr/bin/curl \
-k \
--write-out '%{http_code}' \
-s \
-o /dev/null \
--write-out "%{http_code}\\n" \
--header "Content-Type: application/json" \
-X POST \
--data "${payload}" \
Expand Down Expand Up @@ -140,10 +143,12 @@ function upgradeAppliancePlugin {

function callRegisterEndpoint {
local payload='{"target":"'"${VCENTER_TARGET}"'","user":"'"${VCENTER_USERNAME}"'","password":"'"${VCENTER_PASSWORD}"'","thumbprint":"'"${VCENTER_FINGERPRINT}"'","externalpsc":"'"${EXTERNAL_PSC}"'","pscdomain":"'"${PSC_DOMAIN}"'"}'
echo "register payload - ${payload}" | sed -e 's/'${VCENTER_PASSWORD}'/***/g' >> $upgrade_log_file 2>&1
echo "register payload - ${payload}" | sed -e 's/"${VCENTER_PASSWORD}"/***/g' >> $upgrade_log_file 2>&1
/usr/bin/curl \
-k \
--write-out '%{http_code}' \
-s \
-o /dev/null \
--write-out "%{http_code}\\n" \
--header "Content-Type: application/json" \
-X POST \
--data "${payload}" \
Expand Down Expand Up @@ -538,6 +543,9 @@ function main {
--ssh-insecure-skip-verify)
INSECURE_SKIP_VERIFY="1"
;;
--upgrade-ui-plugin)
UPGRADE_UI_PLUGIN="y"
;;
-h|--help|*)
usage
exit 0
Expand Down Expand Up @@ -582,6 +590,7 @@ function main {
export GOVC_DATACENTER="$VCENTER_DATACENTER"
[ -z "${APPLIANCE_TARGET}" ] && read -p "Enter old VIC appliance IP: " APPLIANCE_TARGET
[ -z "${APPLIANCE_USERNAME}" ] && read -p "Enter old VIC appliance username: " APPLIANCE_USERNAME
[ -z "${UPGRADE_UI_PLUGIN}" ] && read -p "Upgrade VIC UI Plugin? (y/n):" UPGRADE_UI_PLUGIN

if [ -n "${DESTROY_ENABLED}" ] ; then
local resp=""
Expand Down Expand Up @@ -626,8 +635,10 @@ function main {
### -------------------- ###
### Component Upgrades ###
### -------------------- ###
log "\n-------------------------\nStarting VIC UI Plugin Upgrade ${TIMESTAMP}\n"
upgradeAppliancePlugin
if [ "$UPGRADE_UI_PLUGIN" == "y" ]; then
log "\n-------------------------\nStarting VIC UI Plugin Upgrade ${TIMESTAMP}\n"
upgradeAppliancePlugin
fi

log "\n-------------------------\nStarting Admiral Upgrade ${TIMESTAMP}\n"
upgradeAdmiral
Expand Down Expand Up @@ -658,7 +669,11 @@ function finish() {
if [ "$rc" -eq 0 ]; then
log ""
log "-------------------------"
log "Upgrade completed successfully. Exiting."
if [ "$UPGRADE_UI_PLUGIN" == "y" ]; then
log "Upgrade completed successfully. Exiting. Please logout and login vCenter Server twice to view the upgraded ui plugin."
else
log "Upgrade completed successfully. Exiting."
fi
log "-------------------------"
log ""
else
Expand Down
3 changes: 2 additions & 1 deletion installer/fileserver/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h4>Infrastructure Deployment Tools</h4>
<div class="modal-dialog" role="dialog"aria-hidden="false">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Complete VIC plugin installation</h3>
<h3 class="modal-title">Complete VIC appliance installation</h3>
</div>
<div id="plugin-spinner" style="display: none;text-align: center">
<div class="spinner"></div>
Expand Down Expand Up @@ -229,6 +229,7 @@ <h3 class="modal-title">Complete VIC appliance installation</h3>
<label for="pscDomain">External PSC Admin Domain</label>
<input id="pscDomain" type="text" name="pscDomain" placeholder="vsphere.local">
</div>
Install UI Plugin <input id="needuiplugin" type="checkbox" name="needuiplugin" value="true" checked>
<input id="thumbprint" type="hidden" name="thumbprint" placeholder="">
</div>
<div class="text-sm-right">
Expand Down
16 changes: 8 additions & 8 deletions installer/fileserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ func parseServerConfig(op trace.Operation, conf *serverConfig) {
// cspMiddleware sets the Content-Security-Policy header to prevent clickjacking
// https://www.owasp.org/index.php/Content_Security_Policy_Cheat_Sheet#Preventing_Clickjacking
func cspMiddleware() func(next http.Handler) http.Handler {
header := "Content-Security-Policy"
value := "frame-ancestors 'none';"
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add(header, value)
next.ServeHTTP(w, r)
})
}
header := "Content-Security-Policy"
value := "frame-ancestors 'none';"
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add(header, value)
next.ServeHTTP(w, r)
})
}
}

func main() {
Expand Down
22 changes: 13 additions & 9 deletions installer/fileserver/routes/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func (i *IndexHTMLRenderer) IndexHandler(resp http.ResponseWriter, req *http.Req
if err := indexFormHandler(op, req, html); err != nil {
op.Errorf("Install failed: %s", err.Error())
html.InitErrorFeedback = fmt.Sprintf("Installation failed: %s", err.Error())
} else if req.FormValue("needuiplugin") == "true" {
html.InitSuccessFeedback = "Installation successful. Refer to the Post-install and Deployment tasks below. Please logout and login vCenter Server twice to view the new ui plugin."
} else {
html.InitSuccessFeedback = "Installation successful. Refer to the Post-install and Deployment tasks below."
}
Expand Down Expand Up @@ -99,16 +101,18 @@ func indexFormHandler(op trace.Operation, req *http.Request, html *IndexHTMLOpti
return err
}

h5 := tasks.NewH5UIPlugin(PSCConfig.Admin)
h5.Force = true
if err := h5.Install(op); err != nil {
return err
}
if req.FormValue("needuiplugin") == "true" {
h5 := tasks.NewH5UIPlugin(PSCConfig.Admin)
h5.Force = true
if err := h5.Install(op); err != nil {
return err
}

flex := tasks.NewFlexUIPlugin(PSCConfig.Admin)
flex.Force = true
if err := flex.Install(op); err != nil {
return err
flex := tasks.NewFlexUIPlugin(PSCConfig.Admin)
flex.Force = true
if err := flex.Install(op); err != nil {
return err
}
}

return nil
Expand Down
5 changes: 2 additions & 3 deletions installer/fileserver/tasks/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ func (p *Plugin) Install(op trace.Operation) error {
}
vCenterVersion := p.Target.Session.Client.ServiceContent.About.Version
if p.denyInstall(op, vCenterVersion) {
err := errors.Errorf("Refusing to install Flex plugin on vSphere %s", vCenterVersion)
op.Error(err)
return err
op.Warnf("Refusing to install Flex plugin on vSphere %s", vCenterVersion)
return nil
}

op.Infof("### Installing UI Plugin against vSphere %s ####", vCenterVersion)
Expand Down
11 changes: 8 additions & 3 deletions installer/scripts/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [ -n "${VICENGINE}" ]; then
OPTIONS="$OPTIONS --vicengine $VICENGINE"
fi
if [ -n "${VICUI}" ]; then
OPTIONS="$OPTIONS --vicui $VICENGINE"
OPTIONS="$OPTIONS --vicui $VICUI"
fi
if [ -n "${VIC_MACHINE_SERVER}" ]; then
OPTIONS="$OPTIONS --vicmachineserver $VIC_MACHINE_SERVER"
Expand Down Expand Up @@ -61,8 +61,13 @@ if [[ ( "$DRONE_BUILD_EVENT" == "tag" && "$DRONE_TAG" != *"dev"* ) || "$DRONE_BR
OPTIONS="$OPTIONS --vicengine ${vicengine_release:?Unable to find an appropriate VIC Engine build. Is '"'$DRONE_BRANCH'"' a valid vmware/vic branch?}"
fi
if [ -z "${VICUI}" ]; then
vicui_release=$(gsutil ls -l "gs://vic-ui-releases" | grep -v TOTAL | grep vic_ | sort -k2 -r | (trap '' PIPE; head -1) | xargs | cut -d " " -f 3 | sed 's/gs:\/\//https:\/\/storage.googleapis.com\//')
OPTIONS="$OPTIONS --vicui $vicui_release"
if [[ "$DRONE_BUILD_EVENT" != "tag" || "$DRONE_TAG" == *"dev"* ]]; then
bucket="gs://vic-ui-builds/$DRONE_BRANCH"
else
bucket="gs://vic-ui-releases"
fi
vicui_release=$(gsutil ls -l "$bucket" | grep -v TOTAL | grep vic_ | sort -k2 -r | (trap '' PIPE; head -1) | xargs | cut -d " " -f 3 | sed 's/gs:\/\//https:\/\/storage.googleapis.com\//')
OPTIONS="$OPTIONS --vicui ${vicui_release:?Unable to find an appropriate VIC UI build. Is '"'$DRONE_BRANCH'"' a valid vmware/vic-ui branch?}"
fi
if [ -z "${VIC_MACHINE_SERVER}" ]; then
# Listing container tags requires permissions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Verify Getting Started page
Log To Console Initializing the OVA using the getting started ui...
Navigate To Getting Started Page
Verify Getting Started Page Title
Log In And Complete OVA Installation
#Log In And Complete OVA Installation

0 comments on commit 6ec823c

Please sign in to comment.