Sharing vApps in vCloud with PowerCLI

June 11, 2013

Table of Contents

Some times vCloud Directors give the organization users grainy control over the the level of access users have to vApps , this is all controlled through the the vCloud API and powerCLI. The code below takes vApps‘ current settings and allow the user to modify the vApp:

# Get our required Objects

$vapp = Get-CIVApp “My vApp”

$user = Get-CIUser “UserToBeAdded”

# Access Level can be one of: ReadOnly,Change,FullControl

$accessLevel = “Change”

# Get current access policy from vApp

$access = $vapp.ExtensionData.GetControlAccess()

if (!$access.AccessSettings)

{

 $access.AccessSettings = New-Object VMware.VimAutomation.Cloud.Views.AccessSettings

}

# New Access object

$newAccess = new-object VMware.VimAutomation.Cloud.Views.AccessSetting

$newAccess.Subject = New-Object VMware.VimAutomation.Cloud.Views.Reference

# Set our access level

$newAccess.AccessLevel = $accessLevel

# Insert user href

$newAccess.Subject.Href = $user.ExtensionData.Href

$newAccess.Subject.Type = “application/vnd.vmware.admin.user+xml”

# Add new access to vApp access settings object

$access.AccessSettings.AccessSetting += $newAccess

#Send new Access config

$vapp.ExtensionData.ControlAccess($access)

A user is also able to control the default access policyand the level-using:

$access.IsSharedToEveryone and $access

Home

Share on
Facebook
Twitter
LinkedIn
Pinterest
More posts

Dedicated Servers Quick Guide

What is a Dedicated Servers? Why bother using a dedicated server over a VPS or Shared Hosting?A dedicated server is a server 100% dedicated to your website/project or business needs.

Organizing Your Slim Based Project

A Slim Based Project is basically extended over three main directories. Slim framework directory Project directory This directory contains your project files like routers, views, models. Being a microframework, Slim

Get 90% Discount

First 3 People gets the Bonus!
Don't Miss Out Our Big Sale

Get 0-90% On All
247Rack Services

247Rack

The Sale Is Until The End Of March