/// <summary> /// Creates ContainerInstanceMsiHandler /// </summary> /// <param name="rbacManager">The graph rbac manager</param> /// <param name="containerGroup">Instance of container group</param> internal ContainerGroupMsiHandler(IGraphRbacManager rbacManager, ContainerGroupImpl containerGroup) : base(rbacManager, new ContainerGroupIdProvider(containerGroup)) { this.containerGroup = containerGroup; this.creatableIdentityKeys = new HashSet <string>(); this.userAssignedIdentities = new Dictionary <string, ContainerGroupIdentityUserAssignedIdentitiesValue>(); }
///GENMHASH:58AD2109DE49A21089D219327AB34729:A24F436CF7F24D91E89F7155872C668C internal VolumeImpl(ContainerGroupImpl parent, string volumeName) { this.parent = parent; this.innerVolume = new Volume { Name = volumeName }; }
public async override Task <IContainerGroup> CreateResourceAsync(CancellationToken cancellationToken) { ContainerGroupImpl self = this; if (IsInCreateMode) { if (this.creatableStorageAccountKey != null && this.newFileShares != null && this.newFileShares.Count > 0) { // Creates the new Azure file shares var storageAccount = this.CreatedResource(this.creatableStorageAccountKey) as IStorageAccount; if (this.Inner.Volumes == null) { this.Inner.Volumes = new List <Volume>(); } var storageAccountKey = (await storageAccount.GetKeysAsync())[0].Value; var sas = $"DefaultEndpointsProtocol=https;AccountName={storageAccount.Name};AccountKey={storageAccountKey};EndpointSuffix=core.Windows.Net"; var cloudFileClient = CloudStorageAccount.Parse(sas).CreateCloudFileClient(); foreach (var fileShare in this.newFileShares) { CloudFileShare cloudFileShare = cloudFileClient.GetShareReference(fileShare.Value); await cloudFileShare.CreateIfNotExistsAsync(); this.Inner.Volumes.Add(new Volume { Name = fileShare.Key, AzureFile = new AzureFileVolume { ShareName = fileShare.Value, ReadOnlyProperty = false, StorageAccountName = storageAccount.Name, StorageAccountKey = storageAccountKey } }); } } var inner = await this.Manager.Inner.ContainerGroups.CreateOrUpdateAsync(this.ResourceGroupName, this.Name, this.Inner, cancellationToken); SetInner(inner); this.InitializeChildrenFromInner(); return(this); } else { var resourceInner = new ResourceInner(); resourceInner.Location = this.RegionName; resourceInner.Tags = this.Inner.Tags; var updatedInner = await this.Manager.Inner.ContainerGroups.UpdateAsync(this.ResourceGroupName, this.Name, resourceInner, cancellationToken : cancellationToken); // TODO: this will go away after service fixes the update bug updatedInner = await this.GetInnerAsync(cancellationToken); SetInner(updatedInner); this.InitializeChildrenFromInner(); return(this); } }
protected async Task <IContainerGroup> WrapModelForListAsync(ContainerGroupInner inner, CancellationToken cancellationToken = default(CancellationToken)) { if (inner != null) { var result = new ContainerGroupImpl(inner.Name, inner, this.Manager, this.storageManager); return(await result.RefreshAsync(cancellationToken)); } else { return(null); } }
///GENMHASH:C933388CFB7191BAD7DAA84EAED418CE:909C9049FD102EC104827552A0DCB4C7 internal ContainerImpl(ContainerGroupImpl parent, string containerName) { this.parent = parent; this.innerContainer = new Container { Name = containerName, Resources = new ResourceRequirements { Requests = new ResourceRequests { Cpu = 1, MemoryInGB = 1.5 } }, }; }
internal ContainerGroupIdProvider(ContainerGroupImpl containerGroup) { this.containerGroup = containerGroup; }