public override void Execute()
        {
            base.Execute();

            MNM.VerificationIPFlowParameters flowParameters = new MNM.VerificationIPFlowParameters();

            flowParameters.Direction           = this.Direction;
            flowParameters.LocalIPAddress      = this.LocalIPAddress;
            flowParameters.LocalPort           = this.LocalPort;
            flowParameters.Protocol            = this.Protocol;
            flowParameters.RemoteIPAddress     = this.RemoteIPAddress;
            flowParameters.RemotePort          = this.RemotePort;
            flowParameters.TargetNicResourceId = this.TargetNetworkInterfaceId;
            flowParameters.TargetResourceId    = this.TargetVirtualMachineId;

            MNM.VerificationIPFlowResult ipFlowVerify = new MNM.VerificationIPFlowResult();
            if (ParameterSetName.Contains("SetByResource"))
            {
                ipFlowVerify = this.NetworkWatcherClient.VerifyIPFlow(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, flowParameters);
            }
            else
            {
                ipFlowVerify = this.NetworkWatcherClient.VerifyIPFlow(this.ResourceGroupName, this.NetworkWatcherName, flowParameters);
            }

            PSIPFlowVerifyResult psIPFlowVerify = Mapper.Map <PSIPFlowVerifyResult>(ipFlowVerify);

            WriteObject(psIPFlowVerify);
        }
Example #2
0
        public override void Execute()
        {
            base.Execute();

            MNM.VerificationIPFlowParameters flowParameters = new MNM.VerificationIPFlowParameters();

            flowParameters.Direction           = this.Direction;
            flowParameters.LocalIPAddress      = this.LocalIPAddress;
            flowParameters.LocalPort           = this.LocalPort;
            flowParameters.Protocol            = this.Protocol;
            flowParameters.RemoteIPAddress     = this.RemoteIPAddress;
            flowParameters.RemotePort          = this.RemotePort;
            flowParameters.TargetNicResourceId = this.TargetNetworkInterfaceId;
            flowParameters.TargetResourceId    = this.TargetVirtualMachineId;

            MNM.VerificationIPFlowResult ipFlowVerify = new MNM.VerificationIPFlowResult();
            if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase))
            {
                var networkWatcher = this.GetNetworkWatcherByLocation(this.Location);

                if (networkWatcher == null)
                {
                    throw new ArgumentException("There is no network watcher in location {0}", this.Location);
                }

                this.ResourceGroupName  = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id);
                this.NetworkWatcherName = networkWatcher.Name;
                ipFlowVerify            = this.NetworkWatcherClient.VerifyIPFlow(this.ResourceGroupName, this.NetworkWatcherName, flowParameters);
            }
            if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase))
            {
                ipFlowVerify = this.NetworkWatcherClient.VerifyIPFlow(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, flowParameters);
            }
            else
            {
                ipFlowVerify = this.NetworkWatcherClient.VerifyIPFlow(this.ResourceGroupName, this.NetworkWatcherName, flowParameters);
            }

            PSIPFlowVerifyResult psIPFlowVerify = NetworkResourceManagerProfile.Mapper.Map <PSIPFlowVerifyResult>(ipFlowVerify);

            WriteObject(psIPFlowVerify);
        }