You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ga...@apache.org on 2019/01/25 12:03:05 UTC
[cloudstack] branch master updated: CLOUDSTACK-3049: Implemented
role update for account. (#3058)
This is an automated email from the ASF dual-hosted git repository.
gabriel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new d68712e CLOUDSTACK-3049: Implemented role update for account. (#3058)
d68712e is described below
commit d68712eb7b0a53f6426f3bff157b14eee40c368e
Author: Bitworks LLC <bw...@users.noreply.github.com>
AuthorDate: Fri Jan 25 19:02:56 2019 +0700
CLOUDSTACK-3049: Implemented role update for account. (#3058)
---
.dockerignore | 1 +
.../command/admin/account/UpdateAccountCmd.java | 16 +-
.../java/com/cloud/user/AccountManagerImpl.java | 74 +++--
.../com/cloud/user/AccountManagerImplTest.java | 14 +-
test/integration/smoke/test_accounts.py | 54 +++-
tools/docker/Dockerfile.smokedev | 143 +++++++++
tools/docker/docker_run_tests.sh | 50 ++++
tools/marvin/marvin/lib/base.py | 330 ++++++++++++---------
8 files changed, 500 insertions(+), 182 deletions(-)
diff --git a/.dockerignore b/.dockerignore
index 6ca3ad4..633d33e 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -16,6 +16,7 @@
# under the License.
cloudstack/tools/docker/Dockerfile
+cloudstack/tools/docker/Dockerfile.smokedev
.dockerignore
.idea
.git
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
index a7ce74a..43377da 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
@@ -21,6 +21,7 @@ import java.util.Map;
import javax.inject.Inject;
+import org.apache.cloudstack.api.response.RoleResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -48,16 +49,19 @@ public class UpdateAccountCmd extends BaseCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@ACL(accessType = AccessType.OperateEntry)
- @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account id")
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account UUID")
private Long id;
- @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the current account name")
+ @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Current account name")
private String accountName;
- @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "the ID of the domain where the account exists")
+ @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The UUID of the domain where the account exists")
private Long domainId;
- @Parameter(name = ApiConstants.NEW_NAME, type = CommandType.STRING, required = true, description = "new name for the account")
+ @Parameter(name = ApiConstants.ROLE_ID, type = CommandType.UUID, entityType = RoleResponse.class, description = "The UUID of the dynamic role to set for the account")
+ private Long roleId;
+
+ @Parameter(name = ApiConstants.NEW_NAME, type = CommandType.STRING, description = "New name for the account")
private String newName;
@Parameter(name = ApiConstants.NETWORK_DOMAIN,
@@ -65,7 +69,7 @@ public class UpdateAccountCmd extends BaseCmd {
description = "Network domain for the account's networks; empty string will update domainName with NULL value")
private String networkDomain;
- @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
+ @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "Details for the account used to store specific parameters")
private Map details;
@Inject
@@ -87,6 +91,8 @@ public class UpdateAccountCmd extends BaseCmd {
return domainId;
}
+ public Long getRoleId() { return roleId; }
+
public String getNewName() {
return newName;
}
diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
index 6025818..bda4cca 100644
--- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
@@ -37,8 +37,10 @@ import javax.crypto.spec.SecretKeySpec;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.QuerySelector;
+import org.apache.cloudstack.acl.Role;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.acl.SecurityChecker;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -1019,8 +1021,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
@DB
@ActionEvents({@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account"),
@ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User")})
- public UserAccount createUserAccount(final String userName, final String password, final String firstName, final String lastName, final String email, final String timezone, String accountName,
- final short accountType, final Long roleId, Long domainId, final String networkDomain, final Map<String, String> details, String accountUUID, final String userUUID,
+ public UserAccount createUserAccount(final String userName, final String password, final String firstName,
+ final String lastName, final String email, final String timezone,
+ String accountName, final short accountType, final Long roleId, Long domainId,
+ final String networkDomain, final Map<String, String> details,
+ String accountUUID, final String userUUID,
final User.Source source) {
if (accountName == null) {
@@ -1155,7 +1160,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
UserVO user = retrieveAndValidateUser(updateUserCmd);
s_logger.debug("Updating user with Id: " + user.getUuid());
- validateAndUpdatApiAndSecretKeyIfNeeded(updateUserCmd, user);
+ validateAndUpdateApiAndSecretKeyIfNeeded(updateUserCmd, user);
Account account = retrieveAndValidateAccount(user);
validateAndUpdateFirstNameIfNeeded(updateUserCmd, user);
@@ -1344,7 +1349,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
* <li>If a pair of keys is provided, we validate to see if there is an user already using the provided API key. If there is someone else using, we throw an {@link InvalidParameterValueException} because two users cannot have the same API key.
* </ul>
*/
- protected void validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmd updateUserCmd, UserVO user) {
+ protected void validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmd updateUserCmd, UserVO user) {
String apiKey = updateUserCmd.getApiKey();
String secretKey = updateUserCmd.getSecretKey();
@@ -1687,6 +1692,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
public AccountVO updateAccount(UpdateAccountCmd cmd) {
Long accountId = cmd.getId();
Long domainId = cmd.getDomainId();
+ Long roleId = cmd.getRoleId();
String accountName = cmd.getAccountName();
String newAccountName = cmd.getNewName();
String networkDomain = cmd.getNetworkDomain();
@@ -1700,6 +1706,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
account = _accountDao.findEnabledAccount(accountName, domainId);
}
+ final AccountVO acctForUpdate = _accountDao.findById(account.getId());
+
// Check if account exists
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
s_logger.error("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
@@ -1712,25 +1720,48 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
}
// Check if user performing the action is allowed to modify this account
- checkAccess(getCurrentCallingAccount(), _domainMgr.getDomain(account.getDomainId()));
+ Account caller = getCurrentCallingAccount();
+ checkAccess(caller, _domainMgr.getDomain(account.getDomainId()));
- // check if the given account name is unique in this domain for updating
- Account duplicateAcccount = _accountDao.findActiveAccount(newAccountName, domainId);
- if (duplicateAcccount != null && duplicateAcccount.getId() != account.getId()) {
- throw new InvalidParameterValueException(
- "There already exists an account with the name:" + newAccountName + " in the domain:" + domainId + " with existing account id:" + duplicateAcccount.getId());
+ if(newAccountName != null) {
+
+ if (newAccountName.isEmpty()) {
+ throw new InvalidParameterValueException("The new account name for account '" + account.getUuid() + "' " +
+ "within domain '" + domainId + "' is empty string. Account will be not renamed.");
+ }
+
+ // check if the new proposed account name is absent in the domain
+ Account existingAccount = _accountDao.findActiveAccount(newAccountName, domainId);
+ if (existingAccount != null && existingAccount.getId() != account.getId()) {
+ throw new InvalidParameterValueException("The account with the proposed name '" +
+ newAccountName + "' exists in the domain '" +
+ domainId + "' with existing account id '" + existingAccount.getId() + "'");
+ }
+
+ acctForUpdate.setAccountName(newAccountName);
}
if (networkDomain != null && !networkDomain.isEmpty()) {
if (!NetUtils.verifyDomainName(networkDomain)) {
- throw new InvalidParameterValueException(
- "Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
+ throw new InvalidParameterValueException("Invalid network domain or format. " +
+ "Total length shouldn't exceed 190 chars. Every domain part must be between 1 and 63 " +
+ "characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
+ "and the hyphen ('-'); can't start or end with \"-\"");
}
}
- final AccountVO acctForUpdate = _accountDao.findById(account.getId());
- acctForUpdate.setAccountName(newAccountName);
+
+ if (roleId != null) {
+ final List<Role> roles = cmd.roleService.listRoles();
+ final boolean roleNotFound = roles.stream().filter(r -> r.getId() == roleId).count() == 0;
+ if (roleNotFound) {
+ throw new InvalidParameterValueException("Role with ID '" + roleId.toString() + "' " +
+ "is not found or not available for the account '" + account.getUuid() + "' " +
+ "in the domain '" + domainId + "'.");
+ }
+
+ acctForUpdate.setRoleId(roleId);
+ }
if (networkDomain != null) {
if (networkDomain.isEmpty()) {
@@ -1741,17 +1772,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
}
final Account accountFinal = account;
- success = Transaction.execute(new TransactionCallback<Boolean>() {
- @Override
- public Boolean doInTransaction(TransactionStatus status) {
- boolean success = _accountDao.update(accountFinal.getId(), acctForUpdate);
-
- if (details != null && success) {
- _accountDetailsDao.update(accountFinal.getId(), details);
- }
+ success = Transaction.execute((TransactionCallback<Boolean>) status -> {
+ boolean success1 = _accountDao.update(accountFinal.getId(), acctForUpdate);
- return success;
+ if (details != null && success1) {
+ _accountDetailsDao.update(accountFinal.getId(), details);
}
+
+ return success1;
});
if (success) {
diff --git a/server/src/test/java/com/cloud/user/AccountManagerImplTest.java b/server/src/test/java/com/cloud/user/AccountManagerImplTest.java
index fcb0c57..e730277 100644
--- a/server/src/test/java/com/cloud/user/AccountManagerImplTest.java
+++ b/server/src/test/java/com/cloud/user/AccountManagerImplTest.java
@@ -226,7 +226,7 @@ public class AccountManagerImplTest extends AccountManagetImplTestBase {
private void prepareMockAndExecuteUpdateUserTest(int numberOfExpectedCallsForSetEmailAndSetTimeZone) {
Mockito.doReturn(userVoMock).when(accountManagerImpl).retrieveAndValidateUser(UpdateUserCmdMock);
- Mockito.doNothing().when(accountManagerImpl).validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ Mockito.doNothing().when(accountManagerImpl).validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
Mockito.doReturn(accountMock).when(accountManagerImpl).retrieveAndValidateAccount(userVoMock);
Mockito.doNothing().when(accountManagerImpl).validateAndUpdateFirstNameIfNeeded(UpdateUserCmdMock, userVoMock);
@@ -242,7 +242,7 @@ public class AccountManagerImplTest extends AccountManagetImplTestBase {
InOrder inOrder = Mockito.inOrder(userVoMock, accountManagerImpl, userDaoMock, userAccountDaoMock);
inOrder.verify(accountManagerImpl).retrieveAndValidateUser(UpdateUserCmdMock);
- inOrder.verify(accountManagerImpl).validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ inOrder.verify(accountManagerImpl).validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
inOrder.verify(accountManagerImpl).retrieveAndValidateAccount(userVoMock);
inOrder.verify(accountManagerImpl).validateAndUpdateFirstNameIfNeeded(UpdateUserCmdMock, userVoMock);
@@ -275,7 +275,7 @@ public class AccountManagerImplTest extends AccountManagetImplTestBase {
@Test
public void validateAndUpdatApiAndSecretKeyIfNeededTestNoKeys() {
- accountManagerImpl.validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ accountManagerImpl.validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
Mockito.verify(accountDaoMock, Mockito.times(0)).findUserAccountByApiKey(Mockito.anyString());
}
@@ -284,14 +284,14 @@ public class AccountManagerImplTest extends AccountManagetImplTestBase {
public void validateAndUpdatApiAndSecretKeyIfNeededTestOnlyApiKeyInformed() {
Mockito.doReturn("apiKey").when(UpdateUserCmdMock).getApiKey();
- accountManagerImpl.validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ accountManagerImpl.validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
}
@Test(expected = InvalidParameterValueException.class)
public void validateAndUpdatApiAndSecretKeyIfNeededTestOnlySecretKeyInformed() {
Mockito.doReturn("secretKey").when(UpdateUserCmdMock).getSecretKey();
- accountManagerImpl.validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ accountManagerImpl.validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
}
@Test(expected = InvalidParameterValueException.class)
@@ -308,7 +308,7 @@ public class AccountManagerImplTest extends AccountManagetImplTestBase {
Pair<User, Account> pairUserAccountMock = new Pair<User, Account>(otherUserMock, Mockito.mock(Account.class));
Mockito.doReturn(pairUserAccountMock).when(accountDaoMock).findUserAccountByApiKey(apiKey);
- accountManagerImpl.validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ accountManagerImpl.validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
}
@Test
@@ -327,7 +327,7 @@ public class AccountManagerImplTest extends AccountManagetImplTestBase {
Pair<User, Account> pairUserAccountMock = new Pair<User, Account>(otherUserMock, Mockito.mock(Account.class));
Mockito.doReturn(pairUserAccountMock).when(accountDaoMock).findUserAccountByApiKey(apiKey);
- accountManagerImpl.validateAndUpdatApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
+ accountManagerImpl.validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmdMock, userVoMock);
Mockito.verify(accountDaoMock).findUserAccountByApiKey(apiKey);
Mockito.verify(userVoMock).setApiKey(apiKey);
diff --git a/test/integration/smoke/test_accounts.py b/test/integration/smoke/test_accounts.py
index 08fa813..6169bf5 100644
--- a/test/integration/smoke/test_accounts.py
+++ b/test/integration/smoke/test_accounts.py
@@ -30,7 +30,7 @@ from marvin.lib.base import (Domain,
User,
NATRule,
Template,
- PublicIPAddress)
+ PublicIPAddress, Role)
from marvin.lib.common import (get_domain,
get_zone,
get_test_template,
@@ -67,6 +67,11 @@ class Services:
# username
"password": "fr3sca",
},
+ "role": {
+ "name": "MarvinFake Role",
+ "type": "User",
+ "description": "Fake Role created by Marvin test"
+ },
"user": {
"email": "user@test.com",
"firstname": "User",
@@ -261,6 +266,53 @@ class TestAccounts(cloudstackTestCase):
return
+ @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"],
+ required_hardware="false")
+ def test_02_update_account(self):
+ """
+ Tests that accounts can be updated with new name, network domain, dynamic role
+ :return:
+ """
+ dynamic_roles_active = self.apiclient.listCapabilities(listCapabilities.listCapabilitiesCmd()).dynamicrolesenabled
+ if not dynamic_roles_active:
+ self.skipTest("Dynamic Role-Based API checker not enabled, skipping test")
+
+ ts = str(time.time())
+ network_domain = 'mycloud.com'
+
+ account = Account.create(self.apiclient, self.services['account'])
+ self.cleanup.append(account)
+
+ role = Role.create(self.apiclient, self.services['role'])
+ self.cleanup.append(role)
+
+ account.update(self.apiclient, newname=account.name + ts)
+ account.update(self.apiclient, roleid=role.id)
+ account.update(self.apiclient, networkdomain=network_domain)
+
+ list_accounts_response = list_accounts(self.apiclient, id=account.id)
+ test_account = list_accounts_response[0]
+
+ self.assertEqual(
+ test_account.roleid, role.id,
+ "Check the role for the account is changed")
+
+ self.assertEqual(
+ test_account.networkdomain, network_domain,
+ "Check the domain for the account is changed")
+
+ self.assertEqual(
+ test_account.name, account.name + ts,
+ "Check the name for the account is changed")
+
+ try:
+ account.update(self.apiclient, newname="")
+ self.fail("Account name change to empty name succeeded. Must be error.")
+ except CloudstackAPIException:
+ pass
+
+
+
class TestRemoveUserFromAccount(cloudstackTestCase):
@classmethod
diff --git a/tools/docker/Dockerfile.smokedev b/tools/docker/Dockerfile.smokedev
new file mode 100644
index 0000000..2faf44b
--- /dev/null
+++ b/tools/docker/Dockerfile.smokedev
@@ -0,0 +1,143 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# CloudStack-simulator build
+
+FROM ubuntu:16.04
+
+MAINTAINER "Apache CloudStack" <de...@cloudstack.apache.org>
+LABEL Vendor="Apache.org" License="ApacheV2" Version="4.12.0-SNAPSHOT"
+
+RUN apt-get -y update && apt-get install -y \
+ genisoimage \
+ libffi-dev \
+ libssl-dev \
+ git \
+ sudo \
+ ipmitool \
+ maven \
+ openjdk-8-jdk \
+ python-dev \
+ python-setuptools \
+ python-pip \
+ python-mysql.connector \
+ supervisor \
+ python-crypto \
+ python-openssl
+
+RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections; \
+ echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections;
+
+RUN apt-get install -qqy mysql-server && \
+ apt-get clean all && \
+ mkdir /var/run/mysqld; \
+ chown mysql /var/run/mysqld
+
+#
+# this package is needed if one wants to run marvin tests from
+# inside the running simulator.
+#
+RUN pip install pyOpenSSL
+
+RUN echo '''sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"''' >> /etc/mysql/mysql.conf.d/mysqld.cnf
+RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot password ''
+
+COPY agent /root/agent
+COPY api /root/api
+COPY build /root/build
+COPY client /root/client
+COPY cloud-cli /root/cloud-cli
+COPY cloudstack.iml /root/cloudstack.iml
+COPY core /root/core
+COPY debian /root/debian
+COPY deps /root/deps
+COPY developer /root/developer
+COPY engine /root/engine
+COPY framework /root/framework
+COPY LICENSE.header /root/LICENSE.header
+COPY LICENSE /root/LICENSE
+COPY maven-standard /root/maven-standard
+COPY NOTICE /root/NOTICE
+COPY packaging /root/packaging
+COPY plugins /root/plugins
+COPY pom.xml /root/pom.xml
+COPY python /root/python
+COPY quickcloud /root/quickcloud
+COPY requirements.txt /root/requirements.txt
+COPY scripts /root/scripts
+COPY server /root/server
+COPY services /root/services
+COPY setup /root/setup
+COPY systemvm /root/systemvm
+COPY target /root/target
+COPY test/bindirbak /root/test/bindirbak
+COPY test/conf /root/test/conf
+COPY test/metadata /root/test/metadata
+COPY test/pom.xml /root/test/pom.xml
+COPY test/scripts /root/test/scripts
+COPY test/selenium /root/test/selenium
+COPY test/systemvm /root/test/systemvm
+COPY test/target /root/test/target
+COPY tools/pom.xml /root/tools/pom.xml
+COPY tools/apidoc /root/tools/apidoc
+COPY tools/checkstyle /root/tools/checkstyle
+COPY tools/devcloud4/pom.xml /root/tools/devcloud4/pom.xml
+COPY tools/devcloud-kvm/pom.xml /root/tools/devcloud-kvm/pom.xml
+COPY tools/marvin/pom.xml /root/tools/marvin/pom.xml
+COPY tools/pom.xml /root/tools/pom.xml
+COPY ui /root/ui
+COPY usage /root/usage
+COPY utils /root/utils
+COPY vmware-base /root/vmware-base
+
+RUN cd /root && mvn -Pdeveloper -Dsimulator -DskipTests -pl "!:cloud-marvin" install
+
+RUN (/usr/bin/mysqld_safe &) && \
+ sleep 5 && \
+ cd /root && \
+ mvn -Pdeveloper -pl developer -Ddeploydb && \
+ mvn -Pdeveloper -pl developer -Ddeploydb-simulator
+
+COPY tools/marvin /root/tools/marvin
+COPY tools/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
+COPY tools/docker/docker_run_tests.sh /root
+
+RUN cd /root && mvn -Pdeveloper -Dsimulator -DskipTests -pl ":cloud-marvin"
+
+RUN MARVIN_FILE=`find /root/tools/marvin/dist/ -name "Marvin*.tar.gz"` && pip install $MARVIN_FILE
+
+COPY test/integration /root/test/integration
+COPY tools /root/tools
+
+RUN pip install --upgrade pyOpenSSL
+
+EXPOSE 8080 8096
+
+WORKDIR /root
+
+CMD ["/usr/bin/supervisord"]
+
+# --------------------------------
+#
+# docker run -v ~/dev/tmp:/tmp -v ~/IdeaProjects/cloudstack/test/integration/smoke:/root/test/integration/smoke -it
+# --name simulator -p 8080:8080 -p8096:8096 simulator:4.12
+#
+# docker exec -it simulator bash
+#
+# cat /root/docker_run_tests.sh
+# for instructions
+#
\ No newline at end of file
diff --git a/tools/docker/docker_run_tests.sh b/tools/docker/docker_run_tests.sh
new file mode 100644
index 0000000..1cc2703
--- /dev/null
+++ b/tools/docker/docker_run_tests.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+MODE=${1:-advanced}
+SUITE=${2:-smoke}
+
+export MARVIN_CONFIG=setup/dev/$MODE.cfg
+export TEST_SUITE=test/integration/$SUITE
+export ZONE_NAME=Sandbox-simulator
+
+cd /root
+
+python tools/marvin/marvin/deployDataCenter.py -i setup/dev/$MODE.cfg
+
+cat <<EOF
+
+RUN WHOLE '$SUITE' SUITE
+--------------------------
+nosetests-2.7 \
+ --with-marvin \
+ --marvin-config=${MARVIN_CONFIG} \
+ -w ${TEST_SUITE} \
+ --with-xunit \
+ --xunit-file=/tmp/bvt_selfservice_cases.xml \
+ --zone=${ZONE_NAME} \
+ --hypervisor=simulator \
+ -a tags=$MODE,required_hardware=false
+--------------------------
+OR INDIVIDUAL TEST LIKE
+--------------------------
+nosetests-2.7 -s --with-marvin --marvin-config=${MARVIN_CONFIG} --zone=${ZONE_NAME} \
+ --hypervisor=simulator -a tags=$MODE,required_hardware=false \
+ test/integration/smoke/test_accounts.py:TestAccounts
+--------------------------
+EOF
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index 060e8c1..178eabe 100755
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -32,8 +32,10 @@ import time
import hashlib
import base64
+
class Domain:
""" Domain Life Cycle """
+
def __init__(self, items):
self.__dict__.update(items)
@@ -86,7 +88,7 @@ class Domain:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listDomains(cmd))
+ return (apiclient.listDomains(cmd))
class Role:
@@ -127,7 +129,7 @@ class Role:
cmd = listRoles.listRolesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRoles(cmd))
+ return (apiclient.listRoles(cmd))
class RolePermission:
@@ -169,11 +171,12 @@ class RolePermission:
cmd = listRolePermissions.listRolePermissionsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRolePermissions(cmd))
+ return (apiclient.listRolePermissions(cmd))
class Account:
""" Account Life Cycle """
+
def __init__(self, items):
self.__dict__.update(items)
@@ -196,7 +199,7 @@ class Account:
username = username[:6]
apiclientid = apiclient.id[-85:] if len(apiclient.id) > 85 else apiclient.id
cmd.username = "-".join([username,
- random_gen(id=apiclientid, size=6)])
+ random_gen(id=apiclientid, size=6)])
if "accountUUID" in services:
cmd.accountid = "-".join([services["accountUUID"], random_gen()])
@@ -229,7 +232,7 @@ class Account:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listAccounts(cmd))
+ return (apiclient.listAccounts(cmd))
def disable(self, apiclient, lock=False):
"""Disable an account"""
@@ -238,9 +241,19 @@ class Account:
cmd.lock = lock
apiclient.disableAccount(cmd)
+ def update(self, apiclient, roleid=None, newname=None, networkdomain=""):
+ """Update account"""
+ cmd = updateAccount.updateAccountCmd()
+ cmd.id = self.id
+ cmd.networkdomain = networkdomain
+ cmd.newname = newname
+ cmd.roleid = roleid
+ apiclient.updateAccount(cmd)
+
class User:
""" User Life Cycle """
+
def __init__(self, items):
self.__dict__.update(items)
@@ -270,7 +283,7 @@ class User:
cmd.id = self.id
apiclient.deleteUser(cmd)
- def move(self, api_client, dest_accountid = None, dest_account = None, domain= None):
+ def move(self, api_client, dest_accountid=None, dest_account=None, domain=None):
if all([dest_account, dest_accountid]) is None:
raise Exception("Please add either destination account or destination account ID.")
@@ -292,7 +305,7 @@ class User:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listUsers(cmd))
+ return (apiclient.listUsers(cmd))
@classmethod
def registerUserKeys(cls, apiclient, userid):
@@ -342,6 +355,7 @@ class VirtualMachine:
EXPUNGING = EXPUNGING
STOPPING = STOPPING
STARTING = STARTING
+
# Varibles denoting VM state - end
def __init__(self, items, services):
@@ -584,9 +598,9 @@ class VirtualMachine:
cmd.datadisktemplatetodiskofferinglist = []
for datadisktemplate, diskoffering in datadisktemplate_diskoffering_list.items():
cmd.datadisktemplatetodiskofferinglist.append({
- 'datadisktemplateid': datadisktemplate,
- 'diskofferingid': diskoffering
- })
+ 'datadisktemplateid': datadisktemplate,
+ 'diskofferingid': diskoffering
+ })
# program default access to ssh
if mode.lower() == 'basic':
@@ -729,7 +743,7 @@ class VirtualMachine:
if hasattr(self, "projectid"):
projectid = self.projectid
vms = VirtualMachine.list(apiclient, projectid=projectid,
- id=self.id, listAll=True)
+ id=self.id, listAll=True)
validationresult = validateList(vms)
if validationresult[0] == FAIL:
raise Exception("VM list validation failed: %s" % validationresult[2])
@@ -749,7 +763,7 @@ class VirtualMachine:
cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.resetSSHKeyForVirtualMachine(cmd))
+ return (apiclient.resetSSHKeyForVirtualMachine(cmd))
def update(self, apiclient, **kwargs):
"""Updates the VM data"""
@@ -757,7 +771,7 @@ class VirtualMachine:
cmd = updateVirtualMachine.updateVirtualMachineCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateVirtualMachine(cmd))
+ return (apiclient.updateVirtualMachine(cmd))
def delete(self, apiclient, expunge=True, **kwargs):
"""Destroy an Instance"""
@@ -793,7 +807,7 @@ class VirtualMachine:
cmd.migrateto.append({
'volume': volume,
'pool': pool
- })
+ })
apiclient.migrateVirtualMachineWithVolume(cmd)
def attach_volume(self, apiclient, volume, deviceid=None):
@@ -838,7 +852,7 @@ class VirtualMachine:
def update_default_nic(self, apiclient, nicId):
"""Set a NIC to be the default network adapter for a VM"""
- cmd = updateDefaultNicForVirtualMachine.\
+ cmd = updateDefaultNicForVirtualMachine. \
updateDefaultNicForVirtualMachineCmd()
cmd.nicid = nicId
cmd.virtualmachineid = self.id
@@ -866,7 +880,7 @@ class VirtualMachine:
def change_service_offering(self, apiclient, serviceOfferingId):
"""Change service offering of the instance"""
- cmd = changeServiceForVirtualMachine.\
+ cmd = changeServiceForVirtualMachine. \
changeServiceForVirtualMachineCmd()
cmd.id = self.id
cmd.serviceofferingid = serviceOfferingId
@@ -880,12 +894,12 @@ class VirtualMachine:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVirtualMachines(cmd))
+ return (apiclient.listVirtualMachines(cmd))
def resetPassword(self, apiclient):
"""Resets VM password if VM created using password enabled template"""
- cmd = resetPasswordForVirtualMachine.\
+ cmd = resetPasswordForVirtualMachine. \
resetPasswordForVirtualMachineCmd()
cmd.id = self.id
try:
@@ -923,7 +937,7 @@ class VirtualMachine:
return apiclient.updateVMAffinityGroup(cmd)
def scale(self, apiclient, serviceOfferingId,
- customcpunumber=None, customcpuspeed=None, custommemory=None):
+ customcpunumber=None, customcpuspeed=None, custommemory=None):
"""Change service offering of the instance"""
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = self.id
@@ -941,6 +955,7 @@ class VirtualMachine:
class Volume:
"""Manage Volume Life cycle
"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -1058,14 +1073,14 @@ class Volume:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVolumes(cmd))
+ return (apiclient.listVolumes(cmd))
def resize(self, apiclient, **kwargs):
"""Resize a volume"""
cmd = resizeVolume.resizeVolumeCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.resizeVolume(cmd))
+ return (apiclient.resizeVolume(cmd))
@classmethod
def upload(cls, apiclient, services, zoneid=None,
@@ -1137,7 +1152,7 @@ class Volume:
"""Migrate a volume"""
cmd = migrateVolume.migrateVolumeCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.migrateVolume(cmd))
+ return (apiclient.migrateVolume(cmd))
class Snapshot:
@@ -1147,6 +1162,7 @@ class Snapshot:
# Variables denoting possible Snapshot states - start
BACKED_UP = BACKED_UP
BACKING_UP = BACKING_UP
+
# Variables denoting possible Snapshot states - end
def __init__(self, items):
@@ -1166,8 +1182,8 @@ class Snapshot:
cmd.projectid = projectid
if locationtype:
cmd.locationtype = locationtype
- if asyncbackup:
- cmd.asyncbackup = asyncbackup
+ if asyncbackup:
+ cmd.asyncbackup = asyncbackup
return Snapshot(apiclient.createSnapshot(cmd).__dict__)
def delete(self, apiclient):
@@ -1184,7 +1200,7 @@ class Snapshot:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listSnapshots(cmd))
+ return (apiclient.listSnapshots(cmd))
def validateState(self, apiclient, snapshotstate, timeout=600):
"""Check if snapshot is in required state
@@ -1204,9 +1220,9 @@ class Snapshot:
break
timeout -= 60
time.sleep(60)
- #end while
+ # end while
if isSnapshotInRequiredState:
- return[PASS, None]
+ return [PASS, None]
else:
raise Exception("Snapshot not in required state")
except Exception as e:
@@ -1315,7 +1331,7 @@ class Template:
"ispublic"] if "ispublic" in services else False
cmd.isextractable = services[
"isextractable"] if "isextractable" in services else False
- cmd.isdynamicallyscalable=services["isdynamicallyscalable"] if "isdynamicallyscalable" in services else False
+ cmd.isdynamicallyscalable = services["isdynamicallyscalable"] if "isdynamicallyscalable" in services else False
cmd.passwordenabled = services[
"passwordenabled"] if "passwordenabled" in services else False
@@ -1336,7 +1352,6 @@ class Template:
if "directdownload" in services:
cmd.directdownload = services["directdownload"]
-
# Register Template
template = apiclient.registerTemplate(cmd)
@@ -1463,7 +1478,7 @@ class Template:
cmd = updateTemplatePermissions.updateTemplatePermissionsCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateTemplatePermissions(cmd))
+ return (apiclient.updateTemplatePermissions(cmd))
def update(self, apiclient, **kwargs):
"""Updates the template details"""
@@ -1471,7 +1486,7 @@ class Template:
cmd = updateTemplate.updateTemplateCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateTemplate(cmd))
+ return (apiclient.updateTemplate(cmd))
def copy(self, apiclient, sourcezoneid, destzoneid):
"Copy Template from source Zone to Destination Zone"
@@ -1491,7 +1506,7 @@ class Template:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listTemplates(cmd))
+ return (apiclient.listTemplates(cmd))
class Iso:
@@ -1607,7 +1622,7 @@ class Iso:
cmd = updateIso.updateIsoCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateIso(cmd))
+ return (apiclient.updateIso(cmd))
@classmethod
def copy(cls, apiclient, id, sourcezoneid, destzoneid):
@@ -1628,7 +1643,7 @@ class Iso:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listIsos(cmd))
+ return (apiclient.listIsos(cmd))
class PublicIPAddress:
@@ -1687,7 +1702,7 @@ class PublicIPAddress:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listPublicIpAddresses(cmd))
+ return (apiclient.listPublicIpAddresses(cmd))
class NATRule:
@@ -1736,7 +1751,7 @@ class NATRule:
@classmethod
def update(self, apiclient, id, virtual_machine, services, fordisplay=False,
- vmguestip=None):
+ vmguestip=None):
"""Create Port forwarding rule"""
cmd = updatePortForwardingRule.updatePortForwardingRuleCmd()
cmd.id = id
@@ -1773,7 +1788,7 @@ class NATRule:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listPortForwardingRules(cmd))
+ return (apiclient.listPortForwardingRules(cmd))
class StaticNATRule:
@@ -1836,7 +1851,7 @@ class StaticNATRule:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listIpForwardingRules(cmd))
+ return (apiclient.listIpForwardingRules(cmd))
@classmethod
def enable(cls, apiclient, ipaddressid, virtualmachineid, networkid=None,
@@ -1865,7 +1880,6 @@ class StaticNATRule:
class EgressFireWallRule:
-
"""Manage Egress Firewall rule"""
def __init__(self, items):
@@ -1907,11 +1921,10 @@ class EgressFireWallRule:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listEgressFirewallRules(cmd))
+ return (apiclient.listEgressFirewallRules(cmd))
class FireWallRule:
-
"""Manage Firewall rule"""
def __init__(self, items):
@@ -1954,11 +1967,10 @@ class FireWallRule:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listFirewallRules(cmd))
+ return (apiclient.listFirewallRules(cmd))
class Autoscale:
-
"""Manage Auto scale"""
def __init__(self, items):
@@ -1970,7 +1982,7 @@ class Autoscale:
cmd = listCounters.listCountersCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listCounters(cmd))
+ return (apiclient.listCounters(cmd))
@classmethod
def createCondition(cls, apiclient, counterid, relationaloperator, threshold):
@@ -1980,7 +1992,7 @@ class Autoscale:
cmd.counterid = counterid
cmd.relationaloperator = relationaloperator
cmd.threshold = threshold
- return(apiclient.createCondition(cmd))
+ return (apiclient.createCondition(cmd))
@classmethod
def listConditions(cls, apiclient, **kwargs):
@@ -1988,7 +2000,7 @@ class Autoscale:
cmd = listConditions.listConditionsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listConditions(cmd))
+ return (apiclient.listConditions(cmd))
@classmethod
def listAutoscalePolicies(cls, apiclient, **kwargs):
@@ -1996,7 +2008,7 @@ class Autoscale:
cmd = listAutoScalePolicies.listAutoScalePoliciesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAutoScalePolicies(cmd))
+ return (apiclient.listAutoScalePolicies(cmd))
@classmethod
def createAutoscalePolicy(cls, apiclient, action, conditionids, duration, quiettime=None):
@@ -2009,7 +2021,7 @@ class Autoscale:
if quiettime:
cmd.quiettime = quiettime
- return(apiclient.createAutoScalePolicy(cmd))
+ return (apiclient.createAutoScalePolicy(cmd))
@classmethod
def updateAutoscalePolicy(cls, apiclient, id, **kwargs):
@@ -2018,7 +2030,7 @@ class Autoscale:
cmd = updateAutoScalePolicy.updateAutoScalePolicyCmd()
cmd.id = id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateAutoScalePolicy(cmd))
+ return (apiclient.updateAutoScalePolicy(cmd))
@classmethod
def listAutoscaleVmPofiles(cls, apiclient, **kwargs):
@@ -2026,7 +2038,7 @@ class Autoscale:
cmd = listAutoScaleVmProfiles.listAutoScaleVmProfilesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAutoScaleVmProfiles(cmd))
+ return (apiclient.listAutoScaleVmProfiles(cmd))
@classmethod
def createAutoscaleVmProfile(cls, apiclient, serviceofferingid, zoneid, templateid,
@@ -2050,7 +2062,7 @@ class Autoscale:
'value': value
})
- return(apiclient.createAutoScaleVmProfile(cmd))
+ return (apiclient.createAutoScaleVmProfile(cmd))
@classmethod
def updateAutoscaleVMProfile(cls, apiclient, id, **kwargs):
@@ -2059,11 +2071,11 @@ class Autoscale:
cmd = updateAutoScaleVmProfile.updateAutoScaleVmProfileCmd()
cmd.id = id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateAutoScaleVmProfile(cmd))
+ return (apiclient.updateAutoScaleVmProfile(cmd))
@classmethod
def createAutoscaleVmGroup(cls, apiclient, lbruleid, minmembers, maxmembers,
- scaledownpolicyids, scaleuppolicyids, vmprofileid, interval=None):
+ scaledownpolicyids, scaleuppolicyids, vmprofileid, interval=None):
"""creates Autoscale VM Group."""
cmd = createAutoScaleVmGroup.createAutoScaleVmGroupCmd()
@@ -2076,7 +2088,7 @@ class Autoscale:
if interval:
cmd.interval = interval
- return(apiclient.createAutoScaleVmGroup(cmd))
+ return (apiclient.createAutoScaleVmGroup(cmd))
@classmethod
def listAutoscaleVmGroup(cls, apiclient, **kwargs):
@@ -2084,7 +2096,7 @@ class Autoscale:
cmd = listAutoScaleVmGroups.listAutoScaleVmGroupsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAutoScaleVmGroups(cmd))
+ return (apiclient.listAutoScaleVmGroups(cmd))
@classmethod
def enableAutoscaleVmGroup(cls, apiclient, id, **kwargs):
@@ -2093,7 +2105,7 @@ class Autoscale:
cmd = enableAutoScaleVmGroup.enableAutoScaleVmGroupCmd()
cmd.id = id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.enableAutoScaleVmGroup(cmd))
+ return (apiclient.enableAutoScaleVmGroup(cmd))
@classmethod
def disableAutoscaleVmGroup(cls, apiclient, id, **kwargs):
@@ -2102,7 +2114,7 @@ class Autoscale:
cmd = disableAutoScaleVmGroup.disableAutoScaleVmGroupCmd()
cmd.id = id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.disableAutoScaleVmGroup(cmd))
+ return (apiclient.disableAutoScaleVmGroup(cmd))
@classmethod
def updateAutoscaleVMGroup(cls, apiclient, id, **kwargs):
@@ -2111,11 +2123,10 @@ class Autoscale:
cmd = updateAutoScaleVmGroup.updateAutoScaleVmGroupCmd()
cmd.id = id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateAutoScaleVmGroup(cmd))
+ return (apiclient.updateAutoScaleVmGroup(cmd))
class ServiceOffering:
-
"""Manage service offerings cycle"""
def __init__(self, items):
@@ -2198,7 +2209,7 @@ class ServiceOffering:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listServiceOfferings(cmd))
+ return (apiclient.listServiceOfferings(cmd))
class DiskOffering:
@@ -2264,7 +2275,7 @@ class DiskOffering:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listDiskOfferings(cmd))
+ return (apiclient.listDiskOfferings(cmd))
class NetworkOffering:
@@ -2297,8 +2308,8 @@ class NetworkOffering:
})
if "serviceCapabilityList" in services:
cmd.servicecapabilitylist = []
- for service, capability in services["serviceCapabilityList"].\
- items():
+ for service, capability in services["serviceCapabilityList"]. \
+ items():
for ctype, value in capability.items():
cmd.servicecapabilitylist.append({
'service': service,
@@ -2321,7 +2332,6 @@ class NetworkOffering:
if "servicepackagedescription" in services:
cmd.details[0]["servicepackagedescription"] = services["servicepackagedescription"]
-
cmd.availability = 'Optional'
[setattr(cmd, k, v) for k, v in kwargs.items()]
@@ -2341,7 +2351,7 @@ class NetworkOffering:
cmd = updateNetworkOffering.updateNetworkOfferingCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateNetworkOffering(cmd))
+ return (apiclient.updateNetworkOffering(cmd))
@classmethod
def list(cls, apiclient, **kwargs):
@@ -2351,7 +2361,7 @@ class NetworkOffering:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNetworkOfferings(cmd))
+ return (apiclient.listNetworkOfferings(cmd))
class SnapshotPolicy:
@@ -2386,10 +2396,12 @@ class SnapshotPolicy:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listSnapshotPolicies(cmd))
+ return (apiclient.listSnapshotPolicies(cmd))
+
class GuestOs:
"""Guest OS calls (currently read-only implemented)"""
+
def __init(self, items):
self.__dict__.update(items)
@@ -2414,7 +2426,8 @@ class GuestOs:
cmd = listOsTypes.listOsTypesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listOsTypes(cmd))
+ return (apiclient.listOsTypes(cmd))
+
class Hypervisor:
"""Manage Hypervisor"""
@@ -2430,7 +2443,7 @@ class Hypervisor:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listHypervisors(cmd))
+ return (apiclient.listHypervisors(cmd))
class LoadBalancerRule:
@@ -2562,7 +2575,7 @@ class LoadBalancerRule:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listLoadBalancerRules(cmd))
+ return (apiclient.listLoadBalancerRules(cmd))
@classmethod
def listLoadBalancerRuleInstances(cls, apiclient, id, lbvmips=False, applied=None, **kwargs):
@@ -2627,7 +2640,7 @@ class Cluster:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listClusters(cmd))
+ return (apiclient.listClusters(cmd))
@classmethod
def update(cls, apiclient, **kwargs):
@@ -2635,7 +2648,7 @@ class Cluster:
cmd = updateCluster.updateClusterCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateCluster(cmd))
+ return (apiclient.updateCluster(cmd))
class Host:
@@ -2731,7 +2744,8 @@ class Host:
retry_interval = 10
num_tries = 10
- wait_result, return_val = wait_until(retry_interval, num_tries, Host._check_resource_state, apiclient, self.id, HOST_RS_MAINTENANCE)
+ wait_result, return_val = wait_until(retry_interval, num_tries, Host._check_resource_state, apiclient, self.id,
+ HOST_RS_MAINTENANCE)
if not wait_result:
raise Exception(return_val)
@@ -2765,7 +2779,7 @@ class Host:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listHosts(cmd))
+ return (apiclient.listHosts(cmd))
@classmethod
def listForMigration(cls, apiclient, **kwargs):
@@ -2775,7 +2789,7 @@ class Host:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.findHostsForMigration(cmd))
+ return (apiclient.findHostsForMigration(cmd))
@classmethod
def update(cls, apiclient, **kwargs):
@@ -2783,7 +2797,7 @@ class Host:
cmd = updateHost.updateHostCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateHost(cmd))
+ return (apiclient.updateHost(cmd))
@classmethod
def reconnect(cls, apiclient, **kwargs):
@@ -2791,7 +2805,7 @@ class Host:
cmd = reconnectHost.reconnectHostCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.reconnectHost(cmd))
+ return (apiclient.reconnectHost(cmd))
@classmethod
def getState(cls, apiclient, hostid, state, resourcestate, timeout=600):
@@ -2808,11 +2822,12 @@ class Host:
while timeout > 0:
try:
hosts = Host.list(apiclient,
- id=hostid, listall=True)
+ id=hostid, listall=True)
validationresult = validateList(hosts)
if validationresult[0] == FAIL:
raise Exception("Host list validation failed: %s" % validationresult[2])
- elif str(hosts[0].state).lower().decode("string_escape") == str(state).lower() and str(hosts[0].resourcestate).lower().decode("string_escape") == str(resourcestate).lower():
+ elif str(hosts[0].state).lower().decode("string_escape") == str(state).lower() and str(
+ hosts[0].resourcestate).lower().decode("string_escape") == str(resourcestate).lower():
returnValue = [PASS, None]
break
except Exception as e:
@@ -2822,6 +2837,7 @@ class Host:
timeout -= 60
return returnValue
+
class StoragePool:
"""Manage Storage pools (Primary Storage)"""
@@ -2922,7 +2938,7 @@ class StoragePool:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listStoragePools(cmd))
+ return (apiclient.listStoragePools(cmd))
@classmethod
def listForMigration(cls, apiclient, **kwargs):
@@ -2932,7 +2948,7 @@ class StoragePool:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.findStoragePoolsForMigration(cmd))
+ return (apiclient.findStoragePoolsForMigration(cmd))
@classmethod
def update(cls, apiclient, **kwargs):
@@ -2956,7 +2972,7 @@ class StoragePool:
while timeout > 0:
try:
pools = StoragePool.list(apiclient,
- id=poolid, listAll=True)
+ id=poolid, listAll=True)
validationresult = validateList(pools)
if validationresult[0] == FAIL:
raise Exception("Pool list validation failed: %s" % validationresult[2])
@@ -2970,6 +2986,7 @@ class StoragePool:
timeout -= 60
return returnValue
+
class Network:
"""Manage Network pools"""
@@ -3046,7 +3063,7 @@ class Network:
cmd = updateNetwork.updateNetworkCmd()
cmd.id = self.id
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateNetwork(cmd))
+ return (apiclient.updateNetwork(cmd))
def restart(self, apiclient, cleanup=None):
"""Restarts the network"""
@@ -3055,14 +3072,14 @@ class Network:
cmd.id = self.id
if cleanup:
cmd.cleanup = cleanup
- return(apiclient.restartNetwork(cmd))
+ return (apiclient.restartNetwork(cmd))
def migrate(self, apiclient, network_offering_id, resume=False):
cmd = migrateNetwork.migrateNetworkCmd()
cmd.networkid = self.id
cmd.networkofferingid = network_offering_id
cmd.resume = resume
- return(apiclient.migrateNetwork(cmd))
+ return (apiclient.migrateNetwork(cmd))
@classmethod
def list(cls, apiclient, **kwargs):
@@ -3072,7 +3089,7 @@ class Network:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNetworks(cmd))
+ return (apiclient.listNetworks(cmd))
class NetworkACL:
@@ -3149,7 +3166,7 @@ class NetworkACL:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNetworkACLs(cmd))
+ return (apiclient.listNetworkACLs(cmd))
class NetworkACLList:
@@ -3196,7 +3213,7 @@ class NetworkACLList:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNetworkACLLists(cmd))
+ return (apiclient.listNetworkACLLists(cmd))
class Vpn:
@@ -3265,14 +3282,14 @@ class Vpn:
"""List all VPN Gateways matching criteria"""
cmd = listVpnGateways.listVpnGatewaysCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVpnGateways(cmd))
+ return (apiclient.listVpnGateways(cmd))
@classmethod
def listVpnConnection(cls, apiclient, **kwargs):
"""List all VPN Connections matching criteria"""
cmd = listVpnConnections.listVpnConnectionsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVpnConnections(cmd))
+ return (apiclient.listVpnConnections(cmd))
def delete(self, apiclient):
"""Delete remote VPN access"""
@@ -3289,7 +3306,7 @@ class Vpn:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listRemoteAccessVpns(cmd))
+ return (apiclient.listRemoteAccessVpns(cmd))
class VpnUser:
@@ -3335,7 +3352,7 @@ class VpnUser:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVpnUsers(cmd))
+ return (apiclient.listVpnUsers(cmd))
class Zone:
@@ -3387,7 +3404,8 @@ class Zone:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listZones(cmd))
+ return (apiclient.listZones(cmd))
+
class Pod:
"""Manage Pod"""
@@ -3433,6 +3451,7 @@ class Pod:
[setattr(cmd, k, v) for k, v in kwargs.items()]
return apiclient.updatePod(cmd)
+
class PublicIpRange:
"""Manage VlanIpRange"""
@@ -3478,7 +3497,7 @@ class PublicIpRange:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVlanIpRanges(cmd))
+ return (apiclient.listVlanIpRanges(cmd))
@classmethod
def dedicate(
@@ -3538,7 +3557,8 @@ class PortablePublicIpRange:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listPortableIpRanges(cmd))
+ return (apiclient.listPortableIpRanges(cmd))
+
class SecondaryStagingStore:
"""Manage Staging Store"""
@@ -3574,7 +3594,7 @@ class SecondaryStagingStore:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listSecondaryStagingStores(cmd))
+ return (apiclient.listSecondaryStagingStores(cmd))
class ImageStore:
@@ -3611,7 +3631,7 @@ class ImageStore:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listImageStores(cmd))
+ return (apiclient.listImageStores(cmd))
class PhysicalNetwork:
@@ -3670,7 +3690,7 @@ class PhysicalNetwork:
def release(self, apiclient):
"""Release guest vlan range"""
- cmd = releaseDedicatedGuestVlanRange.\
+ cmd = releaseDedicatedGuestVlanRange. \
releaseDedicatedGuestVlanRangeCmd()
cmd.id = self.id
return apiclient.releaseDedicatedGuestVlanRange(cmd)
@@ -3810,7 +3830,7 @@ class SecurityGroup:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listSecurityGroups(cmd))
+ return (apiclient.listSecurityGroups(cmd))
class VpnCustomerGateway:
@@ -3870,7 +3890,7 @@ class VpnCustomerGateway:
cmd.dpd = services["dpd"]
if "forceencap" in services:
cmd.forceencap = services["forceencap"]
- return(apiclient.updateVpnCustomerGateway(cmd))
+ return (apiclient.updateVpnCustomerGateway(cmd))
def delete(self, apiclient):
"""Delete VPN Customer Gateway"""
@@ -3887,7 +3907,7 @@ class VpnCustomerGateway:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVpnCustomerGateways(cmd))
+ return (apiclient.listVpnCustomerGateways(cmd))
class Project:
@@ -3966,7 +3986,7 @@ class Project:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listProjectAccounts(cmd))
+ return (apiclient.listProjectAccounts(cmd))
@classmethod
def list(cls, apiclient, **kwargs):
@@ -3976,7 +3996,7 @@ class Project:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listProjects(cmd))
+ return (apiclient.listProjects(cmd))
class ProjectInvitation:
@@ -4014,7 +4034,7 @@ class ProjectInvitation:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listProjectInvitations(cmd))
+ return (apiclient.listProjectInvitations(cmd))
class Configurations:
@@ -4033,10 +4053,9 @@ class Configurations:
if clusterid:
cmd.clusterid = clusterid
if storageid:
- cmd.storageid=storageid
+ cmd.storageid = storageid
apiclient.updateConfiguration(cmd)
-
@classmethod
def list(cls, apiclient, **kwargs):
"""Lists configurations"""
@@ -4045,14 +4064,15 @@ class Configurations:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listConfigurations(cmd))
+ return (apiclient.listConfigurations(cmd))
@classmethod
def listCapabilities(cls, apiclient, **kwargs):
"""Lists capabilities"""
cmd = listCapabilities.listCapabilitiesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listCapabilities(cmd))
+ return (apiclient.listCapabilities(cmd))
+
class NetScaler:
"""Manage external netscaler device"""
@@ -4083,12 +4103,12 @@ class NetScaler:
url = 'https://' + str(services["ipaddress"]) + '?'
url = url + 'publicinterface=' + str(services["publicinterface"]) + '&'
url = url + 'privateinterface=' + \
- str(services["privateinterface"]) + '&'
+ str(services["privateinterface"]) + '&'
url = url + 'numretries=' + str(services["numretries"]) + '&'
if "lbdevicecapacity" in services:
url = url + 'lbdevicecapacity=' + \
- str(services["lbdevicecapacity"]) + '&'
+ str(services["lbdevicecapacity"]) + '&'
url = url + 'lbdevicededicated=' + str(services["lbdevicededicated"])
@@ -4106,11 +4126,11 @@ class NetScaler:
def configure(self, apiclient, **kwargs):
"""List already registered netscaler devices"""
- cmd = configureNetscalerLoadBalancer.\
+ cmd = configureNetscalerLoadBalancer. \
configureNetscalerLoadBalancerCmd()
cmd.lbdeviceid = self.lbdeviceid
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.configureNetscalerLoadBalancer(cmd))
+ return (apiclient.configureNetscalerLoadBalancer(cmd))
@classmethod
def list(cls, apiclient, **kwargs):
@@ -4120,7 +4140,8 @@ class NetScaler:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNetscalerLoadBalancers(cmd))
+ return (apiclient.listNetscalerLoadBalancers(cmd))
+
class NiciraNvp:
@@ -4157,7 +4178,7 @@ class NiciraNvp:
elif services and 'l2gatewayserviceuuid' in services:
cmd.l2gatewayserviceuuid = services['l2gatewayserviceuuid']
- return NiciraNvp(apiclient.addNiciraNvpDevice(cmd).__dict__)
+ return NiciraNvp(apiclient.addNiciraNvpDevice(cmd).__dict__)
def delete(self, apiclient):
cmd = deleteNiciraNvpDevice.deleteNiciraNvpDeviceCmd()
@@ -4171,7 +4192,7 @@ class NiciraNvp:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNiciraNvpDevices(cmd))
+ return (apiclient.listNiciraNvpDevices(cmd))
class NetworkServiceProvider:
@@ -4223,7 +4244,7 @@ class NetworkServiceProvider:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNetworkServiceProviders(cmd))
+ return (apiclient.listNetworkServiceProviders(cmd))
class Nuage:
@@ -4278,7 +4299,7 @@ class Nuage:
cmd = listNuageVspDevices.listNuageVspDevicesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNuageVspDevices(cmd))
+ return (apiclient.listNuageVspDevices(cmd))
class Router:
@@ -4333,7 +4354,7 @@ class Router:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listRouters(cmd))
+ return (apiclient.listRouters(cmd))
class Tag:
@@ -4380,7 +4401,7 @@ class Tag:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listTags(cmd))
+ return (apiclient.listTags(cmd))
class VpcOffering:
@@ -4414,7 +4435,7 @@ class VpcOffering:
if "serviceCapabilityList" in services:
cmd.servicecapabilitylist = []
for service, capability in \
- services["serviceCapabilityList"].items():
+ services["serviceCapabilityList"].items():
for ctype, value in capability.items():
cmd.servicecapabilitylist.append({
'service': service,
@@ -4444,7 +4465,7 @@ class VpcOffering:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVPCOfferings(cmd))
+ return (apiclient.listVPCOfferings(cmd))
def delete(self, apiclient):
"""Deletes existing VPC offering"""
@@ -4499,8 +4520,7 @@ class VPC:
cmd.vpcofferingid = vpc_offering_id
cmd.tiernetworkofferings = vpc_network_offering_ids
cmd.resume = resume
- return(apiclient.migrateVPC(cmd))
-
+ return (apiclient.migrateVPC(cmd))
def delete(self, apiclient):
"""Delete VPC network"""
@@ -4524,7 +4544,7 @@ class VPC:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVPCs(cmd))
+ return (apiclient.listVPCs(cmd))
class PrivateGateway:
@@ -4566,7 +4586,7 @@ class PrivateGateway:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listPrivateGateways(cmd))
+ return (apiclient.listPrivateGateways(cmd))
class AffinityGroup:
@@ -4603,8 +4623,10 @@ class AffinityGroup:
cmd.listall = True
return apiclient.listAffinityGroups(cmd)
+
class StaticRoute:
"""Manage static route lifecycle"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -4632,11 +4654,12 @@ class StaticRoute:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listStaticRoutes(cmd))
+ return (apiclient.listStaticRoutes(cmd))
class VNMC:
"""Manage VNMC lifecycle"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -4666,7 +4689,7 @@ class VNMC:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listCiscoVnmcResources(cmd))
+ return (apiclient.listCiscoVnmcResources(cmd))
class SSHKeyPair:
@@ -4710,7 +4733,7 @@ class SSHKeyPair:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listSSHKeyPairs(cmd))
+ return (apiclient.listSSHKeyPairs(cmd))
class Capacities:
@@ -4724,7 +4747,7 @@ class Capacities:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listCapacity(cmd))
+ return (apiclient.listCapacity(cmd))
class Alert:
@@ -4738,7 +4761,7 @@ class Alert:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listAlerts(cmd))
+ return (apiclient.listAlerts(cmd))
class InstanceGroup:
@@ -4817,7 +4840,7 @@ class InstanceGroup:
def changeServiceOffering(self, apiclient, serviceOfferingId):
"""Change service offering of the vm tier"""
- cmd = changeServiceForVirtualMachine.\
+ cmd = changeServiceForVirtualMachine. \
changeServiceForVirtualMachineCmd()
cmd.group = self.id
cmd.serviceofferingid = serviceOfferingId
@@ -4832,6 +4855,7 @@ class InstanceGroup:
class ASA1000V:
"""Manage ASA 1000v lifecycle"""
+
def create(cls, apiclient, hostname, insideportprofile,
clusterid, physicalnetworkid):
"""Registers ASA 1000v appliance"""
@@ -4858,10 +4882,12 @@ class ASA1000V:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listCiscoAsa1000vResources(cmd))
+ return (apiclient.listCiscoAsa1000vResources(cmd))
+
class VmSnapshot:
"""Manage VM Snapshot life cycle"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -4885,7 +4911,7 @@ class VmSnapshot:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listVMSnapshot(cmd))
+ return (apiclient.listVMSnapshot(cmd))
@classmethod
def revertToSnapshot(cls, apiclient, vmsnapshotid):
@@ -4899,8 +4925,10 @@ class VmSnapshot:
cmd.vmsnapshotid = vmsnapshotid
return apiclient.deleteVMSnapshot(cmd)
+
class Region:
""" Regions related Api """
+
def __init__(self, items):
self.__dict__.update(items)
@@ -5034,7 +5062,8 @@ class ApplicationLoadBalancer:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listLoadBalancerRules(cmd))
+ return (apiclient.listLoadBalancerRules(cmd))
+
class Resources:
"""Manage resource limits"""
@@ -5050,7 +5079,7 @@ class Resources:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listResourceLimits(cmd))
+ return (apiclient.listResourceLimits(cmd))
@classmethod
def updateLimit(cls, apiclient, **kwargs):
@@ -5058,7 +5087,7 @@ class Resources:
cmd = updateResourceLimit.updateResourceLimitCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateResourceLimit(cmd))
+ return (apiclient.updateResourceLimit(cmd))
@classmethod
def updateCount(cls, apiclient, **kwargs):
@@ -5066,10 +5095,12 @@ class Resources:
cmd = updateResourceCount.updateResourceCountCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateResourceCount(cmd))
+ return (apiclient.updateResourceCount(cmd))
+
class NIC:
"""NIC related API"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -5080,14 +5111,14 @@ class NIC:
cmd.nicid = id
if ipaddress:
cmd.ipaddress = ipaddress
- return(apiclient.addIpToNic(cmd))
+ return (apiclient.addIpToNic(cmd))
@classmethod
def removeIp(cls, apiclient, ipaddressid):
"""Remove secondary Ip from NIC"""
cmd = removeIpFromNic.removeIpFromNicCmd()
cmd.id = ipaddressid
- return(apiclient.addIpToNic(cmd))
+ return (apiclient.addIpToNic(cmd))
@classmethod
def list(cls, apiclient, **kwargs):
@@ -5097,10 +5128,12 @@ class NIC:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listNics(cmd))
+ return (apiclient.listNics(cmd))
+
class SimulatorMock:
"""Manage simulator mock lifecycle"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -5142,8 +5175,10 @@ class SimulatorMock:
except Exception as e:
raise e
+
class Usage:
"""Manage Usage Generation"""
+
def __init__(self, items):
self.__dict__.update(items)
@@ -5154,7 +5189,7 @@ class Usage:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listUsageRecords(cmd))
+ return (apiclient.listUsageRecords(cmd))
@classmethod
def listTypes(cls, apiclient, **kwargs):
@@ -5163,14 +5198,15 @@ class Usage:
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
- return(apiclient.listUsageTypes(cmd))
+ return (apiclient.listUsageTypes(cmd))
@classmethod
def generateRecords(cls, apiclient, **kwargs):
"""Lists domains"""
cmd = generateUsageRecords.generateUsageRecordsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.generateUsageRecords(cmd))
+ return (apiclient.generateUsageRecords(cmd))
+
class TrafficType:
"""Manage different traffic types in the setup"""
@@ -5184,7 +5220,8 @@ class TrafficType:
cmd = listTrafficTypes.listTrafficTypesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listTrafficTypes(cmd))
+ return (apiclient.listTrafficTypes(cmd))
+
class StorageNetworkIpRange:
"""Manage Storage Network Ip Range"""
@@ -5198,7 +5235,8 @@ class StorageNetworkIpRange:
cmd = listStorageNetworkIpRange.listStorageNetworkIpRangeCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listStorageNetworkIpRange(cmd))
+ return (apiclient.listStorageNetworkIpRange(cmd))
+
class RegisteredServicePackage:
"""Manage ServicePackage registered with NCC"""
@@ -5212,7 +5250,7 @@ class RegisteredServicePackage:
cmd = listRegisteredServicePackages.listRegisteredServicePackagesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRegisteredServicePackages(cmd))
+ return (apiclient.listRegisteredServicePackages(cmd))
class ResourceDetails: