diff --git a/tools/marvin/marvin/integration/lib/base/Account.py b/tools/marvin/marvin/integration/lib/base/Account.py index 61223c23ef6..2dee6364d02 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.CloudStackEntity): +class Account(CloudStackEntity): def __init__(self, items): @@ -47,8 +47,8 @@ class Account(CloudStackEntity.CloudStackEntity): @classmethod def create(cls, apiclient, AccountFactory, **kwargs): cmd = createAccount.createAccountCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AccountFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AccountFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] account = apiclient.createAccount(cmd) return Account(account.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/AutoScalePolicy.py b/tools/marvin/marvin/integration/lib/base/AutoScalePolicy.py index be07a7d0abf..062a58d5fcd 100644 --- a/tools/marvin/marvin/integration/lib/base/AutoScalePolicy.py +++ b/tools/marvin/marvin/integration/lib/base/AutoScalePolicy.py @@ -29,8 +29,8 @@ class AutoScalePolicy(CloudStackEntity): @classmethod def create(cls, apiclient, AutoScalePolicyFactory, **kwargs): cmd = createAutoScalePolicy.createAutoScalePolicyCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AutoScalePolicyFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AutoScalePolicyFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] autoscalepolicy = apiclient.createAutoScalePolicy(cmd) return AutoScalePolicy(autoscalepolicy.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/AutoScaleVmGroup.py b/tools/marvin/marvin/integration/lib/base/AutoScaleVmGroup.py index 4de66448866..232af505e57 100644 --- a/tools/marvin/marvin/integration/lib/base/AutoScaleVmGroup.py +++ b/tools/marvin/marvin/integration/lib/base/AutoScaleVmGroup.py @@ -39,8 +39,8 @@ class AutoScaleVmGroup(CloudStackEntity): @classmethod def create(cls, apiclient, AutoScaleVmGroupFactory, **kwargs): cmd = createAutoScaleVmGroup.createAutoScaleVmGroupCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AutoScaleVmGroupFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AutoScaleVmGroupFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] autoscalevmgroup = apiclient.createAutoScaleVmGroup(cmd) return AutoScaleVmGroup(autoscalevmgroup.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/AutoScaleVmProfile.py b/tools/marvin/marvin/integration/lib/base/AutoScaleVmProfile.py index bd0cc7910c2..d6e5cdfb6d1 100644 --- a/tools/marvin/marvin/integration/lib/base/AutoScaleVmProfile.py +++ b/tools/marvin/marvin/integration/lib/base/AutoScaleVmProfile.py @@ -30,8 +30,8 @@ class AutoScaleVmProfile(CloudStackEntity): @classmethod def create(cls, apiclient, AutoScaleVmProfileFactory, **kwargs): cmd = createAutoScaleVmProfile.createAutoScaleVmProfileCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AutoScaleVmProfileFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in AutoScaleVmProfileFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] autoscalevmprofile = apiclient.createAutoScaleVmProfile(cmd) return AutoScaleVmProfile(autoscalevmprofile.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/BigSwitchVnsDevice.py b/tools/marvin/marvin/integration/lib/base/BigSwitchVnsDevice.py new file mode 100644 index 00000000000..3bccb351b57 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/BigSwitchVnsDevice.py @@ -0,0 +1,49 @@ +# 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 addBigSwitchVnsDevice +from marvin.cloudstackAPI import listBigSwitchVnsDevices +from marvin.cloudstackAPI import deleteBigSwitchVnsDevice + +class BigSwitchVnsDevice(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def add(self, apiclient, physicalnetworkid, hostname, **kwargs): + cmd = addBigSwitchVnsDevice.addBigSwitchVnsDeviceCmd() + cmd.hostname = hostname + cmd.physicalnetworkid = physicalnetworkid + [setattr(cmd, key, value) for key,value in kwargs.items] + bigswitchvnsdevice = apiclient.addBigSwitchVnsDevice(cmd) + + + @classmethod + def list(self, apiclient, **kwargs): + cmd = listBigSwitchVnsDevices.listBigSwitchVnsDevicesCmd() + [setattr(cmd, key, value) for key,value in kwargs.items] + bigswitchvnsdevice = apiclient.listBigSwitchVnsDevices(cmd) + return map(lambda e: BigSwitchVnsDevice(e.__dict__), bigswitchvnsdevice) + + + def delete(self, apiclient, vnsdeviceid, **kwargs): + cmd = deleteBigSwitchVnsDevice.deleteBigSwitchVnsDeviceCmd() + cmd.vnsdeviceid = vnsdeviceid + [setattr(cmd, key, value) for key,value in kwargs.items] + bigswitchvnsdevice = apiclient.deleteBigSwitchVnsDevice(cmd) diff --git a/tools/marvin/marvin/integration/lib/base/Condition.py b/tools/marvin/marvin/integration/lib/base/Condition.py index 2abc263bb90..45c7e8036a4 100644 --- a/tools/marvin/marvin/integration/lib/base/Condition.py +++ b/tools/marvin/marvin/integration/lib/base/Condition.py @@ -29,8 +29,8 @@ class Condition(CloudStackEntity): @classmethod def create(cls, apiclient, ConditionFactory, **kwargs): cmd = createCondition.createConditionCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ConditionFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ConditionFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] condition = apiclient.createCondition(cmd) return Condition(condition.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Counter.py b/tools/marvin/marvin/integration/lib/base/Counter.py index 3990acc37fc..cac0b584d4a 100644 --- a/tools/marvin/marvin/integration/lib/base/Counter.py +++ b/tools/marvin/marvin/integration/lib/base/Counter.py @@ -29,8 +29,8 @@ class Counter(CloudStackEntity): @classmethod def create(cls, apiclient, CounterFactory, **kwargs): cmd = createCounter.createCounterCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in CounterFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in CounterFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] counter = apiclient.createCounter(cmd) return Counter(counter.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/DiskOffering.py b/tools/marvin/marvin/integration/lib/base/DiskOffering.py index 4168d7715a3..e93f5f74671 100644 --- a/tools/marvin/marvin/integration/lib/base/DiskOffering.py +++ b/tools/marvin/marvin/integration/lib/base/DiskOffering.py @@ -30,8 +30,8 @@ class DiskOffering(CloudStackEntity): @classmethod def create(cls, apiclient, DiskOfferingFactory, **kwargs): cmd = createDiskOffering.createDiskOfferingCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in DiskOfferingFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in DiskOfferingFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] diskoffering = apiclient.createDiskOffering(cmd) return DiskOffering(diskoffering.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Domain.py b/tools/marvin/marvin/integration/lib/base/Domain.py index 0134e2a8c17..2c4b7c3e3f6 100644 --- a/tools/marvin/marvin/integration/lib/base/Domain.py +++ b/tools/marvin/marvin/integration/lib/base/Domain.py @@ -30,8 +30,8 @@ class Domain(CloudStackEntity): @classmethod def create(cls, apiclient, DomainFactory, **kwargs): cmd = createDomain.createDomainCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in DomainFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in DomainFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] domain = apiclient.createDomain(cmd) return Domain(domain.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py b/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py index 5f74351596e..750ccea2cf0 100644 --- a/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py +++ b/tools/marvin/marvin/integration/lib/base/EgressFirewallRule.py @@ -29,8 +29,8 @@ class EgressFirewallRule(CloudStackEntity): @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] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in EgressFirewallRuleFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] egressfirewallrule = apiclient.createEgressFirewallRule(cmd) return EgressFirewallRule(egressfirewallrule.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/FirewallRule.py b/tools/marvin/marvin/integration/lib/base/FirewallRule.py index 232e7e6214b..c052b2a1823 100644 --- a/tools/marvin/marvin/integration/lib/base/FirewallRule.py +++ b/tools/marvin/marvin/integration/lib/base/FirewallRule.py @@ -29,8 +29,8 @@ class FirewallRule(CloudStackEntity): @classmethod def create(cls, apiclient, FirewallRuleFactory, **kwargs): cmd = createFirewallRule.createFirewallRuleCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in FirewallRuleFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in FirewallRuleFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] firewallrule = apiclient.createFirewallRule(cmd) return FirewallRule(firewallrule.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/InstanceGroup.py b/tools/marvin/marvin/integration/lib/base/InstanceGroup.py index 24ce434b27b..82cffe44681 100644 --- a/tools/marvin/marvin/integration/lib/base/InstanceGroup.py +++ b/tools/marvin/marvin/integration/lib/base/InstanceGroup.py @@ -30,8 +30,8 @@ class InstanceGroup(CloudStackEntity): @classmethod def create(cls, apiclient, InstanceGroupFactory, **kwargs): cmd = createInstanceGroup.createInstanceGroupCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in InstanceGroupFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in InstanceGroupFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] instancegroup = apiclient.createInstanceGroup(cmd) return InstanceGroup(instancegroup.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/IpForwardingRule.py b/tools/marvin/marvin/integration/lib/base/IpForwardingRule.py index aab954c5145..f80f2831438 100644 --- a/tools/marvin/marvin/integration/lib/base/IpForwardingRule.py +++ b/tools/marvin/marvin/integration/lib/base/IpForwardingRule.py @@ -29,8 +29,8 @@ class IpForwardingRule(CloudStackEntity): @classmethod def create(cls, apiclient, IpForwardingRuleFactory, **kwargs): cmd = createIpForwardingRule.createIpForwardingRuleCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in IpForwardingRuleFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in IpForwardingRuleFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] ipforwardingrule = apiclient.createIpForwardingRule(cmd) return IpForwardingRule(ipforwardingrule.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/IpFromNic.py b/tools/marvin/marvin/integration/lib/base/IpFromNic.py new file mode 100644 index 00000000000..750e14217b8 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/IpFromNic.py @@ -0,0 +1,31 @@ +# 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 removeIpFromNic + +class IpFromNic(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def remove(self, apiclient, id, **kwargs): + cmd = removeIpFromNic.removeIpFromNicCmd() + cmd.id = id + [setattr(cmd, key, value) for key,value in kwargs.items] + ipfromnic = apiclient.removeIpFromNic(cmd) diff --git a/tools/marvin/marvin/integration/lib/base/IpToNic.py b/tools/marvin/marvin/integration/lib/base/IpToNic.py new file mode 100644 index 00000000000..713c07db249 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/IpToNic.py @@ -0,0 +1,31 @@ +# 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 addIpToNic + +class IpToNic(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def add(self, apiclient, nicid, **kwargs): + cmd = addIpToNic.addIpToNicCmd() + cmd.nicid = nicid + [setattr(cmd, key, value) for key,value in kwargs.items] + iptonic = apiclient.addIpToNic(cmd) diff --git a/tools/marvin/marvin/integration/lib/base/LBStickinessPolicy.py b/tools/marvin/marvin/integration/lib/base/LBStickinessPolicy.py index feef54b819d..9d02914603b 100644 --- a/tools/marvin/marvin/integration/lib/base/LBStickinessPolicy.py +++ b/tools/marvin/marvin/integration/lib/base/LBStickinessPolicy.py @@ -28,8 +28,8 @@ class LBStickinessPolicy(CloudStackEntity): @classmethod def create(cls, apiclient, LBStickinessPolicyFactory, **kwargs): cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in LBStickinessPolicyFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in LBStickinessPolicyFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] lbstickinesspolicy = apiclient.createLBStickinessPolicy(cmd) return LBStickinessPolicy(lbstickinesspolicy.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/LoadBalancerRule.py b/tools/marvin/marvin/integration/lib/base/LoadBalancerRule.py index 2aa69a8c2e0..f5142ab071b 100644 --- a/tools/marvin/marvin/integration/lib/base/LoadBalancerRule.py +++ b/tools/marvin/marvin/integration/lib/base/LoadBalancerRule.py @@ -30,8 +30,8 @@ class LoadBalancerRule(CloudStackEntity): @classmethod def create(cls, apiclient, LoadBalancerRuleFactory, **kwargs): cmd = createLoadBalancerRule.createLoadBalancerRuleCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in LoadBalancerRuleFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in LoadBalancerRuleFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] loadbalancerrule = apiclient.createLoadBalancerRule(cmd) return LoadBalancerRule(loadbalancerrule.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Network.py b/tools/marvin/marvin/integration/lib/base/Network.py index 4d2723e9671..cb9d364965c 100644 --- a/tools/marvin/marvin/integration/lib/base/Network.py +++ b/tools/marvin/marvin/integration/lib/base/Network.py @@ -31,8 +31,8 @@ class Network(CloudStackEntity): @classmethod def create(cls, apiclient, NetworkFactory, **kwargs): cmd = createNetwork.createNetworkCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in NetworkFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in NetworkFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] network = apiclient.createNetwork(cmd) return Network(network.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/NetworkACL.py b/tools/marvin/marvin/integration/lib/base/NetworkACL.py index c6b9eeb45b1..ab3d9df4c9a 100644 --- a/tools/marvin/marvin/integration/lib/base/NetworkACL.py +++ b/tools/marvin/marvin/integration/lib/base/NetworkACL.py @@ -29,8 +29,8 @@ class NetworkACL(CloudStackEntity): @classmethod def create(cls, apiclient, NetworkACLFactory, **kwargs): cmd = createNetworkACL.createNetworkACLCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in NetworkACLFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in NetworkACLFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] networkacl = apiclient.createNetworkACL(cmd) return NetworkACL(networkacl.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/NetworkOffering.py b/tools/marvin/marvin/integration/lib/base/NetworkOffering.py index 4393285a914..804360a6755 100644 --- a/tools/marvin/marvin/integration/lib/base/NetworkOffering.py +++ b/tools/marvin/marvin/integration/lib/base/NetworkOffering.py @@ -30,8 +30,8 @@ class NetworkOffering(CloudStackEntity): @classmethod def create(cls, apiclient, NetworkOfferingFactory, **kwargs): cmd = createNetworkOffering.createNetworkOfferingCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in NetworkOfferingFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in NetworkOfferingFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] networkoffering = apiclient.createNetworkOffering(cmd) return NetworkOffering(networkoffering.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Nics.py b/tools/marvin/marvin/integration/lib/base/Nics.py new file mode 100644 index 00000000000..57338cec210 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/Nics.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 listNics + +class Nics(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + @classmethod + def list(self, apiclient, virtualmachineid, **kwargs): + cmd = listNics.listNicsCmd() + cmd.virtualmachineid = virtualmachineid + [setattr(cmd, key, value) for key,value in kwargs.items] + nics = apiclient.listNics(cmd) + return map(lambda e: Nics(e.__dict__), nics) diff --git a/tools/marvin/marvin/integration/lib/base/PhysicalNetwork.py b/tools/marvin/marvin/integration/lib/base/PhysicalNetwork.py index ac70ebb6a2d..1ba0d9e2cdc 100644 --- a/tools/marvin/marvin/integration/lib/base/PhysicalNetwork.py +++ b/tools/marvin/marvin/integration/lib/base/PhysicalNetwork.py @@ -30,8 +30,8 @@ class PhysicalNetwork(CloudStackEntity): @classmethod def create(cls, apiclient, PhysicalNetworkFactory, **kwargs): cmd = createPhysicalNetwork.createPhysicalNetworkCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PhysicalNetworkFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PhysicalNetworkFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] physicalnetwork = apiclient.createPhysicalNetwork(cmd) return PhysicalNetwork(physicalnetwork.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Pod.py b/tools/marvin/marvin/integration/lib/base/Pod.py index f967910cba7..8064075fd89 100644 --- a/tools/marvin/marvin/integration/lib/base/Pod.py +++ b/tools/marvin/marvin/integration/lib/base/Pod.py @@ -30,8 +30,8 @@ class Pod(CloudStackEntity): @classmethod def create(cls, apiclient, PodFactory, **kwargs): cmd = createPod.createPodCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PodFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PodFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] pod = apiclient.createPod(cmd) return Pod(pod.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/PortForwardingRule.py b/tools/marvin/marvin/integration/lib/base/PortForwardingRule.py index 3638bac333d..2cb4febd305 100644 --- a/tools/marvin/marvin/integration/lib/base/PortForwardingRule.py +++ b/tools/marvin/marvin/integration/lib/base/PortForwardingRule.py @@ -30,8 +30,8 @@ class PortForwardingRule(CloudStackEntity): @classmethod def create(cls, apiclient, PortForwardingRuleFactory, **kwargs): cmd = createPortForwardingRule.createPortForwardingRuleCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PortForwardingRuleFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PortForwardingRuleFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] portforwardingrule = apiclient.createPortForwardingRule(cmd) return PortForwardingRule(portforwardingrule.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/PrivateGateway.py b/tools/marvin/marvin/integration/lib/base/PrivateGateway.py index 40f2a8442de..b567e0b039f 100644 --- a/tools/marvin/marvin/integration/lib/base/PrivateGateway.py +++ b/tools/marvin/marvin/integration/lib/base/PrivateGateway.py @@ -29,8 +29,8 @@ class PrivateGateway(CloudStackEntity): @classmethod def create(cls, apiclient, PrivateGatewayFactory, **kwargs): cmd = createPrivateGateway.createPrivateGatewayCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PrivateGatewayFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in PrivateGatewayFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] privategateway = apiclient.createPrivateGateway(cmd) return PrivateGateway(privategateway.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Project.py b/tools/marvin/marvin/integration/lib/base/Project.py index a3e96f6f31b..0ba471a8665 100644 --- a/tools/marvin/marvin/integration/lib/base/Project.py +++ b/tools/marvin/marvin/integration/lib/base/Project.py @@ -39,8 +39,8 @@ class Project(CloudStackEntity): @classmethod def create(cls, apiclient, ProjectFactory, **kwargs): cmd = createProject.createProjectCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ProjectFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ProjectFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] project = apiclient.createProject(cmd) return Project(project.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Region.py b/tools/marvin/marvin/integration/lib/base/Region.py new file mode 100644 index 00000000000..03631abc067 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/Region.py @@ -0,0 +1,58 @@ +# 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 addRegion +from marvin.cloudstackAPI import listRegions +from marvin.cloudstackAPI import updateRegion +from marvin.cloudstackAPI import removeRegion + +class Region(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def add(self, apiclient, endpoint, id, name, **kwargs): + cmd = addRegion.addRegionCmd() + cmd.id = id + cmd.endpoint = endpoint + cmd.name = name + [setattr(cmd, key, value) for key,value in kwargs.items] + region = apiclient.addRegion(cmd) + + + @classmethod + def list(self, apiclient, **kwargs): + cmd = listRegions.listRegionsCmd() + [setattr(cmd, key, value) for key,value in kwargs.items] + region = apiclient.listRegions(cmd) + return map(lambda e: Region(e.__dict__), region) + + + def update(self, apiclient, id, **kwargs): + cmd = updateRegion.updateRegionCmd() + cmd.id = id + [setattr(cmd, key, value) for key,value in kwargs.items] + region = apiclient.updateRegion(cmd) + + + def remove(self, apiclient, id, **kwargs): + cmd = removeRegion.removeRegionCmd() + cmd.id = id + [setattr(cmd, key, value) for key,value in kwargs.items] + region = apiclient.removeRegion(cmd) diff --git a/tools/marvin/marvin/integration/lib/base/RemoteAccessVpn.py b/tools/marvin/marvin/integration/lib/base/RemoteAccessVpn.py index d18d5c1e141..7400a52c8b4 100644 --- a/tools/marvin/marvin/integration/lib/base/RemoteAccessVpn.py +++ b/tools/marvin/marvin/integration/lib/base/RemoteAccessVpn.py @@ -29,8 +29,8 @@ class RemoteAccessVpn(CloudStackEntity): @classmethod def create(cls, apiclient, RemoteAccessVpnFactory, **kwargs): cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in RemoteAccessVpnFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in RemoteAccessVpnFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] remoteaccessvpn = apiclient.createRemoteAccessVpn(cmd) return RemoteAccessVpn(remoteaccessvpn.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/SSHKeyPair.py b/tools/marvin/marvin/integration/lib/base/SSHKeyPair.py index f0e97755178..152ae99374e 100644 --- a/tools/marvin/marvin/integration/lib/base/SSHKeyPair.py +++ b/tools/marvin/marvin/integration/lib/base/SSHKeyPair.py @@ -30,8 +30,8 @@ class SSHKeyPair(CloudStackEntity): @classmethod def create(cls, apiclient, SSHKeyPairFactory, **kwargs): cmd = createSSHKeyPair.createSSHKeyPairCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SSHKeyPairFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SSHKeyPairFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] sshkeypair = apiclient.createSSHKeyPair(cmd) return SSHKeyPair(sshkeypair.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/SecurityGroup.py b/tools/marvin/marvin/integration/lib/base/SecurityGroup.py index fbe74909f6e..826003d6706 100644 --- a/tools/marvin/marvin/integration/lib/base/SecurityGroup.py +++ b/tools/marvin/marvin/integration/lib/base/SecurityGroup.py @@ -29,8 +29,8 @@ class SecurityGroup(CloudStackEntity): @classmethod def create(cls, apiclient, SecurityGroupFactory, **kwargs): cmd = createSecurityGroup.createSecurityGroupCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SecurityGroupFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SecurityGroupFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] securitygroup = apiclient.createSecurityGroup(cmd) return SecurityGroup(securitygroup.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/ServiceOffering.py b/tools/marvin/marvin/integration/lib/base/ServiceOffering.py index 2dda2a03171..a865925e9c3 100644 --- a/tools/marvin/marvin/integration/lib/base/ServiceOffering.py +++ b/tools/marvin/marvin/integration/lib/base/ServiceOffering.py @@ -30,8 +30,8 @@ class ServiceOffering(CloudStackEntity): @classmethod def create(cls, apiclient, ServiceOfferingFactory, **kwargs): cmd = createServiceOffering.createServiceOfferingCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ServiceOfferingFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ServiceOfferingFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] serviceoffering = apiclient.createServiceOffering(cmd) return ServiceOffering(serviceoffering.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Simulator.py b/tools/marvin/marvin/integration/lib/base/Simulator.py new file mode 100644 index 00000000000..5c58ddee8dc --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/Simulator.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 configureSimulator + +class Simulator(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + def configure(self, apiclient, name, value, **kwargs): + cmd = configureSimulator.configureSimulatorCmd() + cmd.name = name + cmd.value = value + [setattr(cmd, key, value) for key,value in kwargs.items] + simulator = apiclient.configureSimulator(cmd) diff --git a/tools/marvin/marvin/integration/lib/base/Snapshot.py b/tools/marvin/marvin/integration/lib/base/Snapshot.py index 90c42788ef2..d6a56910ce0 100644 --- a/tools/marvin/marvin/integration/lib/base/Snapshot.py +++ b/tools/marvin/marvin/integration/lib/base/Snapshot.py @@ -29,8 +29,8 @@ class Snapshot(CloudStackEntity): @classmethod def create(cls, apiclient, SnapshotFactory, **kwargs): cmd = createSnapshot.createSnapshotCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SnapshotFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SnapshotFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] snapshot = apiclient.createSnapshot(cmd) return Snapshot(snapshot.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/SnapshotPolicy.py b/tools/marvin/marvin/integration/lib/base/SnapshotPolicy.py index 1dff0d2e87b..b082900e690 100644 --- a/tools/marvin/marvin/integration/lib/base/SnapshotPolicy.py +++ b/tools/marvin/marvin/integration/lib/base/SnapshotPolicy.py @@ -27,7 +27,7 @@ class SnapshotPolicy(CloudStackEntity): @classmethod def create(cls, apiclient, SnapshotPolicyFactory, **kwargs): cmd = createSnapshotPolicy.createSnapshotPolicyCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SnapshotPolicyFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in SnapshotPolicyFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] snapshotpolicy = apiclient.createSnapshotPolicy(cmd) return SnapshotPolicy(snapshotpolicy.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/StaticRoute.py b/tools/marvin/marvin/integration/lib/base/StaticRoute.py index e24884c534b..dc87852115b 100644 --- a/tools/marvin/marvin/integration/lib/base/StaticRoute.py +++ b/tools/marvin/marvin/integration/lib/base/StaticRoute.py @@ -29,8 +29,8 @@ class StaticRoute(CloudStackEntity): @classmethod def create(cls, apiclient, StaticRouteFactory, **kwargs): cmd = createStaticRoute.createStaticRouteCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in StaticRouteFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in StaticRouteFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] staticroute = apiclient.createStaticRoute(cmd) return StaticRoute(staticroute.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/StorageNetworkIpRange.py b/tools/marvin/marvin/integration/lib/base/StorageNetworkIpRange.py index e4797fc1c12..37130ca93b5 100644 --- a/tools/marvin/marvin/integration/lib/base/StorageNetworkIpRange.py +++ b/tools/marvin/marvin/integration/lib/base/StorageNetworkIpRange.py @@ -30,8 +30,8 @@ class StorageNetworkIpRange(CloudStackEntity): @classmethod def create(cls, apiclient, StorageNetworkIpRangeFactory, **kwargs): cmd = createStorageNetworkIpRange.createStorageNetworkIpRangeCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in StorageNetworkIpRangeFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in StorageNetworkIpRangeFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] storagenetworkiprange = apiclient.createStorageNetworkIpRange(cmd) return StorageNetworkIpRange(storagenetworkiprange.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/StoragePool.py b/tools/marvin/marvin/integration/lib/base/StoragePool.py index 478407a8584..3da065ff378 100644 --- a/tools/marvin/marvin/integration/lib/base/StoragePool.py +++ b/tools/marvin/marvin/integration/lib/base/StoragePool.py @@ -30,8 +30,8 @@ class StoragePool(CloudStackEntity): @classmethod def create(cls, apiclient, StoragePoolFactory, **kwargs): cmd = createStoragePool.createStoragePoolCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in StoragePoolFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in StoragePoolFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] storagepool = apiclient.createStoragePool(cmd) return StoragePool(storagepool.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Tags.py b/tools/marvin/marvin/integration/lib/base/Tags.py index 240eab388d8..9e0093f7990 100644 --- a/tools/marvin/marvin/integration/lib/base/Tags.py +++ b/tools/marvin/marvin/integration/lib/base/Tags.py @@ -29,8 +29,8 @@ class Tags(CloudStackEntity): @classmethod def create(cls, apiclient, TagsFactory, **kwargs): cmd = createTags.createTagsCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in TagsFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in TagsFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] tags = apiclient.createTags(cmd) return Tags(tags.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Template.py b/tools/marvin/marvin/integration/lib/base/Template.py index f7d2f93dd9c..005125e88e1 100644 --- a/tools/marvin/marvin/integration/lib/base/Template.py +++ b/tools/marvin/marvin/integration/lib/base/Template.py @@ -42,8 +42,8 @@ class Template(CloudStackEntity): @classmethod def create(cls, apiclient, TemplateFactory, **kwargs): cmd = createTemplate.createTemplateCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in TemplateFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in TemplateFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] template = apiclient.createTemplate(cmd) return Template(template.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/User.py b/tools/marvin/marvin/integration/lib/base/User.py index 131a7b330bb..cd02f8ce23c 100644 --- a/tools/marvin/marvin/integration/lib/base/User.py +++ b/tools/marvin/marvin/integration/lib/base/User.py @@ -55,8 +55,8 @@ class User(CloudStackEntity): @classmethod def create(cls, apiclient, UserFactory, **kwargs): cmd = createUser.createUserCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in UserFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in UserFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] user = apiclient.createUser(cmd) return User(user.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VMSnapshot.py b/tools/marvin/marvin/integration/lib/base/VMSnapshot.py new file mode 100644 index 00000000000..66a17071669 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/base/VMSnapshot.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 createVMSnapshot +from marvin.cloudstackAPI import listVMSnapshot +from marvin.cloudstackAPI import deleteVMSnapshot + +class VMSnapshot(CloudStackEntity): + + + def __init__(self, items): + self.__dict__.update(items) + + + @classmethod + def create(cls, apiclient, VMSnapshotFactory, **kwargs): + cmd = createVMSnapshot.createVMSnapshotCmd() + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VMSnapshotFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] + vmsnapshot = apiclient.createVMSnapshot(cmd) + return VMSnapshot(vmsnapshot.__dict__) + + + @classmethod + def list(self, apiclient, **kwargs): + cmd = listVMSnapshot.listVMSnapshotCmd() + [setattr(cmd, key, value) for key,value in kwargs.items] + vmsnapshot = apiclient.listVMSnapshot(cmd) + return map(lambda e: VMSnapshot(e.__dict__), vmsnapshot) + + + def delete(self, apiclient, vmsnapshotid, **kwargs): + cmd = deleteVMSnapshot.deleteVMSnapshotCmd() + cmd.vmsnapshotid = vmsnapshotid + [setattr(cmd, key, value) for key,value in kwargs.items] + vmsnapshot = apiclient.deleteVMSnapshot(cmd) diff --git a/tools/marvin/marvin/integration/lib/base/VPC.py b/tools/marvin/marvin/integration/lib/base/VPC.py index b92676306a5..164f7dd4792 100644 --- a/tools/marvin/marvin/integration/lib/base/VPC.py +++ b/tools/marvin/marvin/integration/lib/base/VPC.py @@ -31,8 +31,8 @@ class VPC(CloudStackEntity): @classmethod def create(cls, apiclient, VPCFactory, **kwargs): cmd = createVPC.createVPCCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VPCFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VPCFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] vpc = apiclient.createVPC(cmd) return VPC(vpc.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VPCOffering.py b/tools/marvin/marvin/integration/lib/base/VPCOffering.py index 74addd649d1..3b34eb337f0 100644 --- a/tools/marvin/marvin/integration/lib/base/VPCOffering.py +++ b/tools/marvin/marvin/integration/lib/base/VPCOffering.py @@ -30,8 +30,8 @@ class VPCOffering(CloudStackEntity): @classmethod def create(cls, apiclient, VPCOfferingFactory, **kwargs): cmd = createVPCOffering.createVPCOfferingCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VPCOfferingFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VPCOfferingFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] vpcoffering = apiclient.createVPCOffering(cmd) return VPCOffering(vpcoffering.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VirtualMachine.py b/tools/marvin/marvin/integration/lib/base/VirtualMachine.py index 498208c9de0..f6d9368b84d 100644 --- a/tools/marvin/marvin/integration/lib/base/VirtualMachine.py +++ b/tools/marvin/marvin/integration/lib/base/VirtualMachine.py @@ -43,8 +43,8 @@ class VirtualMachine(CloudStackEntity): @classmethod def deploy(cls, apiclient, VirtualMachineFactory, **kwargs): cmd = deployVirtualMachine.deployVirtualMachineCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VirtualMachineFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VirtualMachineFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] virtualmachine = apiclient.deployVirtualMachine(cmd) return VirtualMachine(virtualmachine.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py b/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py index 10df736f7e0..74c2d0c6cb1 100644 --- a/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py +++ b/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py @@ -29,8 +29,8 @@ class VirtualRouterElement(CloudStackEntity): @classmethod def create(cls, apiclient, VirtualRouterElementFactory, **kwargs): cmd = createVirtualRouterElement.createVirtualRouterElementCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VirtualRouterElementFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VirtualRouterElementFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] virtualrouterelement = apiclient.createVirtualRouterElement(cmd) return VirtualRouterElement(virtualrouterelement.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VlanIpRange.py b/tools/marvin/marvin/integration/lib/base/VlanIpRange.py index 1f99d5a8c6d..55ca5d8c7a4 100644 --- a/tools/marvin/marvin/integration/lib/base/VlanIpRange.py +++ b/tools/marvin/marvin/integration/lib/base/VlanIpRange.py @@ -29,8 +29,8 @@ class VlanIpRange(CloudStackEntity): @classmethod def create(cls, apiclient, VlanIpRangeFactory, **kwargs): cmd = createVlanIpRange.createVlanIpRangeCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VlanIpRangeFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VlanIpRangeFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] vlaniprange = apiclient.createVlanIpRange(cmd) return VlanIpRange(vlaniprange.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Volume.py b/tools/marvin/marvin/integration/lib/base/Volume.py index 8ba630bacf1..160a09244c8 100644 --- a/tools/marvin/marvin/integration/lib/base/Volume.py +++ b/tools/marvin/marvin/integration/lib/base/Volume.py @@ -42,8 +42,8 @@ class Volume(CloudStackEntity): @classmethod def create(cls, apiclient, VolumeFactory, **kwargs): cmd = createVolume.createVolumeCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VolumeFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VolumeFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] volume = apiclient.createVolume(cmd) return Volume(volume.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VpnConnection.py b/tools/marvin/marvin/integration/lib/base/VpnConnection.py index a2c5f5b7dab..62062114dba 100644 --- a/tools/marvin/marvin/integration/lib/base/VpnConnection.py +++ b/tools/marvin/marvin/integration/lib/base/VpnConnection.py @@ -37,8 +37,8 @@ class VpnConnection(CloudStackEntity): @classmethod def create(cls, apiclient, VpnConnectionFactory, **kwargs): cmd = createVpnConnection.createVpnConnectionCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VpnConnectionFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VpnConnectionFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] vpnconnection = apiclient.createVpnConnection(cmd) return VpnConnection(vpnconnection.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py b/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py index eab0b6e7b0c..a718ddb1d79 100644 --- a/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py +++ b/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py @@ -30,8 +30,8 @@ class VpnCustomerGateway(CloudStackEntity): @classmethod def create(cls, apiclient, VpnCustomerGatewayFactory, **kwargs): cmd = createVpnCustomerGateway.createVpnCustomerGatewayCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VpnCustomerGatewayFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VpnCustomerGatewayFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] vpncustomergateway = apiclient.createVpnCustomerGateway(cmd) return VpnCustomerGateway(vpncustomergateway.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/VpnGateway.py b/tools/marvin/marvin/integration/lib/base/VpnGateway.py index 7f2766a89af..3d7f4f72978 100644 --- a/tools/marvin/marvin/integration/lib/base/VpnGateway.py +++ b/tools/marvin/marvin/integration/lib/base/VpnGateway.py @@ -29,8 +29,8 @@ class VpnGateway(CloudStackEntity): @classmethod def create(cls, apiclient, VpnGatewayFactory, **kwargs): cmd = createVpnGateway.createVpnGatewayCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VpnGatewayFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in VpnGatewayFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] vpngateway = apiclient.createVpnGateway(cmd) return VpnGateway(vpngateway.__dict__) diff --git a/tools/marvin/marvin/integration/lib/base/Zone.py b/tools/marvin/marvin/integration/lib/base/Zone.py index 7cf01ea408a..aca473dfa32 100644 --- a/tools/marvin/marvin/integration/lib/base/Zone.py +++ b/tools/marvin/marvin/integration/lib/base/Zone.py @@ -30,8 +30,8 @@ class Zone(CloudStackEntity): @classmethod def create(cls, apiclient, ZoneFactory, **kwargs): cmd = createZone.createZoneCmd() - [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ZoneFactory.attributes()] - [setattr(cmd, key, value) for key,value in kwargs.items] + [setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in ZoneFactory.__dict__.iteritems()] + [setattr(cmd, key, value) for key,value in kwargs.iteritems()] zone = apiclient.createZone(cmd) return Zone(zone.__dict__) diff --git a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py index 894f92ead71..dc543d4e97c 100644 --- a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py @@ -28,13 +28,14 @@ class AccountFactory(CloudStackBaseFactory): 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 + username = firstname + lastname # Password Encoding mdf = hashlib.md5() mdf.update('password') password = mdf.hexdigest() + class AdminAccountFactory(AccountFactory): accounttype = 1 diff --git a/tools/marvin/marvin/integration/lib/factory/StoragePoolFactory.py b/tools/marvin/marvin/integration/lib/factory/StoragePoolFactory.py index 3803bfcbac6..775375d29f5 100644 --- a/tools/marvin/marvin/integration/lib/factory/StoragePoolFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/StoragePoolFactory.py @@ -25,3 +25,6 @@ class StoragePoolFactory(factory.Factory): podid = None url = None zoneid = None + name = None + url = None + zoneid = None diff --git a/tools/marvin/marvin/integration/lib/factory/VMSnapshotFactory.py b/tools/marvin/marvin/integration/lib/factory/VMSnapshotFactory.py new file mode 100644 index 00000000000..bbd0bd7a743 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/factory/VMSnapshotFactory.py @@ -0,0 +1,23 @@ +# 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 VMSnapshot +class VMSnapshotFactory(factory.Factory): + + FACTORY_FOR = VMSnapshot.VMSnapshot + + virtualmachineid = None diff --git a/tools/marvin/marvin/integration/lib/factory/test/__init__.py b/tools/marvin/marvin/integration/lib/factory/test/__init__.py new file mode 100644 index 00000000000..d216be4ddc9 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/factory/test/__init__.py @@ -0,0 +1,16 @@ +# 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. \ No newline at end of file diff --git a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py new file mode 100644 index 00000000000..eec44de4a21 --- /dev/null +++ b/tools/marvin/marvin/integration/lib/factory/test/testFactories.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. + +import unittest +from marvin.integration.lib.factory import AccountFactory +from marvin.integration.lib.base import Account +from marvin.cloudstackTestClient import cloudstackTestClient + +class AccountFactoryTest(unittest.TestCase): + def setUp(self): + self.apiClient = cloudstackTestClient(mgtSvr='localhost') + + def test_userAccountFactory(self): + af = AccountFactory.AdminAccountFactory() + accnt = Account.Account.create(apiclient=self.apiClient, AccountFactory=af) + self.assertTrue(accnt is not None, msg="no account created by factory") + + def tearDown(self): + self.apiClient.close() \ No newline at end of file diff --git a/tools/marvin/marvin/integration/lib/generateBase.py b/tools/marvin/marvin/integration/lib/generateBase.py index 5f5e3dff721..f94043eab69 100644 --- a/tools/marvin/marvin/integration/lib/generateBase.py +++ b/tools/marvin/marvin/integration/lib/generateBase.py @@ -126,8 +126,8 @@ def write_entity_classes(entities): if action in ['create', 'deploy']: body.append(tabspace + 'def %s(cls, apiclient, %sFactory, **kwargs):'%(action, entity)) body.append(tabspace*2 + 'cmd = %(module)s.%(command)s()'%{"module": details["apimodule"], "command": details["apicmd"]}) - body.append(tabspace*2 + '[setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in %sFactory.attributes()]'%entity) - body.append(tabspace*2 + '[setattr(cmd, key, value) for key,value in kwargs.items]') + body.append(tabspace*2 + '[setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in %sFactory.__dict__.iteritems()]'%entity) + body.append(tabspace*2 + '[setattr(cmd, key, value) for key,value in kwargs.iteritems()]') body.append(tabspace*2 + '%s = apiclient.%s(cmd)'%(entity.lower(), details['apimodule'])) body.append(tabspace*2 + 'return %s(%s.__dict__)'%(entity, entity.lower())) else: @@ -185,7 +185,7 @@ def write_entity_factory(entity, actions): code += 'from marvin.integration.lib.base import %s\n'%entity code += 'class %sFactory(factory.Factory):'%entity code += '\n\n' - code += tabspace + 'FACTORY_FOR = %s\n\n'%entity + code += tabspace + 'FACTORY_FOR = %s.%s\n\n'%(entity,entity) for arg in factory_defaults: code += tabspace + '%s = None\n'%arg with open("./factory/%sFactory.py"%entity, "w") as writer: