/// <summary> /// Allows creation of a new LUN /// /// <para> /// Allows the creation of a LUN for a volume.A LUN is an instance of a /// volume export that makes a volume accessible to a host. /// </para> /// <para> /// At least one host must be specified via <c>HostGuids</c> or /// <c>SpuSerials</c> - either one option must be specified but not /// both. If the <c>Locak</c> option is provided and set to <c>true</c> /// then the volume will be exported with ALUA, otherwise with ALUA /// turned off. /// </para> /// </summary> /// <param name="input"> /// An input definition for the new LUN. Review the CreateLunInput /// properties for configuration details /// </param> /// <returns>The new LUN if successful</returns> public Lun CreateLun(CreateLunInput input) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"input", input); TokenResponse token = RunMutation <TokenResponse>(@"createLUN", parameters); if (!DeliverToken(token)) { throw new Exception("Token delivery failed"); } // wait until the new LUN is reporting in nebulon ON Thread.Sleep(TOKEN_WAITTIME_MS); // Query for LUN LunFilter filter = new LunFilter(); filter.LunGuid = new GuidFilter(); filter.LunGuid.MustEqual = token.WaitOn; LunList lunList = GetLuns(null, filter, null); if (lunList.FilteredCount != 1) { throw new Exception("Unexpected number of results returned"); } return(lunList.Items[0]); }
/// <summary> /// Performs execution of the command /// </summary> protected override void ProcessRecord() { try { CreateLunInput input = new CreateLunInput(); if (ParameterPresent("Server")) { input.HostGuids = new Guid[] { Server.Guid } } ; if (ParameterPresent("Spu")) { input.SpuSerials = new string[] { Spu.Serial } } ; if (ParameterPresent("Volume")) { input.VolumeGuid = Volume.Guid; } if (ParameterPresent("LunId")) { input.LunId = LunId; } input.Local = Local.IsPresent; Lun newLun = Connection.CreateLun(input); WriteObject(newLun); } catch (AggregateException exceptions) { foreach (Exception ex in exceptions.InnerExceptions) { WriteError(ex); } } catch (Exception ex) { WriteError(ex); } }