marvin-factories: inherit from ABSTRACT_FACTORY This is done to remove dependency on an ORM.
+ Additional APIs from multiple ip per nic. Signed-off-by: Prasanna Santhanam <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/069abf78 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/069abf78 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/069abf78 Branch: refs/heads/marvin-refactor Commit: 069abf78d321827d2c16ae2fa53b24b448a78ef1 Parents: 41f2ac0 Author: Prasanna Santhanam <[email protected]> Authored: Mon Mar 4 19:11:36 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Mon Mar 4 19:11:36 2013 +0530 ---------------------------------------------------------------------- .../marvin/marvin/integration/lib/base/Account.py | 2 +- .../lib/base/DefaultNicForVirtualMachine.py | 33 +++++++++ .../integration/lib/base/EgressFirewallRule.py | 51 +++++++++++++++ .../integration/lib/base/NicFromVirtualMachine.py | 33 +++++++++ .../integration/lib/base/NicToVirtualMachine.py | 33 +++++++++ .../lib/base/SSHKeyForVirtualMachine.py | 33 +++++++++ .../integration/lib/factory/AccountFactory.py | 16 ++--- .../lib/factory/CloudStackBaseFactory.py | 25 +++++++ .../lib/factory/EgressFirewallRuleFactory.py | 24 +++++++ 9 files changed, 239 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/base/Account.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/base/Account.py b/tools/marvin/marvin/integration/lib/base/Account.py index 72750ea..cef5506 100644 --- a/tools/marvin/marvin/integration/lib/base/Account.py +++ b/tools/marvin/marvin/integration/lib/base/Account.py @@ -23,7 +23,7 @@ from marvin.cloudstackAPI import updateAccount from marvin.cloudstackAPI import disableAccount from marvin.cloudstackAPI import deleteAccount -class Account(CloudStackEntity): +class Account(CloudStackEntity.CloudStackEntity): def __init__(self, items): http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/base/DefaultNicForVirtualMachine.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/base/DefaultNicForVirtualMachine.py b/tools/marvin/marvin/integration/lib/base/DefaultNicForVirtualMachine.py new file mode 100644 index 0000000..8aa5a2f --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/DefaultNicForVirtualMachine.py @@ -0,0 +1,33 @@ +# 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. +from marvin.integration.lib.base import CloudStackEntity +from marvin.cloudstackAPI import updateDefaultNicForVirtualMachine + +class DefaultNicForVirtualMachine(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def update(self, apiclient, nicid, virtualmachineid, **kwargs): + cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd() + cmd.nicid = nicid + cmd.virtualmachineid = virtualmachineid + [setattr(cmd, key, value) for key,value in kwargs.items] + defaultnicforvirtualmachine = apiclient.updateDefaultNicForVirtualMachine(cmd) + http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py b/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py new file mode 100644 index 0000000..f1d6f47 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py @@ -0,0 +1,51 @@ +# 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. +from marvin.integration.lib.base import CloudStackEntity +from marvin.cloudstackAPI import createEgressFirewallRule +from marvin.cloudstackAPI import listEgressFirewallRules +from marvin.cloudstackAPI import deleteEgressFirewallRule + +class EgressFirewallRule(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + @classmethod + def create(cls, apiclient, EgressFirewallRuleFactory, **kwargs): + cmd = createEgressFirewallRule.createEgressFirewallRuleCmd() + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in EgressFirewallRuleFactory.attributes()] + [setattr(cmd, key, value) for key,value in kwargs.items] + egressfirewallrule = apiclient.createEgressFirewallRule(cmd) + return EgressFirewallRule(egressfirewallrule.__dict__) + + + @classmethod + def list(self, apiclient, **kwargs): + cmd = listEgressFirewallRules.listEgressFirewallRulesCmd() + [setattr(cmd, key, value) for key,value in kwargs.items] + egressfirewallrule = apiclient.listEgressFirewallRules(cmd) + return map(lambda e: EgressFirewallRule(e.__dict__), egressfirewallrule) + + + def delete(self, apiclient, id, **kwargs): + cmd = deleteEgressFirewallRule.deleteEgressFirewallRuleCmd() + cmd.id = id + [setattr(cmd, key, value) for key,value in kwargs.items] + egressfirewallrule = apiclient.deleteEgressFirewallRule(cmd) + http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/base/NicFromVirtualMachine.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/base/NicFromVirtualMachine.py b/tools/marvin/marvin/integration/lib/base/NicFromVirtualMachine.py new file mode 100644 index 0000000..6c84a6f --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/NicFromVirtualMachine.py @@ -0,0 +1,33 @@ +# 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. +from marvin.integration.lib.base import CloudStackEntity +from marvin.cloudstackAPI import removeNicFromVirtualMachine + +class NicFromVirtualMachine(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def remove(self, apiclient, nicid, virtualmachineid, **kwargs): + cmd = removeNicFromVirtualMachine.removeNicFromVirtualMachineCmd() + cmd.nicid = nicid + cmd.virtualmachineid = virtualmachineid + [setattr(cmd, key, value) for key,value in kwargs.items] + nicfromvirtualmachine = apiclient.removeNicFromVirtualMachine(cmd) + http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/base/NicToVirtualMachine.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/base/NicToVirtualMachine.py b/tools/marvin/marvin/integration/lib/base/NicToVirtualMachine.py new file mode 100644 index 0000000..e8d62d8 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/NicToVirtualMachine.py @@ -0,0 +1,33 @@ +# 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. +from marvin.integration.lib.base import CloudStackEntity +from marvin.cloudstackAPI import addNicToVirtualMachine + +class NicToVirtualMachine(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def add(self, apiclient, networkid, virtualmachineid, **kwargs): + cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd() + cmd.networkid = networkid + cmd.virtualmachineid = virtualmachineid + [setattr(cmd, key, value) for key,value in kwargs.items] + nictovirtualmachine = apiclient.addNicToVirtualMachine(cmd) + http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/base/SSHKeyForVirtualMachine.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/base/SSHKeyForVirtualMachine.py b/tools/marvin/marvin/integration/lib/base/SSHKeyForVirtualMachine.py new file mode 100644 index 0000000..c1b0e45 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/SSHKeyForVirtualMachine.py @@ -0,0 +1,33 @@ +# 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. +from marvin.integration.lib.base import CloudStackEntity +from marvin.cloudstackAPI import resetSSHKeyForVirtualMachine + +class SSHKeyForVirtualMachine(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def reset(self, apiclient, keypair, id, **kwargs): + cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd() + cmd.id = id + cmd.keypair = keypair + [setattr(cmd, key, value) for key,value in kwargs.items] + sshkeyforvirtualmachine = apiclient.resetSSHKeyForVirtualMachine(cmd) + http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/factory/AccountFactory.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py index acb93dc..894f92e 100644 --- a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py @@ -14,17 +14,18 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -import factory + from marvin.integration.lib.base import Account import hashlib +from marvin.integration.lib.factory.CloudStackBaseFactory import * from marvin.integration.lib.utils import random_gen -class AccountFactory(factory.Factory): +class AccountFactory(CloudStackBaseFactory): - FACTORY_FOR = Account + FACTORY_FOR = Account.Account accounttype = 0 - email = factory.LazyAttribute(lambda e: '{0}.{1}@cloudstack.org'.format(e.firstname, e.lastname)).lower() + email = factory.LazyAttribute(lambda e: '{0}.{1}@cloudstack.org'.format(e.firstname, e.lastname).lower()) firstname = 'fname-'+random_gen() lastname = 'lname-'+random_gen() username = None @@ -40,9 +41,4 @@ class AdminAccountFactory(AccountFactory): class DomainAdminFactory(AccountFactory): accounttype = 2 - domainid = None accounttype = None - email = None - firstname = None - lastname = None - password = None - username = None + domainid = None http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/factory/CloudStackBaseFactory.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/factory/CloudStackBaseFactory.py b/tools/marvin/marvin/integration/lib/factory/CloudStackBaseFactory.py new file mode 100644 index 0000000..a921430 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/factory/CloudStackBaseFactory.py @@ -0,0 +1,25 @@ +# 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. + +import factory + +class CloudStackBaseFactory(factory.Factory): + ABSTRACT_FACTORY = True + + @classmethod + def _create(cls, target_class, *args, **kwargs): + return target_class(*args, **kwargs) http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/069abf78/tools/marvin/marvin/integration/lib/factory/EgressFirewallRuleFactory.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/factory/EgressFirewallRuleFactory.py b/tools/marvin/marvin/integration/lib/factory/EgressFirewallRuleFactory.py new file mode 100644 index 0000000..1395429 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/factory/EgressFirewallRuleFactory.py @@ -0,0 +1,24 @@ +# 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. +import factory +from marvin.integration.lib.base import EgressFirewallRule +class EgressFirewallRuleFactory(factory.Factory): + + FACTORY_FOR = EgressFirewallRule + + networkid = None + protocol = None
