Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +   }
> +
> +   @Nullable
> +   public abstract String description();
> +
> +   public abstract Protocol protocol();
> +
> +   @Nullable
> +   public abstract String sourcePortRange();
> +
> +   @Nullable
> +   public abstract String destinationPortRange();
> +
> +   public abstract String sourceAddressPrefix();
> +
> +   public abstract String destinactionAddressPrefix();

[minor] typo: destination

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65958776

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> + NetworkSecurityRuleProperties.create("deny all out",
> + Protocol.Tcp,
> + "*",
> + "*",
> + "*",
> + "*",
> + Access.Deny,
> + 4095,
> + Direction.Outbound));
> +  ArrayList ruleList = new 
> ArrayList();
> +  ruleList.add(rule);
> +  NetworkSecurityGroup nsg = NetworkSecurityGroup.create("samplensg", 
> "westus", null,
> + 
> NetworkSecurityGroupProperties.create(ruleList, null,
> + 
>   null, null, null,
> + 
>   null),
> + null);

Same here, providing a builder would help code be more readable and get rid of 
all those null values.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65959236

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +public class NetworkSecurityGroupApiLiveTest extends 
> BaseAzureComputeApiLiveTest {
> +
> +   private String resourcegroup;
> +   private static String DEFAULT_NSG_NAME = "testNetworkSecurityGroup";
> +
> +   private NetworkSecurityGroup createGroup() {
> +  NetworkSecurityRule rule = NetworkSecurityRule.create("denyallout", 
> null, null,
> + NetworkSecurityRuleProperties.create("deny all out",
> + Protocol.Tcp,
> + "*",
> + "*",
> + "*",
> + "*",
> + Access.Deny,
> + 4095,
> + Direction.Outbound));

[minor] For factory methods that have such an amount of constructor parameters, 
we could consider providing a builder, so code is easier to read and understand.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65959122

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +  assertNotNull(result);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityGroup")
> +   public void listNetworkSecurityGroups() {
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  List result = nsgApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 1);

It would be great to do a more robust test and add a check that ensures the one 
you created is present in the list, instead of just checking the size. Once the 
live test number starts to grow (and perhaps other tests reuse the same groups, 
etc) this will help a lot when it comes to maintain them.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65959454

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +NetworkSecurityGroupProperties.create(ruleList, null,
> +  null, null, null,
> +  null),
> +null);
> +  return nsg;
> +   }
> +
> +   public void createNetworkSecurityGroup() throws InterruptedException {
> +  NetworkSecurityGroup nsg = createGroup();
> +
> +  
> server.enqueue(jsonResponse("/networksecuritygroupcreate.json").setResponseCode(200));
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +
> +  String path = 
> String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s?%s",
>  subscriptionid, resourcegroup, DEFAULT_NSG_NAME, apiVersion);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME, 
> "westus", null, nsg.properties());
> +  assertSent(server, "PUT", path);

Also verify the body being generated

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65959677

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +  resourcegroup = getResourceGroupName();
> +
> +  // a network security group is needed
> +  final NetworkSecurityGroup nsg = createGroup();
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +   }
> +
> +   @AfterClass(alwaysRun = true)
> +   @Override
> +   public void tearDown() {
> +  // remove the security group we created
> +  final NetworkSecurityGroup nsg = createGroup();

Remove this?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65961801

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +  for (int i = 0; i < result.size(); i++) {
> + if (result.get(i).name().equals(rule.name())) {
> +rulePresent = true;
> +break;
> + }
> +  }
> +  assertTrue(rulePresent);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityRule")
> +   public void listDefaultSecurityRules() {
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  List result = ruleApi.listDefaultRules();
> +
> +  assertNotNull(result);
> +  assertTrue(result.size() > 0);

Validate that the created rules are present instead of asserting the size

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65962117

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +  assertNotNull(rule);
> +
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  List result = ruleApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 2);
> +
> +  boolean rulePresent = false;
> +  for (int i = 0; i < result.size(); i++) {
> + if (result.get(i).name().equals(rule.name())) {
> +rulePresent = true;
> +break;
> + }
> +  }
> +  assertTrue(rulePresent);

Go for a more idiomatic approach with `Iterables.any`?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65962064

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Rita Zhang
> + NetworkSecurityRuleProperties.create("deny all out",
> + Protocol.Tcp,
> + "*",
> + "*",
> + "*",
> + "*",
> + Access.Deny,
> + 4095,
> + Direction.Outbound));
> +  ArrayList ruleList = new 
> ArrayList();
> +  ruleList.add(rule);
> +  NetworkSecurityGroup nsg = NetworkSecurityGroup.create("samplensg", 
> "westus", null,
> + 
> NetworkSecurityGroupProperties.create(ruleList, null,
> + 
>   null, null, null,
> + 
>   null),
> + null);

@jmspring Please refer 
[here](https://github.com/jclouds/jclouds-labs/blob/master/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/PublicIPAddressProperties.java#L50-L81)
 for an example of implementation of builder.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65962275

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +   public void deleteNetworkSecurityRule() {
> +  final NetworkSecurityRule rule = createRule();
> +  assertNotNull(rule);
> +
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  URI uri = ruleApi.delete(rule.name());
> +  if (uri != null) {
> + assertTrue(uri.toString().contains("api-version"));
> + assertTrue(uri.toString().contains("operationresults"));
> +
> + boolean jobDone = Predicates2.retry(new Predicate() {
> +@Override
> +public boolean apply(URI uri) {
> +   return ParseJobStatus.JobStatus.DONE == 
> api.getJobApi().jobStatus(uri);
> +}
> + }, 60 * 2 * 1000 /* 2 minute timeout */).apply(uri);

This predicate is recurrent, and something that potentially could be reused. 
Please, bind the reusable predicates to the Guice context so the code can be 
properly shared in the different tests, but also in the provider code that 
needs to wait.

Take a look at how this kind of predicates are configured in the [DigitalOcean 
provider](https://github.com/jclouds/jclouds/blob/master/providers/digitalocean2/src/main/java/org/jclouds/digitalocean2/compute/config/DigitalOcean2ComputeServiceContextModule.java#L108-L216)
 and [how they are used in the live 
tests](https://github.com/jclouds/jclouds/blob/master/providers/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65962712

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
> +  "*",
> +  NetworkSecurityRuleProperties.Access.Allow,
> +  4094,
> +  NetworkSecurityRuleProperties.Direction.Inbound));
> +  return rule;
> +   }
> +
> +   public void createNetworkSecurityRule() throws InterruptedException {
> +  NetworkSecurityRule rule = createRule();
> +
> +  
> server.enqueue(jsonResponse("/networksecurityrulecreate.json").setResponseCode(200));
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +
> +  String path = 
> String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s",
>  subscriptionid, resourcegroup, DEFAULT_NSG_NAME, rule.name(), apiVersion);
> +  NetworkSecurityRule result = ruleApi.createOrUpdate(rule.name(), 
> rule.properties());
> +  assertSent(server, "PUT", path);

Verify the generated body

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65962759

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Ignasi Barrera
This looks very good. Thanks @jmspring and @ritazh for the early review! It is 
much appreciated!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#issuecomment-224078542

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +  assertNotNull(result);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityGroup")
> +   public void listNetworkSecurityGroups() {
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  List result = nsgApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 1);

@nacx - do you want to go as far as creating the necessary equal methods for 
the objects, or is a more basic comparison field by field sufficient for now?  

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65986308

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +  for (int i = 0; i < result.size(); i++) {
> + if (result.get(i).name().equals(rule.name())) {
> +rulePresent = true;
> +break;
> + }
> +  }
> +  assertTrue(rulePresent);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityRule")
> +   public void listDefaultSecurityRules() {
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  List result = ruleApi.listDefaultRules();
> +
> +  assertNotNull(result);
> +  assertTrue(result.size() > 0);

Default rules are automatically created as part of the resource group.  It is 
not well defined what the default rules are and whether or not that may change 
over time.  These aren't created by code in azurecompute-arm, but rather are 
generated as part of creating the network security group.

So, suggestions for a test other than size?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r65999461

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +   }
> +
> +   @Nullable
> +   public abstract String description();
> +
> +   public abstract Protocol protocol();
> +
> +   @Nullable
> +   public abstract String sourcePortRange();
> +
> +   @Nullable
> +   public abstract String destinationPortRange();
> +
> +   public abstract String sourceAddressPrefix();
> +
> +   public abstract String destinactionAddressPrefix();

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66003900

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> + NetworkSecurityRuleProperties.create("deny all out",
> + Protocol.Tcp,
> + "*",
> + "*",
> + "*",
> + "*",
> + Access.Deny,
> + 4095,
> + Direction.Outbound));
> +  ArrayList ruleList = new 
> ArrayList();
> +  ruleList.add(rule);
> +  NetworkSecurityGroup nsg = NetworkSecurityGroup.create("samplensg", 
> "westus", null,
> + 
> NetworkSecurityGroupProperties.create(ruleList, null,
> + 
>   null, null, null,
> + 
>   null),
> + null);

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66003908

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +public class NetworkSecurityGroupApiLiveTest extends 
> BaseAzureComputeApiLiveTest {
> +
> +   private String resourcegroup;
> +   private static String DEFAULT_NSG_NAME = "testNetworkSecurityGroup";
> +
> +   private NetworkSecurityGroup createGroup() {
> +  NetworkSecurityRule rule = NetworkSecurityRule.create("denyallout", 
> null, null,
> + NetworkSecurityRuleProperties.create("deny all out",
> + Protocol.Tcp,
> + "*",
> + "*",
> + "*",
> + "*",
> + Access.Deny,
> + 4095,
> + Direction.Outbound));

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66003905

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +NetworkSecurityGroupProperties.create(ruleList, null,
> +  null, null, null,
> +  null),
> +null);
> +  return nsg;
> +   }
> +
> +   public void createNetworkSecurityGroup() throws InterruptedException {
> +  NetworkSecurityGroup nsg = createGroup();
> +
> +  
> server.enqueue(jsonResponse("/networksecuritygroupcreate.json").setResponseCode(200));
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +
> +  String path = 
> String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s?%s",
>  subscriptionid, resourcegroup, DEFAULT_NSG_NAME, apiVersion);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME, 
> "westus", null, nsg.properties());
> +  assertSent(server, "PUT", path);

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66003931

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +  assertNotNull(result);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityGroup")
> +   public void listNetworkSecurityGroups() {
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  List result = nsgApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 1);

done, added equals on NetworkSecurityRuleProperties...

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66003928

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +  resourcegroup = getResourceGroupName();
> +
> +  // a network security group is needed
> +  final NetworkSecurityGroup nsg = createGroup();
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +   }
> +
> +   @AfterClass(alwaysRun = true)
> +   @Override
> +   public void tearDown() {
> +  // remove the security group we created
> +  final NetworkSecurityGroup nsg = createGroup();

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66004016

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +  assertNotNull(rule);
> +
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  List result = ruleApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 2);
> +
> +  boolean rulePresent = false;
> +  for (int i = 0; i < result.size(); i++) {
> + if (result.get(i).name().equals(rule.name())) {
> +rulePresent = true;
> +break;
> + }
> +  }
> +  assertTrue(rulePresent);

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66004025

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +  "*",
> +  NetworkSecurityRuleProperties.Access.Allow,
> +  4094,
> +  NetworkSecurityRuleProperties.Direction.Inbound));
> +  return rule;
> +   }
> +
> +   public void createNetworkSecurityRule() throws InterruptedException {
> +  NetworkSecurityRule rule = createRule();
> +
> +  
> server.enqueue(jsonResponse("/networksecurityrulecreate.json").setResponseCode(200));
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +
> +  String path = 
> String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s",
>  subscriptionid, resourcegroup, DEFAULT_NSG_NAME, rule.name(), apiVersion);
> +  NetworkSecurityRule result = ruleApi.createOrUpdate(rule.name(), 
> rule.properties());
> +  assertSent(server, "PUT", path);

done

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66004122

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
Reopened #280.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#event-683789942

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
@nacx -- two lingering comments in place

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#issuecomment-224158501

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
Closed #280.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#event-683789930

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-06 Thread Jim Spring
> +   public void deleteNetworkSecurityRule() {
> +  final NetworkSecurityRule rule = createRule();
> +  assertNotNull(rule);
> +
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  URI uri = ruleApi.delete(rule.name());
> +  if (uri != null) {
> + assertTrue(uri.toString().contains("api-version"));
> + assertTrue(uri.toString().contains("operationresults"));
> +
> + boolean jobDone = Predicates2.retry(new Predicate() {
> +@Override
> +public boolean apply(URI uri) {
> +   return ParseJobStatus.JobStatus.DONE == 
> api.getJobApi().jobStatus(uri);
> +}
> + }, 60 * 2 * 1000 /* 2 minute timeout */).apply(uri);

@nacx - you had this same advice for @ritazh in PR#664.  Rather than 
duplicating the work, can we have this addressed as part of the work Rita is 
doing when she lands that work?  This avoids duplicate efforts.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66004115

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Ignasi Barrera
> +   public void deleteNetworkSecurityRule() {
> +  final NetworkSecurityRule rule = createRule();
> +  assertNotNull(rule);
> +
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  URI uri = ruleApi.delete(rule.name());
> +  if (uri != null) {
> + assertTrue(uri.toString().contains("api-version"));
> + assertTrue(uri.toString().contains("operationresults"));
> +
> + boolean jobDone = Predicates2.retry(new Predicate() {
> +@Override
> +public boolean apply(URI uri) {
> +   return ParseJobStatus.JobStatus.DONE == 
> api.getJobApi().jobStatus(uri);
> +}
> + }, 60 * 2 * 1000 /* 2 minute timeout */).apply(uri);

+1

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66019852

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Ignasi Barrera
> +
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +  assertNotNull(result);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityGroup")
> +   public void listNetworkSecurityGroups() {
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  List result = nsgApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 1);

Can you remove it? AutoValue already adds consistent equals and hashcode 
methods to the model classes, so it is safe (and better) to rely on them.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66020160

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Ignasi Barrera
> +  for (int i = 0; i < result.size(); i++) {
> + if (result.get(i).name().equals(rule.name())) {
> +rulePresent = true;
> +break;
> + }
> +  }
> +  assertTrue(rulePresent);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityRule")
> +   public void listDefaultSecurityRules() {
> +  final NetworkSecurityRuleApi ruleApi = 
> api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
> +  List result = ruleApi.listDefaultRules();
> +
> +  assertNotNull(result);
> +  assertTrue(result.size() > 0);

Let's keep it as-is then. Thanks for clarifying!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66020210

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Ignasi Barrera
Thanks @jmspring! Just the equals thing remaining and it will be good to go :)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#issuecomment-224199704

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Jim Spring
> +
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  NetworkSecurityGroup result = nsgApi.createOrUpdate(DEFAULT_NSG_NAME,
> +  nsg.location(),
> +  nsg.tags(),
> +  nsg.properties());
> +  assertNotNull(result);
> +   }
> +
> +   @Test(groups = "live", dependsOnMethods = "createNetworkSecurityGroup")
> +   public void listNetworkSecurityGroups() {
> +  final NetworkSecurityGroupApi nsgApi = 
> api.getNetworkSecurityGroupApi(resourcegroup);
> +  List result = nsgApi.list();
> +
> +  assertNotNull(result);
> +  assertEquals(result.size(), 1);

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280/files/7ae85f1027f814b7d751eae6d421a1bad4693417#r66088672

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Jim Spring
@nacx -- all changes should be in.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#issuecomment-224309967

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Ignasi Barrera
Closed #280.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#event-684938452

Re: [jclouds/jclouds-labs] Network Security Group API (#280)

2016-06-07 Thread Ignasi Barrera
And pushed to amster as 
[016f6e0c](http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/016f6e0c)!
 Thanks @jmspring!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/280#issuecomment-224406954