Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

user password in keystone, security group rule delete fixed

  • Loading branch information...
commit f225a1e7f0d0ee860f031cbfe865ba958c74b3e6 1 parent 6fe2342
@woorea authored
View
31 keystone-model/src/main/java/org/openstack/keystone/model/User.java
@@ -2,6 +2,7 @@
import java.io.Serializable;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;
@JsonRootName("user")
@@ -11,6 +12,9 @@
private String username;
+ @JsonProperty("OS_KSADM_password")
+ private String password;
+
private String tenantId;
private String name;
@@ -27,6 +31,13 @@ public String getId() {
}
/**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
* @return the username
*/
public String getUsername() {
@@ -41,6 +52,20 @@ public void setUsername(String username) {
}
/**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
* @return the tenantId
*/
public String getTenantId() {
@@ -101,9 +126,9 @@ public void setEnabled(Boolean enabled) {
*/
@Override
public String toString() {
- return "User [id=" + id + ", username=" + username + ", tenantId="
- + tenantId + ", name=" + name + ", email=" + email
- + ", enabled=" + enabled + "]";
+ return "User [id=" + id + ", username=" + username + ", password="
+ + password + ", tenantId=" + tenantId + ", name=" + name
+ + ", email=" + email + ", enabled=" + enabled + "]";
}
}
View
2  nova-client/src/main/java/org/openstack/nova/api/extensions/SecurityGroupsExtension.java
@@ -92,7 +92,7 @@ public DeleteSecurityGroupRule(Integer id) {
@Override
public Void execute(WebTarget target) {
- target.path("os-security-groups").path(String.valueOf(id)).request(MediaType.APPLICATION_JSON).delete();
+ target.path("os-security-group-rules").path(String.valueOf(id)).request(MediaType.APPLICATION_JSON).delete();
return null;
}
View
2  openstack-examples/src/main/java/org/openstack/examples/ExamplesConfiguration.java
@@ -2,7 +2,7 @@
public class ExamplesConfiguration {
- public static final String KEYSTONE_AUTH_URL = "";
+ public static final String KEYSTONE_AUTH_URL = "http://keystone/v2.0";
public static final String KEYSTONE_USERNAME = "admin";
View
38 openstack-examples/src/main/java/org/openstack/examples/keystone/KeystoneCreateUser.java
@@ -0,0 +1,38 @@
+package org.openstack.examples.keystone;
+
+import java.util.logging.Logger;
+
+import org.openstack.examples.ExamplesConfiguration;
+import org.openstack.keystone.KeystoneClient;
+import org.openstack.keystone.api.Authenticate;
+import org.openstack.keystone.api.CreateUser;
+import org.openstack.keystone.api.DeleteUser;
+import org.openstack.keystone.model.Access;
+import org.openstack.keystone.model.User;
+
+public class KeystoneCreateUser {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ KeystoneClient keystone = new KeystoneClient(ExamplesConfiguration.KEYSTONE_AUTH_URL);
+ //access with unscoped token
+ Access access = keystone.execute(Authenticate.withPasswordCredentials(
+ ExamplesConfiguration.KEYSTONE_USERNAME,
+ ExamplesConfiguration.KEYSTONE_PASSWORD).withTenantName("admin"));
+
+ User user = new User();
+ user.setEmail("luis@woorea.es");
+ user.setUsername("luis.gervaso");
+ user.setPassword("password.0");
+ user.setName("Luis");
+ user.setEnabled(Boolean.TRUE);
+
+ keystone = new KeystoneClient(ExamplesConfiguration.KEYSTONE_AUTH_URL, access.getToken().getId());
+ keystone.enableLogging(Logger.getLogger("keystone"), 10000);
+ user = keystone.execute(new CreateUser(user));
+ System.out.println(user);
+ keystone.execute(new DeleteUser(user.getId()));
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.