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

            MNM.NextHopParameters parameters = new MNM.NextHopParameters();

            parameters.DestinationIPAddress = this.DestinationIPAddress;
            parameters.SourceIPAddress      = this.SourceIPAddress;
            parameters.TargetNicResourceId  = this.TargetNetworkInterfaceId;
            parameters.TargetResourceId     = this.TargetVirtualMachineId;

            MNM.NextHopResult nextHop = new MNM.NextHopResult();

            if (ParameterSetName.Contains("SetByResource"))
            {
                nextHop = this.NetworkWatcherClient.GetNextHop(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters);
            }
            else
            {
                nextHop = this.NetworkWatcherClient.GetNextHop(this.ResourceGroupName, this.NetworkWatcherName, parameters);
            }

            PSNextHopResult psNextHop = NetworkResourceManagerProfile.Mapper.Map <PSNextHopResult>(nextHop);

            WriteObject(psNextHop);
        }
示例#2
0
        public override void Execute()
        {
            base.Execute();

            MNM.NextHopParameters parameters = new MNM.NextHopParameters();

            parameters.DestinationIPAddress = this.DestinationIPAddress;
            parameters.SourceIPAddress      = this.SourceIPAddress;
            parameters.TargetNicResourceId  = this.TargetNetworkInterfaceId;
            parameters.TargetResourceId     = this.TargetVirtualMachineId;

            MNM.NextHopResult nextHop = new MNM.NextHopResult();

            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;
                nextHop = this.NetworkWatcherClient.GetNextHop(this.ResourceGroupName, this.NetworkWatcherName, parameters);
            }
            else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase))
            {
                nextHop = this.NetworkWatcherClient.GetNextHop(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters);
            }
            else
            {
                nextHop = this.NetworkWatcherClient.GetNextHop(this.ResourceGroupName, this.NetworkWatcherName, parameters);
            }

            PSNextHopResult psNextHop = NetworkResourceManagerProfile.Mapper.Map <PSNextHopResult>(nextHop);

            WriteObject(psNextHop);
        }