1111import com .google .common .base .Optional ;
1212import com .google .common .collect .ImmutableList ;
1313import com .google .common .collect .ImmutableSet ;
14- import com .google .common .net .UrlEscapers ;
1514import org .apache .brooklyn .location .jclouds .JcloudsLocation ;
1615import org .apache .brooklyn .location .jclouds .JcloudsMachineLocation ;
17- import org .apache .brooklyn .util .exceptions .Exceptions ;
1816import org .apache .brooklyn .util .repeat .Repeater ;
1917import org .apache .brooklyn .util .text .Identifiers ;
2018import org .apache .brooklyn .util .text .StringShortener ;
2119import org .apache .brooklyn .util .text .Strings ;
2220import org .apache .brooklyn .util .time .Duration ;
2321import org .jclouds .azurecompute .arm .AzureComputeApi ;
2422import org .jclouds .azurecompute .arm .domain .DataDisk ;
25- import org .jclouds .azurecompute .arm .domain .Deployment ;
2623import org .jclouds .azurecompute .arm .domain .Disk ;
2724import org .jclouds .azurecompute .arm .domain .ManagedDiskParameters ;
2825import org .jclouds .azurecompute .arm .domain .ResourceGroup ;
3128import org .jclouds .azurecompute .arm .domain .VirtualMachine ;
3229import org .jclouds .azurecompute .arm .domain .VirtualMachineProperties ;
3330import org .jclouds .azurecompute .arm .features .DiskApi ;
34- import org .jclouds .azurecompute .arm .features .DeploymentApi ;
3531import org .jclouds .azurecompute .arm .features .ResourceGroupApi ;
3632import org .jclouds .azurecompute .arm .features .StorageAccountApi ;
3733import org .jclouds .azurecompute .arm .features .VirtualMachineApi ;
3834import org .slf4j .Logger ;
3935import org .slf4j .LoggerFactory ;
4036
41- import java .io .IOException ;
42- import java .nio .file .Files ;
43- import java .nio .file .Paths ;
4437import java .util .List ;
4538import java .util .concurrent .Callable ;
4639import java .util .concurrent .TimeUnit ;
@@ -161,11 +154,9 @@ private AttachedBlockDevice createAndAttachBlockDevice(JcloudsMachineLocation ma
161154 }
162155
163156 int numExistingDisks = coundDataDisks (vm );
164- int lun = numExistingDisks ; // starts from 0, so if have one disk already then next will be "1"
157+ int lun = numExistingDisks ; // starts from 0, so if have one disk already then next will be "1"
165158
166- DeploymentApi deploymentApi = api .getDeploymentApi (resourceGroupName .get ());
167-
168- Disk disk = addDisk (vmApi , diskApi , vm , options .getSizeInGb (), lun , deploymentApi );
159+ Disk disk = addDisk (vmApi , diskApi , vm , options .getSizeInGb (), lun );
169160
170161 BlockDevice blockDevice = new AzureArmBlockDevice (location , disk , resourceGroupName .get (), storageAccountName );
171162 return blockDevice .attachedTo (machine , getVolumeDeviceName (options .getDeviceSuffix ()));
@@ -199,7 +190,7 @@ private void deleteStorageAccount(AzureComputeApi api, String resourceGroupName,
199190 }
200191 }
201192
202- private Disk addDisk (VirtualMachineApi vmApi , DiskApi diskApi , VirtualMachine vm , int diskSizeGB , int lun , DeploymentApi deploymentApi ) {
193+ private Disk addDisk (VirtualMachineApi vmApi , DiskApi diskApi , VirtualMachine vm , int diskSizeGB , int lun ) {
203194 String vmName = vm .name ();
204195 VirtualMachineProperties oldProperties = vm .properties ();
205196 StorageProfile oldStorageProfile = oldProperties .storageProfile ();
@@ -220,19 +211,7 @@ private Disk addDisk(VirtualMachineApi vmApi, DiskApi diskApi, VirtualMachine vm
220211 VirtualMachine newVm = vm .toBuilder ().properties (newProperties ).build ();
221212
222213 vmApi .createOrUpdate (vmName , newVm .location (), newVm .properties (), newVm .tags (), newVm .plan ());
223- Disk result = waitDiskToAppear (diskApi , diskName , TIMEOUT );
224-
225- if (vm .location ().contains ("Win" )) { //TODO make better check
226- String deploymentName = "jc" + System .currentTimeMillis ();
227- try {
228- String deploymentTemplate = UrlEscapers .urlFormParameterEscaper ().escape (new String (Files .readAllBytes (Paths .get ("customscriptextension.json" ))));
229- Deployment deployment = deploymentApi .create (deploymentName , deploymentTemplate );
230- } catch (IOException e ) {
231- Exceptions .propagate ("Failed to read customscriptextension.json" , e );
232- }
233- }
234-
235- return result ;
214+ return waitDiskToAppear (diskApi , diskName , TIMEOUT );
236215 }
237216
238217 private String getRegionName (JcloudsLocation location ) {
0 commit comments