diff --git a/tools/marvin/marvin/integration/lib/base/Account.py b/tools/marvin/marvin/integration/lib/base/Account.py index 1b25bb64fb5..61223c23ef6 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): 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 00000000000..97d362d0227 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/DefaultNicForVirtualMachine.py @@ -0,0 +1,32 @@ +# 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) 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 00000000000..5f74351596e --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py @@ -0,0 +1,50 @@ +# 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) 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 00000000000..9a5685051f1 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/NicFromVirtualMachine.py @@ -0,0 +1,32 @@ +# 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) 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 00000000000..8d4f6c3c938 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/NicToVirtualMachine.py @@ -0,0 +1,32 @@ +# 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) 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 00000000000..a55174b55c6 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/SSHKeyForVirtualMachine.py @@ -0,0 +1,32 @@ +# 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) diff --git a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py index acb93dc5bbf..894f92ead71 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 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 00000000000..20185195ab0 --- /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) 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 00000000000..13954290d42 --- /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