Skip to content

Commit

Permalink
Merge pull request #1 from Azure/master
Browse files Browse the repository at this point in the history
Merge updates
  • Loading branch information
alvadb authored Oct 5, 2016
2 parents f030f13 + 5e747bd commit e58490e
Show file tree
Hide file tree
Showing 32 changed files with 368 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public void modify(Object request) {
Class<?> c = request.getClass();

try {
Method clientRequestIdMethod = c.getMethod("setClientRequestId", new Class[]{String.class});
Method clientRequestIdMethod = c.getMethod("withClientRequestId", new Class[]{String.class});
if (clientRequestIdMethod != null) {
String clientRequestId = UUID.randomUUID().toString();
clientRequestIdMethod.invoke(request, clientRequestId);
}

Method returnClientRequestIdMethod = c.getMethod("setReturnClientRequestId", new Class[]{Boolean.class});
Method returnClientRequestIdMethod = c.getMethod("withReturnClientRequestId", new Class[]{Boolean.class});
if (returnClientRequestIdMethod != null) {
returnClientRequestIdMethod.invoke(request, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void modify(Object request) {
if (detailLevel != null) {
Class<?> c = request.getClass();
try {
Method selectMethod = c.getMethod("setSelect", new Class[]{String.class});
Method selectMethod = c.getMethod("withSelect", new Class[]{String.class});
if (selectMethod != null) {
selectMethod.invoke(request, detailLevel.selectClause());
}
Expand All @@ -31,7 +31,7 @@ public void modify(Object request) {
}

try {
Method filterMethod = c.getMethod("setFilter", new Class[]{String.class});
Method filterMethod = c.getMethod("withFilter", new Class[]{String.class});
if (filterMethod != null) {
filterMethod.invoke(request, detailLevel.filterClause());
}
Expand All @@ -40,7 +40,7 @@ public void modify(Object request) {
}

try {
Method expandMethod = c.getMethod("setExpand", new Class[]{String.class});
Method expandMethod = c.getMethod("withExpand", new Class[]{String.class});
if (expandMethod != null) {
expandMethod.invoke(request, detailLevel.expandClause());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public PageSizeInterceptor(int pageSize) {
public void modify(Object request) {
Class<?> c = request.getClass();
try {
Method maxResultsMethod = c.getMethod("setMaxResults", new Class[]{Integer.class});
Method maxResultsMethod = c.getMethod("withMaxResults", new Class[]{Integer.class});
if (maxResultsMethod != null) {
maxResultsMethod.invoke(request, maxResults);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ServerTimeoutInterceptor(int timeout) {
public void modify(Object request) {
Class<?> c = request.getClass();
try {
Method timeoutMethod = c.getMethod("setTimeout", new Class[]{Integer.class});
Method timeoutMethod = c.getMethod("withTimeout", new Class[]{Integer.class});
if (timeoutMethod != null) {
timeoutMethod.invoke(request, serverTimeout);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.microsoft.azure.management.batch.implementation;

import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.RestClient;
import com.microsoft.azure.credentials.AzureTokenCredentials;
import com.microsoft.azure.management.batch.BatchAccounts;
import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable;
import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager;
import com.microsoft.azure.management.storage.implementation.StorageManager;
import com.microsoft.rest.credentials.ServiceClientCredentials;

/**
* Entry point to Azure Batch Account resource management.
Expand Down Expand Up @@ -42,8 +41,8 @@ public static Configurable configure() {
* @param subscriptionId the subscription
* @return the BatchManager
*/
public static BatchManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
return new BatchManager(AzureEnvironment.AZURE.newRestClientBuilder()
public static BatchManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return new BatchManager(credentials.getEnvironment().newRestClientBuilder()
.withCredentials(credentials)
.build(), subscriptionId);
}
Expand All @@ -70,15 +69,15 @@ public interface Configurable extends AzureConfigurable<Configurable> {
* @param subscriptionId the subscription
* @return the BatchManager
*/
BatchManager authenticate(ServiceClientCredentials credentials, String subscriptionId);
BatchManager authenticate(AzureTokenCredentials credentials, String subscriptionId);
}

/**
* The implementation for Configurable interface.
*/
private static final class ConfigurableImpl extends AzureConfigurableImpl<Configurable> implements Configurable {
@Override
public BatchManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
public BatchManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return BatchManager.authenticate(buildRestClient(credentials), subscriptionId);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.RestClient;
import com.microsoft.azure.credentials.AzureTokenCredentials;
import com.microsoft.azure.management.compute.AvailabilitySets;
import com.microsoft.azure.management.compute.VirtualMachineExtensionImages;
import com.microsoft.azure.management.compute.VirtualMachineImages;
Expand All @@ -11,8 +12,6 @@
import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager;
import com.microsoft.azure.management.storage.implementation.StorageManager;
import com.microsoft.azure.RestClient;
import com.microsoft.rest.credentials.ServiceClientCredentials;

/**
* Entry point to Azure compute resource management.
Expand Down Expand Up @@ -44,8 +43,8 @@ public static Configurable configure() {
* @param subscriptionId the subscription
* @return the ComputeManager
*/
public static ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
return new ComputeManager(AzureEnvironment.AZURE.newRestClientBuilder()
public static ComputeManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return new ComputeManager(credentials.getEnvironment().newRestClientBuilder()
.withCredentials(credentials)
.build(), subscriptionId);
}
Expand All @@ -72,15 +71,15 @@ public interface Configurable extends AzureConfigurable<Configurable> {
* @param subscriptionId the subscription
* @return the ComputeManager
*/
ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId);
ComputeManager authenticate(AzureTokenCredentials credentials, String subscriptionId);
}

/**
* The implementation for Configurable interface.
*/
private static final class ConfigurableImpl extends AzureConfigurableImpl<Configurable> implements Configurable {
@Override
public ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
public ComputeManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return ComputeManager.authenticate(buildRestClient(credentials), subscriptionId);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.microsoft.azure.management.compute;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer;
import com.microsoft.azure.management.storage.StorageAccount;
import org.apache.commons.codec.binary.Base64;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -18,6 +22,56 @@ public static void setup() throws Exception {
public static void cleanup() throws Exception {
}

@Test
public void canEnableDiagnosticsExtension() throws Exception {
final String RG_NAME = ResourceNamer.randomResourceName("vmexttest", 15);
final String STORAGEACCOUNTNAME = ResourceNamer.randomResourceName("stg", 15);
final String LOCATION = "eastus";
final String VMNAME = "javavm";

// Creates a storage account
StorageAccount storageAccount = storageManager.storageAccounts()
.define(STORAGEACCOUNTNAME)
.withRegion(LOCATION)
.withNewResourceGroup(RG_NAME)
.create();

// Create a Linux VM
//
VirtualMachine vm = computeManager.virtualMachines()
.define(VMNAME)
.withRegion(LOCATION)
.withExistingResourceGroup(RG_NAME)
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIpAddressDynamic()
.withoutPrimaryPublicIpAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withRootUserName("Foo12")
.withPassword("BaR@12abc!")
.withSize(VirtualMachineSizeTypes.STANDARD_D3)
.withExistingStorageAccount(storageAccount)
.create();

final InputStream embeddedJsonConfig = VirtualMachineExtensionOperationsTests.class.getResourceAsStream("/linux_diagnostics_public_config.json");
String jsonConfig = ((new ObjectMapper()).readTree(embeddedJsonConfig)).toString();
jsonConfig = jsonConfig.replace("%VirtualMachineResourceId%", vm.id());

// Update Linux VM to enable Diagnostics
vm.update()
.defineNewExtension("LinuxDiagnostic")
.withPublisher("Microsoft.OSTCExtensions")
.withType("LinuxDiagnostic")
.withVersion("2.3")
.withPublicSetting("ladCfg", new String(Base64.encodeBase64(jsonConfig.getBytes())))
.withPublicSetting("storageAccount", storageAccount.name())
.withProtectedSetting("storageAccountName", storageAccount.name())
.withProtectedSetting("storageAccountKey", storageAccount.getKeys().get(0).value())
.withProtectedSetting("storageAccountEndPoint", "https://core.windows.net:443/")
.attach()
.apply();
}


@Test
public void canResetPasswordUsingVMAccessExtension() throws Exception {
final String RG_NAME = ResourceNamer.randomResourceName("vmexttest", 15);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"diagnosticMonitorConfiguration":{"metrics":{"resourceId":"%VirtualMachineResourceId%","metricAggregation":[{"scheduledTransferPeriod":"PT1H"},{"scheduledTransferPeriod":"PT1M"}]},"performanceCounters":{"performanceCounterConfiguration":[{"class":"Memory","counterSpecifier":"PercentAvailableMemory","table":"LinuxMemory"},{"class":"Memory","counterSpecifier":"AvailableMemory","table":"LinuxMemory"},{"class":"Memory","counterSpecifier":"UsedMemory","table":"LinuxMemory"},{"class":"Memory","counterSpecifier":"PercentUsedSwap","table":"LinuxMemory"},{"class":"Processor","counterSpecifier":"PercentProcessorTime","table":"LinuxCpu"},{"class":"Processor","counterSpecifier":"PercentIOWaitTime","table":"LinuxCpu"},{"class":"Processor","counterSpecifier":"PercentIdleTime","table":"LinuxCpu"},{"class":"PhysicalDisk","counterSpecifier":"AverageWriteTime","table":"LinuxDisk"},{"class":"PhysicalDisk","counterSpecifier":"AverageReadTime","table":"LinuxDisk"},{"class":"PhysicalDisk","counterSpecifier":"ReadBytesPerSecond","table":"LinuxDisk"},{"class":"PhysicalDisk","counterSpecifier":"WriteBytesPerSecond","table":"LinuxDisk"}]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<WadCfg><DiagnosticMonitorConfiguration overallQuotaInMB="4096"><DiagnosticInfrastructureLogs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Warning"/><PerformanceCounters scheduledTransferPeriod="PT1M"><PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT15S" unit="Percent"><annotation displayName="CPU utilization" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Privileged Time" sampleRate="PT15S" unit="Percent"><annotation displayName="CPU privileged time" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% User Time" sampleRate="PT15S" unit="Percent"><annotation displayName="CPU user time" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Processor Information(_Total)\Processor Frequency" sampleRate="PT15S" unit="Count"><annotation displayName="CPU frequency" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\System\Processes" sampleRate="PT15S" unit="Count"><annotation displayName="Processes" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Process(_Total)\Thread Count" sampleRate="PT15S" unit="Count"><annotation displayName="Threads" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Process(_Total)\Handle Count" sampleRate="PT15S" unit="Count"><annotation displayName="Handles" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Memory\% Committed Bytes In Use" sampleRate="PT15S" unit="Percent"><annotation displayName="Memory usage" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Memory\Available Bytes" sampleRate="PT15S" unit="Bytes"><annotation displayName="Memory available" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Memory\Committed Bytes" sampleRate="PT15S" unit="Bytes"><annotation displayName="Memory committed" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Memory\Commit Limit" sampleRate="PT15S" unit="Bytes"><annotation displayName="Memory commit limit" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Memory\Pool Paged Bytes" sampleRate="PT15S" unit="Bytes"><annotation displayName="Memory paged pool" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\Memory\Pool Nonpaged Bytes" sampleRate="PT15S" unit="Bytes"><annotation displayName="Memory non-paged pool" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Time" sampleRate="PT15S" unit="Percent"><annotation displayName="Disk active time" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Read Time" sampleRate="PT15S" unit="Percent"><annotation displayName="Disk active read time" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Write Time" sampleRate="PT15S" unit="Percent"><annotation displayName="Disk active write time" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Transfers/sec" sampleRate="PT15S" unit="CountPerSecond"><annotation displayName="Disk operations" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Reads/sec" sampleRate="PT15S" unit="CountPerSecond"><annotation displayName="Disk read operations" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Writes/sec" sampleRate="PT15S" unit="CountPerSecond"><annotation displayName="Disk write operations" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Bytes/sec" sampleRate="PT15S" unit="BytesPerSecond"><annotation displayName="Disk speed" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Read Bytes/sec" sampleRate="PT15S" unit="BytesPerSecond"><annotation displayName="Disk read speed" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Write Bytes/sec" sampleRate="PT15S" unit="BytesPerSecond"><annotation displayName="Disk write speed" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Queue Length" sampleRate="PT15S" unit="Count"><annotation displayName="Disk average queue length" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Read Queue Length" sampleRate="PT15S" unit="Count"><annotation displayName="Disk average read queue length" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Write Queue Length" sampleRate="PT15S" unit="Count"><annotation displayName="Disk average write queue length" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(_Total)\% Free Space" sampleRate="PT15S" unit="Percent"><annotation displayName="Disk free space (percentage)" locale="en-us"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(_Total)\Free Megabytes" sampleRate="PT15S" unit="Count"><annotation displayName="Disk free space (MB)" locale="en-us"/></PerformanceCounterConfiguration></PerformanceCounters><WindowsEventLog scheduledTransferPeriod="PT1M"><DataSource name="Application!*[System[(Level = 1 or Level = 2)]]"/><DataSource name="Security!*[System[(Level = 1 or Level = 2)]"/><DataSource name="System!*[System[(Level = 1 or Level = 2)]]"/></WindowsEventLog><Metrics resourceId="%VirtualMachineResourceId%"><MetricAggregation scheduledTransferPeriod="PT1H"/><MetricAggregation scheduledTransferPeriod="PT1M"/></Metrics></DiagnosticMonitorConfiguration></WadCfg>
Loading

0 comments on commit e58490e

Please sign in to comment.