marvin_refactor: VNS device APIs, VMSnapshot APIs, changes to factory creation

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-03-18 17:56:09 +05:30
parent 676997c8a3
commit f0b9b274ee
57 changed files with 453 additions and 93 deletions

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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

View File

@ -25,3 +25,6 @@ class StoragePoolFactory(factory.Factory):
podid = None
url = None
zoneid = None
name = None
url = None
zoneid = None

View File

@ -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

View File

@ -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.

View File

@ -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()

View File

@ -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: