/**
         * Creates a VCN and waits for it to become available to use.
         *
         * @param vcnClient the service client to use to create the VCN
         * @param compartmentId the OCID of the compartment where the VCN will be created
         *
         * @return the created VCN
         */
        private static async Task <Vcn> CreateVcn(VirtualNetworkClient virtualNetworkClient, string compartmentId)
        {
            logger.Info("creating vcn");

            CreateVcnDetails createVcnDetails = new CreateVcnDetails
            {
                CidrBlock     = CidrBlock,
                CompartmentId = compartmentId,
                DisplayName   = VcnDisplayName
            };
            CreateVcnRequest createVcnRequest = new CreateVcnRequest
            {
                CreateVcnDetails = createVcnDetails
            };
            CreateVcnResponse createVcnResponse = await virtualNetworkClient.CreateVcn(createVcnRequest);

            GetVcnRequest getVcnRequest = new GetVcnRequest
            {
                VcnId = createVcnResponse.Vcn.Id
            };
            GetVcnResponse getVcnResponse = virtualNetworkClient.Waiters.ForVcn(getVcnRequest, Vcn.LifecycleStateEnum.Available).Execute();
            Vcn            vcn            = getVcnResponse.Vcn;

            logger.Info($"Created vcn: {vcn.Id} and state is {vcn.LifecycleState}");
            return(vcn);
        }
Пример #2
0
        private void HandleOutput(GetVcnRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForVcn(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetVcn(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Vcn);
        }
Пример #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetVcnRequest request;

            try
            {
                request = new GetVcnRequest
                {
                    VcnId = VcnId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }