Beispiel #1
0
        public override void ExecuteCmdlet()
        {
            var peer = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);

            if (AccessType != BgpPeeringAccessType.Microsoft)
            {
                peer.LegacyMode = 1;
            }

            WriteObject(peer);
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                var route = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);

                var advertisedPublicPrefixes = AdvertisedPublicPrefixes ?? ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.AdvertisedPublicPrefixes : route.AdvertisedPublicPrefixesIpv6);
                var routingRegistryName      = RoutingRegistryName ?? ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.RoutingRegistryName : route.RoutingRegistryNameIpv6);
                var customerAsn = (CustomerAsn.HasValue) ? CustomerAsn.Value : ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.CustomerAutonomousSystemNumber : route.CustomerAutonomousSystemNumberIpv6);

                var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, PeerAddressType, AccessType,
                                                                            advertisedPublicPrefixes, customerAsn, PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet,
                                                                            routingRegistryName, SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
                                                                            string.IsNullOrWhiteSpace(SharedKey) ? null : SharedKey.Trim());

                WriteObject(updatedRoute, false);
            }
            catch
            {
                if (!PeerAsn.HasValue)
                {
                    throw new ArgumentException(Resources.PeerAsnRequired);
                }

                if (!VlanId.HasValue)
                {
                    throw new ArgumentException(Resources.VlanIdRequired);
                }

                if (PrimaryPeerSubnet == null)
                {
                    throw new ArgumentException(Resources.PrimaryPeerSubnetRequired);
                }

                if (SecondaryPeerSubnet == null)
                {
                    throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
                }

                var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAddressType, AdvertisedPublicPrefixes, CustomerAsn.Value, PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet,
                                                                     VlanId.Value, AccessType, SharedKey);
                WriteObject(newRoute);
            }
        }
 private AzureDedicatedCircuitStats compute(AzureDedicatedCircuitStats stats, Guid key, BgpPeeringAccessType type)
 {
     try
     {
         AzureBgpPeering peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, type);
         if (peering != null)
         {
             var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key, type);
             stats.PrimaryBytesIn    += tempstats.PrimaryBytesIn;
             stats.PrimaryBytesOut   += tempstats.PrimaryBytesOut;
             stats.SecondaryBytesIn  += tempstats.SecondaryBytesIn;
             stats.SecondaryBytesOut += tempstats.SecondaryBytesOut;
         }
         return(stats);
     }
     catch
     {
         // The cirucit might not have corresponding peering
         return(stats);
     }
 }
        public override void ExecuteCmdlet()
        {
            try
            {
                var route        = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);
                var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType, CustomerAsn,
                                                                            PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet, RoutingRegistryName,
                                                                            SecondaryPeerSubnet ?? route.SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
                                                                            SharedKey);
                WriteObject(updatedRoute, false);
            }
            catch
            {
                if (!PeerAsn.HasValue)
                {
                    throw new ArgumentException(Resources.PeerAsnRequired);
                }

                if (!VlanId.HasValue)
                {
                    throw new ArgumentException(Resources.VlanIdRequired);
                }

                if (PrimaryPeerSubnet == null)
                {
                    throw new ArgumentException(Resources.PrimaryPeerSubnetRequired);
                }

                if (SecondaryPeerSubnet == null)
                {
                    throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
                }

                var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn,
                                                                     PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId.Value, AccessType,
                                                                     SharedKey);
                WriteObject(newRoute);
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                var route        = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);
                var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType,
                                                                            PeerAsn.HasValue ? PeerAsn.Value : route.PeerAutonomousSystemNumber, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet,
                                                                            SecondaryPeerSubnet ?? route.SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VirtualLanId,
                                                                            SharedKey);
                WriteObject(updatedRoute, false);
            }
            catch
            {
                if (!PeerAsn.HasValue)
                {
                    throw new ArgumentException(Resources.PeerAsnRequired);
                }

                if (!VlanId.HasValue)
                {
                    throw new ArgumentException(Resources.VlanIdRequired);
                }

                if (PrimaryPeerSubnet == null)
                {
                    throw new ArgumentException(Resources.PrimaryPeerSubnetRequired);
                }

                if (SecondaryPeerSubnet == null)
                {
                    throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
                }

                var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAsn.Value, PrimaryPeerSubnet,
                                                                     SecondaryPeerSubnet, VlanId.Value, AccessType, SharedKey);
                WriteObject(newRoute);
            }
        }
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(AccessType))
            {
                AzureDedicatedCircuitStats stats = new AzureDedicatedCircuitStats
                {
                    PrimaryBytesIn    = (ulong)0,
                    PrimaryBytesOut   = (ulong)0,
                    SecondaryBytesIn  = (ulong)0,
                    SecondaryBytesOut = (ulong)0
                };
                AzureBgpPeering peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, BgpPeeringAccessType.Private);
                if (peering != null)
                {
                    stats = compute(stats, ServiceKey, BgpPeeringAccessType.Private);
                }
                peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, BgpPeeringAccessType.Public);
                if (peering != null)
                {
                    stats = compute(stats, ServiceKey, BgpPeeringAccessType.Public);
                }
                peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, BgpPeeringAccessType.Microsoft);
                if (peering != null)
                {
                    stats = compute(stats, ServiceKey, BgpPeeringAccessType.Microsoft);
                }
                WriteObject(stats);
            }
            BgpPeeringAccessType type;

            if (BgpPeeringAccessType.TryParse(AccessType, out type))
            {
                var stats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(ServiceKey, type);
                WriteObject(stats);
            }
        }
        public override void ExecuteCmdlet()
        {
            var route = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);

            WriteObject(route);
        }