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.

Easy File & Code Manager

Easy File Manager FileZilla Best Server Manager Tools Download FileZilla Client You can use FileZilla to manage websites and servers and edit code in real-time or for simple backup methods

RVTools 3.3 Now Available

Good news: RVTools 3.3 from Rob de Veij is now generally available to the public.  Release notes for this build: GetWebResponse time-out value changed from 5 minutes to 10 minutes

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