background image

Technical Note

VMware, Inc.

1

Extending Virtual Machine Deletion 
with Scripts

View Manager 4.x

When

 

you

 

delete

 

a

 

virtual

 

machine

 

from

 

the

 

VMware

®

 

View™

 

environment,

 

you

 

might

 

want

 

to

 

run

 

your

 

own

 

scripts

 

to

 

remove

 

Active

 

Directory

 

or

 

database

 

entries

 

that

 

reference

 

the

 

deleted

 

machine.

 

This

 

technical

 

note

 

describes

 

how

 

to

 

configure

 

View

 

Manager

 

to

 

run

 

such

 

deletion

 

scripts

 

automatically

 

when

 

you

 

delete

 

a

 

virtual

 

machine.

 

To

 

enable

 

a

 

deletion

 

script,

 

you

 

add

 

an

 

entry

 

for

 

the

 

script

 

to

 

the

 

Windows

 

Registry,

 

configure

 

the

 

account

 

of

 

the

 

user

 

who

 

has

 

the

 

appropriate

 

privileges

 

to

 

run

 

the

 

script,

 

and

 

enable

 

the

 

VMware

 

View

 

Script

 

Host

 

service.

You

 

must

 

configure

 

all

 

View

 

Connection

 

Server

 

hosts

 

that

 

need

 

to

 

run

 

deletion

 

scripts.

 

There

 

is

 

no

 

mechanism

 

to

 

propagate

 

registry

 

changes,

 

VMware

 

View

 

Script

 

Host

 

service

 

configuration

 

changes,

 

and

 

deletion

 

scripts

 

between

 

View

 

Connection

 

Server

 

hosts.

Environment Variables

Deletion

 

scripts

 

cannot

 

run

 

interactively.

 

A

 

deletion

 

script

 

runs

 

in

 

an

 

environment

 

created

 

by

 

View

 

Manager,

 

and

 

the

 

script

 

must

 

obtain

 

its

 

input

 

data

 

from

 

this

 

environment.

 

Table 1

 

shows

 

the

 

environment

 

variables

 

that

 

you

 

can

 

use.

 

You

 

should

 

ensure

 

that

 

a

 

deletion

 

script

 

validates

 

the

 

existence

 

of

 

any

 

environment

 

variable

 

that

 

it

 

uses.

 

The

 

following

 

Visual

 

Basic

 

code

 

fragment

 

shows

 

how

 

to

 

access

 

the

 

environment

 

variable

 

for

 

the

 

MAC

 

address

 

of

 

the

 

first

 

network

 

interface

 

of

 

a

 

virtual

 

machine

 

that

 

is

 

being

 

deleted.

Dim shell
set shell = WScript.CreateObject( "WScript.Shell" )

macAddr0 = shell.ExpandEnvironmentStrings("%VDM_DeleteVm_VmMac.0%")

Table 1.  

Environment Variables for Deletion Scripts

Environment Variable

Description

VDM_DeleteVm_VmName

Name

 

of

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_VmDnsName

DNS

 

name

 

of

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_VmDn

Distinguished

 

name

 

of

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_VmPath

Path

 

in

 

the

 

VMware

 

vCenter™

 

server

 

that

 

manages

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_PoolDn

Distinguished

 

name

 

of

 

the

 

pool

 

that

 

contains

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_VcDn

Distinguished

 

name

 

of

 

the

 

vCenter

 

server

 

that

 

manages

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_VmMac.<N>

MAC

 

address

 

for

 

the

 

network

 

interface

 

number

 

of

 

the

 

virtual

 

machine

 

being

 

deleted.

VDM_DeleteVm_Error

String

 

that

 

describes

 

a

 

problem

 

that

 

occurred

 

while

 

deleting

 

the

 

virtual

 

machine.

Reviews: