Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread Ignasi Barrera
 @@ -123,4 +137,29 @@
 @Fallback(EmptySetOnNotFoundOr404.class)
 ListenableFuture? extends Set? extends Role 
 listRolesOfUserOnTenant(@PathParam(userId) String userId,
  @PathParam(tenantId) String tenantId);
 +   
 +   /**
 +* @see UserApi#add(String, String, Boolean, String)
 +*/
 +   @Named(user:add)
 +   @POST
 +   @SelectJson(user)
 +   @Consumes(MediaType.APPLICATION_JSON)
 +   @Path(/users)
 +   @RequestFilters(AuthenticateRequest.class)
 +   @Fallback(NullOnNotFoundOr404.class)

Is the create request supposed to return a 404? All parameters seem to be 
related to the new user being created, so is this fallback actually needed?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290/files#r9700462

[jira] [Commented] (JCLOUDS-467) nameNodes only taking first name with AWS

2014-02-13 Thread Ignasi Barrera (JIRA)

[ 
https://issues.apache.org/jira/browse/JCLOUDS-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13900119#comment-13900119
 ] 

Ignasi Barrera commented on JCLOUDS-467:


Maybe just taking the nodeNames iterator out of the loop? (don't know if it is 
smooth enough as you are testing the hasNext() in every iteration):
{code}
if (generateInstanceNames  !common.containsKey(Name)) {
   IteratorString namesIt = nodeNames.iterator();
   for (Map.EntryString, ? extends NodeMetadata entry : 
instancesById.entrySet()) {
  String id = entry.getKey();
  String name = namesIt.hasNext()? namesIt.next() : id.replaceAll(.*-, 
group + -);
  ...
   }
}
{code}

 nameNodes only taking first name with AWS
 -

 Key: JCLOUDS-467
 URL: https://issues.apache.org/jira/browse/JCLOUDS-467
 Project: jclouds
  Issue Type: Bug
  Components: jclouds-compute
Reporter: Everett Toews
Assignee: Andrew Bayer
 Fix For: 1.8.0


 I'll put nameNodes into TemplateOptions but only the first gets used.
 {code}
 public class NameNodes {
 public static final String MCW = multi-cloud-workshop;
 public static final String LOAD_BALANCER = MCW + -lb;
 public static final String DATABASE = MCW + -db;
 public static final String WEB_SERVER_01 = MCW + -webserver-01;
 public static final String WEB_SERVER_02 = MCW + -webserver-02;
 private final ComputeService computeService;
 public static void main(String[] args) {
 NameNodes nameNodes = null;
 try {
 nameNodes = new NameNodes();
 nameNodes.createServers();
 } catch (Throwable e) {
 e.printStackTrace();
 } finally {
 if (nameNodes != null) {
 nameNodes.close();
 }
 }
 }
 public NameNodes() throws IOException {
 IterableModule modules = ImmutableSet.Moduleof(
 new SLF4JLoggingModule(),
 new SshjSshClientModule());
 Properties overrides = new Properties();
 overrides.setProperty(POLL_INITIAL_PERIOD, 3);
 overrides.setProperty(POLL_MAX_PERIOD, 3);
 ComputeServiceContext context = ContextBuilder.newBuilder(aws-ec2)
 .credentials(myAwsAccessKeyId, myAwsSecretAccessKey)
 .modules(modules)
 .overrides(overrides)
 .buildView(ComputeServiceContext.class);
 computeService = context.getComputeService();
 }
 private MapString, NodeMetadata createServers() throws 
 RunNodesException, IOException {
 SetString nodeNames = ImmutableSet.of(DATABASE, WEB_SERVER_01, 
 WEB_SERVER_02, LOAD_BALANCER);
 System.out.println(format(Creating servers %s, Joiner.on(, 
 ).join(nodeNames)));
 TemplateOptions options = computeService.templateOptions()
 .nodeNames(nodeNames)
 .inboundPorts(22);
 Template template = computeService.templateBuilder()
 
 .imageNameMatches(ubuntu/images/ubuntu-precise-12.04-amd64-server-20131003)
 .locationId(us-west-2)
 .hardwareId(m1.small)
 .options(options)
 .build();
 Set? extends NodeMetadata nodes = 
 computeService.createNodesInGroup(MCW, 4, template);
 MapString, NodeMetadata nameToNode = newHashMap();
 System.out.println(Created servers:);
 for (NodeMetadata node: nodes) {
 String name = node.getName();
 String publicIpAddress = 
 getOnlyElement(node.getPublicAddresses());
 String user = node.getCredentials().getUser();
 System.out.println(format(  %-40s %s@%s, name, user, 
 publicIpAddress));
 nameToNode.put(name, node);
 }
 return nameToNode;
 }
 private void close() {
 computeService.getContext().close();
 }
 }
 {code}
 The output is
 {code}
 Creating servers multi-cloud-workshop-db, multi-cloud-workshop-webserver-01, 
 multi-cloud-workshop-webserver-02, multi-cloud-workshop-lb
 Created servers:
   multi-cloud-workshop-db  ubuntu@54.184.78.205
   multi-cloud-workshop-db  ubuntu@54.203.107.107
   multi-cloud-workshop-db  ubuntu@54.202.100.94
   multi-cloud-workshop-db  ubuntu@54.184.52.175
 {code}
 Confirmed the names of the instances in the AWS console too.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)


Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread Andrew Phillips
 @@ -81,4 +81,21 @@
  */
 Set? extends Role listRolesOfUserOnTenant(String userId, String 
 tenantId);
  
 +   /**
 +* Create a new user in keystone.

Creates (per Javadoc style guide - descriptive over imperative)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290/files#r9715276

Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread Andrew Phillips
 +   @Path(/users)
 +   @RequestFilters(AuthenticateRequest.class)
 +   @Fallback(NullOnNotFoundOr404.class)
 +   ListenableFuture? extends User add(@PayloadParam(username) String 
 userName,
 +@PayloadParam(email) String 
 userEmail,
 +@PayloadParam(enabled) boolean 
 enabled,
 +@PayloadParam(OS-KSADM:password) 
 String password);
 +   
 +   /**
 +* @see UserApi#delete(String)
 +*/
 +   @Named(user:delete)
 +   @DELETE
 +   @Path(/users/{userId})
 +   @RequestFilters(AuthenticateRequest.class)
 +   @Fallback(TrueOnNotFoundOr404.class)

Is this desirable behaviour? Are all user applications necessarily not going to 
care whether the user we try to delete actually existed or not?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290/files#r9715343

Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread Andrew Phillips
 +  
 +  User newUser = userApi.add(randUser, email, true, password);
 +  
 +  // validate that our new user exists
 +  Set? extends User newUsers = userApi.list().concat().toSet();
 +  assertTrue(newUsers.contains(newUser));
 +  
 +  // validate that we can delete our user
 +  assertTrue(userApi.delete(newUser.getId()));
 +  
 +  // validate that the user no longer exists
 +  Set? extends User finalUsers = userApi.list().concat().toSet();
 +  assertEquals(initialUsers, finalUsers);
 +   }
 +   
 +   public void testDeleteInvalidUser() {

See comment above...is this silent failure what we think users will want in 
all cases?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290/files#r9720539

Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread Austin
Fixed javadoc style comments.

I'm not particularly tied to the fallback behavior on user deletion; I'm open 
to other options. Once we figure out what behavior we want, I'll update the 
javadoc so that it better describes the behavior.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290#issuecomment-35018490

Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread Austin
 @@ -86,4 +88,37 @@ public void testUsersByName() {
}
  
 }
 +   
 +   public void testAddDeleteUser() {

I wrote this as one test because the test for the delete operation requires 
that the add operation succeed, and that we know the ID of the user that was 
created.

We should be able to figure out which operation failed by looking at which 
assert failed.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290/files#r9724443

Re: [jclouds] Add keystone user add and delete methods. (#290)

2014-02-13 Thread CloudBees pull request builder plugin
[jclouds-pull-requests 
#601](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/601/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/290#issuecomment-35023554

[jira] [Created] (JCLOUDS-468) Nova needs to handle key pair creation better in the ComputeService

2014-02-13 Thread Everett Toews (JIRA)
Everett Toews created JCLOUDS-468:
-

 Summary: Nova needs to handle key pair creation better in the 
ComputeService
 Key: JCLOUDS-468
 URL: https://issues.apache.org/jira/browse/JCLOUDS-468
 Project: jclouds
  Issue Type: Improvement
  Components: jclouds-compute
Reporter: Everett Toews
Priority: Minor
 Fix For: 1.8.0


Nova needs a strategy so it behaves more like 
org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.createNewKeyPairUnlessUserSpecifiedOtherwise()
 

Right now it only has 
org.jclouds.openstack.nova.v2_0.compute.loaders.CreateUniqueKeyPair which does 
not examine TemplateOptions to determine what to do. 



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)


[jira] [Commented] (JCLOUDS-468) Nova needs to handle key pair creation better in the ComputeService

2014-02-13 Thread Ignasi Barrera (JIRA)

[ 
https://issues.apache.org/jira/browse/JCLOUDS-468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13901196#comment-13901196
 ] 

Ignasi Barrera commented on JCLOUDS-468:


The DigitalOcean provider also needs a better keypair creation strategy. It 
could be worth trying to extract the AWS logic, as the checks it performs seem 
to be generic, into a strategy in jclouds-compute so we can easily align all 
providers with the standard keypair creation flow. WDYT?

 Nova needs to handle key pair creation better in the ComputeService
 ---

 Key: JCLOUDS-468
 URL: https://issues.apache.org/jira/browse/JCLOUDS-468
 Project: jclouds
  Issue Type: Improvement
  Components: jclouds-compute
Reporter: Everett Toews
Priority: Minor
  Labels: openstack
 Fix For: 1.8.0


 Nova needs a strategy so it behaves more like 
 org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.createNewKeyPairUnlessUserSpecifiedOtherwise()
  
 Right now it only has 
 org.jclouds.openstack.nova.v2_0.compute.loaders.CreateUniqueKeyPair which 
 does not examine TemplateOptions to determine what to do. 



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)