mirror of https://github.com/apache/cloudstack.git
marvin_factories: inherit from ABSTRACT_FACTORY
This is done to remove dependency on an ORM. + Additional APIs from multiple ip per nic. Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
fa00dc9f9b
commit
ae49eb9d27
|
|
@ -23,7 +23,7 @@ from marvin.cloudstackAPI import updateAccount
|
|||
from marvin.cloudstackAPI import disableAccount
|
||||
from marvin.cloudstackAPI import deleteAccount
|
||||
|
||||
class Account(CloudStackEntity):
|
||||
class Account(CloudStackEntity.CloudStackEntity):
|
||||
|
||||
|
||||
def __init__(self, items):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from marvin.integration.lib.base import CloudStackEntity
|
||||
from marvin.cloudstackAPI import updateDefaultNicForVirtualMachine
|
||||
|
||||
class DefaultNicForVirtualMachine(CloudStackEntity):
|
||||
|
||||
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
|
||||
def update(self, apiclient, nicid, virtualmachineid, **kwargs):
|
||||
cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd()
|
||||
cmd.nicid = nicid
|
||||
cmd.virtualmachineid = virtualmachineid
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
defaultnicforvirtualmachine = apiclient.updateDefaultNicForVirtualMachine(cmd)
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from marvin.integration.lib.base import CloudStackEntity
|
||||
from marvin.cloudstackAPI import createEgressFirewallRule
|
||||
from marvin.cloudstackAPI import listEgressFirewallRules
|
||||
from marvin.cloudstackAPI import deleteEgressFirewallRule
|
||||
|
||||
class EgressFirewallRule(CloudStackEntity):
|
||||
|
||||
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
|
||||
@classmethod
|
||||
def create(cls, apiclient, EgressFirewallRuleFactory, **kwargs):
|
||||
cmd = createEgressFirewallRule.createEgressFirewallRuleCmd()
|
||||
[setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in EgressFirewallRuleFactory.attributes()]
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
egressfirewallrule = apiclient.createEgressFirewallRule(cmd)
|
||||
return EgressFirewallRule(egressfirewallrule.__dict__)
|
||||
|
||||
|
||||
@classmethod
|
||||
def list(self, apiclient, **kwargs):
|
||||
cmd = listEgressFirewallRules.listEgressFirewallRulesCmd()
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
egressfirewallrule = apiclient.listEgressFirewallRules(cmd)
|
||||
return map(lambda e: EgressFirewallRule(e.__dict__), egressfirewallrule)
|
||||
|
||||
|
||||
def delete(self, apiclient, id, **kwargs):
|
||||
cmd = deleteEgressFirewallRule.deleteEgressFirewallRuleCmd()
|
||||
cmd.id = id
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
egressfirewallrule = apiclient.deleteEgressFirewallRule(cmd)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from marvin.integration.lib.base import CloudStackEntity
|
||||
from marvin.cloudstackAPI import removeNicFromVirtualMachine
|
||||
|
||||
class NicFromVirtualMachine(CloudStackEntity):
|
||||
|
||||
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
|
||||
def remove(self, apiclient, nicid, virtualmachineid, **kwargs):
|
||||
cmd = removeNicFromVirtualMachine.removeNicFromVirtualMachineCmd()
|
||||
cmd.nicid = nicid
|
||||
cmd.virtualmachineid = virtualmachineid
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
nicfromvirtualmachine = apiclient.removeNicFromVirtualMachine(cmd)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from marvin.integration.lib.base import CloudStackEntity
|
||||
from marvin.cloudstackAPI import addNicToVirtualMachine
|
||||
|
||||
class NicToVirtualMachine(CloudStackEntity):
|
||||
|
||||
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
|
||||
def add(self, apiclient, networkid, virtualmachineid, **kwargs):
|
||||
cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd()
|
||||
cmd.networkid = networkid
|
||||
cmd.virtualmachineid = virtualmachineid
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
nictovirtualmachine = apiclient.addNicToVirtualMachine(cmd)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from marvin.integration.lib.base import CloudStackEntity
|
||||
from marvin.cloudstackAPI import resetSSHKeyForVirtualMachine
|
||||
|
||||
class SSHKeyForVirtualMachine(CloudStackEntity):
|
||||
|
||||
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
|
||||
def reset(self, apiclient, keypair, id, **kwargs):
|
||||
cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd()
|
||||
cmd.id = id
|
||||
cmd.keypair = keypair
|
||||
[setattr(cmd, key, value) for key,value in kwargs.items]
|
||||
sshkeyforvirtualmachine = apiclient.resetSSHKeyForVirtualMachine(cmd)
|
||||
|
|
@ -14,17 +14,18 @@
|
|||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import factory
|
||||
|
||||
from marvin.integration.lib.base import Account
|
||||
import hashlib
|
||||
from marvin.integration.lib.factory.CloudStackBaseFactory import *
|
||||
from marvin.integration.lib.utils import random_gen
|
||||
|
||||
class AccountFactory(factory.Factory):
|
||||
class AccountFactory(CloudStackBaseFactory):
|
||||
|
||||
FACTORY_FOR = Account
|
||||
FACTORY_FOR = Account.Account
|
||||
|
||||
accounttype = 0
|
||||
email = factory.LazyAttribute(lambda e: '{0}.{1}@cloudstack.org'.format(e.firstname, e.lastname)).lower()
|
||||
email = factory.LazyAttribute(lambda e: '{0}.{1}@cloudstack.org'.format(e.firstname, e.lastname).lower())
|
||||
firstname = 'fname-'+random_gen()
|
||||
lastname = 'lname-'+random_gen()
|
||||
username = None
|
||||
|
|
@ -40,9 +41,4 @@ class AdminAccountFactory(AccountFactory):
|
|||
|
||||
class DomainAdminFactory(AccountFactory):
|
||||
accounttype = 2
|
||||
domainid = None accounttype = None
|
||||
email = None
|
||||
firstname = None
|
||||
lastname = None
|
||||
password = None
|
||||
username = None
|
||||
domainid = None
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import factory
|
||||
|
||||
class CloudStackBaseFactory(factory.Factory):
|
||||
ABSTRACT_FACTORY = True
|
||||
|
||||
@classmethod
|
||||
def _create(cls, target_class, *args, **kwargs):
|
||||
return target_class(*args, **kwargs)
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import factory
|
||||
from marvin.integration.lib.base import EgressFirewallRule
|
||||
class EgressFirewallRuleFactory(factory.Factory):
|
||||
|
||||
FACTORY_FOR = EgressFirewallRule
|
||||
|
||||
networkid = None
|
||||
protocol = None
|
||||
Loading…
Reference in New Issue