forked from AzureRT/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hovsep Mkrtchyan
committed
Nov 30, 2017
1 parent
dba029c
commit db0f83e
Showing
8 changed files
with
343 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...sourceManager/Common/Commands.Common.Strategies/Compute/VirtualMachineScaleSetStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Management.Compute; | ||
using Microsoft.Azure.Management.Compute.Models; | ||
using Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.Azure.Management.ResourceManager.Models; | ||
|
||
namespace Microsoft.Azure.Commands.Common.Strategies.Compute | ||
{ | ||
public static class VirtualMachineScaleSetStrategy | ||
{ | ||
public static ResourceStrategy<VirtualMachineScaleSet> Strategy { get; } | ||
= ComputePolicy.Create( | ||
"virtual machine scale set", | ||
"virtualMachines", | ||
client => client.VirtualMachineScaleSets, | ||
(o, p) => o.GetAsync( | ||
p.ResourceGroupName, p.Name, p.CancellationToken), | ||
(o, p) => o.CreateOrUpdateAsync( | ||
p.ResourceGroupName, p.Name, p.Model, p.CancellationToken)); | ||
|
||
public static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScaleSetConfig( | ||
this ResourceConfig<ResourceGroup> resourceGroup, | ||
string name, | ||
string adminUsername, | ||
string adminPassword, | ||
Image image) | ||
=> Strategy.CreateConfig( | ||
resourceGroup, | ||
name, | ||
subscription => new VirtualMachineScaleSet | ||
{ | ||
}); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/ResourceManager/Common/Commands.Common.Strategies/Network/LoadBalancerStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.Azure.Management.ResourceManager.Models; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Azure.Commands.Common.Strategies.Network | ||
{ | ||
public static class LoadBalancerStrategy | ||
{ | ||
public static ResourceStrategy<LoadBalancer> Strategy { get; } | ||
= NetworkStrategy.Create( | ||
"load balancer", | ||
"loadBalancers", | ||
client => client.LoadBalancers, | ||
(o, p) => o.GetAsync( | ||
p.ResourceGroupName, p.Name, null, p.CancellationToken), | ||
(o, p) => o.CreateOrUpdateAsync( | ||
p.ResourceGroupName, p.Name, p.Model, p.CancellationToken)); | ||
|
||
public static ResourceConfig<LoadBalancer> CreateLoadBalancerConfig( | ||
this ResourceConfig<ResourceGroup> resourceGroup, string name) | ||
=> Strategy.CreateConfig( | ||
resourceGroup, | ||
name, | ||
_ => new LoadBalancer()); | ||
} | ||
|
||
/* | ||
public static class NetworkSecurityGroupStrategy | ||
{ | ||
public static ResourceStrategy<NetworkSecurityGroup> Strategy { get; } | ||
= NetworkStrategy.Create( | ||
"network security group", | ||
"networkSecurityGroups", | ||
client => client.NetworkSecurityGroups, | ||
(o, p) => o.GetAsync( | ||
p.ResourceGroupName, p.Name, null, p.CancellationToken), | ||
(o, p) => o.CreateOrUpdateAsync( | ||
p.ResourceGroupName, p.Name, p.Model, p.CancellationToken)); | ||
public static ResourceConfig<NetworkSecurityGroup> CreateNetworkSecurityGroupConfig( | ||
this ResourceConfig<ResourceGroup> resourceGroup, string name, int[] openPorts) | ||
=> Strategy.CreateConfig( | ||
resourceGroup, | ||
name, | ||
_ => new NetworkSecurityGroup | ||
{ | ||
SecurityRules = openPorts | ||
.Select((port, index) => new SecurityRule | ||
{ | ||
Name = name + port, | ||
Protocol = "Tcp", | ||
Priority = index + 1000, | ||
Access = "Allow", | ||
Direction = "Inbound", | ||
SourcePortRange = "*", | ||
SourceAddressPrefix = "*", | ||
DestinationPortRange = port.ToString(), | ||
DestinationAddressPrefix = "*" | ||
}) | ||
.ToList() | ||
}); | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.