cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frankzh...@apache.org
Subject [2/3] git commit: updated refs/heads/master to 10544e2
Date Fri, 05 Sep 2014 23:24:23 GMT
CLOUDSTACK-6278
Baremetal Advanced Networking support


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c301bd1c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c301bd1c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c301bd1c

Branch: refs/heads/master
Commit: c301bd1c940f941f59dd280d7f22abe71b5279bc
Parents: c2c511e
Author: Frank.Zhang <frank.zhang@citrix.com>
Authored: Thu Aug 21 15:37:57 2014 -0700
Committer: Frank.Zhang <frank.zhang@citrix.com>
Committed: Fri Sep 5 16:28:33 2014 -0700

----------------------------------------------------------------------
 .../api/command/admin/user/RegisterCmd.java     |  4 ++
 .../baremetal/manager/BaremetalVlanManager.java |  2 +
 .../manager/BaremetalVlanManagerImpl.java       | 49 ++++++++++++++++++++
 3 files changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c301bd1c/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
old mode 100644
new mode 100755
index bb80999..2732bb9
--- a/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
@@ -52,6 +52,10 @@ public class RegisterCmd extends BaseCmd {
         return id;
     }
 
+    public void setId(Long id) {
+        this.id = id;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c301bd1c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
index 7ffe461..13e61fa 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
@@ -26,5 +26,7 @@ import org.apache.cloudstack.api.AddBaremetalRctCmd;
  * Created by frank on 4/30/14.
  */
 public interface BaremetalVlanManager extends Manager, PluggableService {
+    public static final String BAREMETAL_SYSTEM_ACCOUNT_NAME = "baremetal-system-account";
+
     BaremetalRctResponse addRct(AddBaremetalRctCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c301bd1c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
index 16daa5b..f307af4 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
@@ -20,11 +20,18 @@ package com.cloud.baremetal.manager;
 import com.cloud.baremetal.database.BaremetalRctDao;
 import com.cloud.baremetal.database.BaremetalRctVO;
 import com.cloud.baremetal.networkservice.BaremetalRctResponse;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.google.gson.Gson;
 import org.apache.cloudstack.api.AddBaremetalRctCmd;
+import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
 import org.springframework.web.client.RestTemplate;
 
 import javax.inject.Inject;
@@ -32,6 +39,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
 /**
  * Created by frank on 5/8/14.
@@ -41,6 +49,12 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
 
     @Inject
     private BaremetalRctDao rctDao;
+    @Inject
+    private AccountDao acntDao;
+    @Inject
+    private UserDao userDao;
+    @Inject
+    private AccountManager acntMgr;
 
     @Override
     public BaremetalRctResponse addRct(AddBaremetalRctCmd cmd) {
@@ -78,6 +92,41 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
         return "Baremetal Vlan Manager";
     }
 
+    @Override
+    public boolean start() {
+        QueryBuilder<AccountVO> acntq = QueryBuilder.create(AccountVO.class);
+        acntq.and(acntq.entity().getAccountName(), SearchCriteria.Op.EQ, BaremetalVlanManager.BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        AccountVO acnt = acntq.find();
+        if (acnt != null) {
+            return true;
+        }
+
+        acnt = new AccountVO();
+        acnt.setAccountName(BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        acnt.setUuid(UUID.randomUUID().toString());
+        acnt.setState(Account.State.enabled);
+        acnt.setDomainId(1);
+        acnt = acntDao.persist(acnt);
+
+        UserVO user = new UserVO();
+        user.setState(Account.State.enabled);
+        user.setUuid(UUID.randomUUID().toString());
+        user.setAccountId(acnt.getAccountId());
+        user.setUsername(BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        user.setFirstname(BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        user.setLastname(BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        user.setPassword(UUID.randomUUID().toString());
+        user = userDao.persist(user);
+
+        RegisterCmd cmd = new RegisterCmd();
+        cmd.setId(user.getId());
+        String[] keys = acntMgr.createApiKeyAndSecretKey(cmd);
+        user.setApiKey(keys[0]);
+        user.setSecretKey(keys[1]);
+        userDao.update(user.getId(), user);
+        return true;
+    }
+
 
     @Override
     public List<Class<?>> getCommands() {


Mime
View raw message