cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [36/50] [abbrv] git commit: updated refs/heads/marvin-refactor to bbaf354
Date Wed, 02 Oct 2013 16:42:06 GMT
marvin_refactor: additional factories for entities

staticnat, vpc, vpcoffering, networkoffering, etc

All classes within factories don't include the redundant *Factory in
their naming.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7d4b35df
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7d4b35df
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7d4b35df

Branch: refs/heads/marvin-refactor
Commit: 7d4b35df83872d71266feb9ba22af48d6ed75e54
Parents: dab5ae5
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Mon Sep 30 09:51:19 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Wed Oct 2 20:27:58 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/factory/data/account.py     |  6 +-
 tools/marvin/marvin/factory/data/cluster.py     |  4 +-
 .../marvin/marvin/factory/data/diskoffering.py  |  4 +-
 .../marvin/marvin/factory/data/firewallrule.py  |  4 +-
 tools/marvin/marvin/factory/data/host.py        |  4 +-
 tools/marvin/marvin/factory/data/network.py     | 32 ++++++--
 .../marvin/factory/data/networkoffering.py      | 37 +++++++++-
 .../marvin/marvin/factory/data/securitygroup.py | 72 ++++++++++++++++++
 .../marvin/factory/data/serviceoffering.py      |  2 +-
 tools/marvin/marvin/factory/data/staticnat.py   | 16 ++++
 tools/marvin/marvin/factory/data/template.py    |  2 +-
 tools/marvin/marvin/factory/data/user.py        | 10 +--
 tools/marvin/marvin/factory/data/vm.py          | 77 +++++++++++++++++---
 tools/marvin/marvin/factory/data/vpc.py         | 35 +++++++++
 tools/marvin/marvin/factory/data/vpcoffering.py | 43 +++++++++++
 tools/marvin/marvin/factory/data/zone.py        |  4 +-
 16 files changed, 312 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/account.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/account.py b/tools/marvin/marvin/factory/data/account.py
index 97caf16..be641d6 100644
--- a/tools/marvin/marvin/factory/data/account.py
+++ b/tools/marvin/marvin/factory/data/account.py
@@ -19,7 +19,7 @@ import factory
 from marvin.factory.account import AccountFactory
 from marvin.legacy.utils import random_gen
 
-class UserAccountFactory(AccountFactory):
+class UserAccount(AccountFactory):
 
     accounttype = 0
     firstname = factory.Sequence(lambda n: random_gen())
@@ -29,10 +29,10 @@ class UserAccountFactory(AccountFactory):
     password = 'password'
 
 
-class AdminAccountFactory(UserAccountFactory):
+class AdminAccount(UserAccount):
     accounttype = 1
 
 
-class DomainAdminFactory(UserAccountFactory):
+class DomainAdmin(UserAccount):
     accounttype = 2
     domainid = None

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/cluster.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/cluster.py b/tools/marvin/marvin/factory/data/cluster.py
index c51321d..5e8c8eb 100644
--- a/tools/marvin/marvin/factory/data/cluster.py
+++ b/tools/marvin/marvin/factory/data/cluster.py
@@ -19,12 +19,12 @@ import factory
 from marvin.legacy.utils import random_gen
 from marvin.factory.cluster import ClusterFactory
 
-class XenClusterFactory(ClusterFactory):
+class XenCluster(ClusterFactory):
     clustername = factory.Sequence(lambda n: "xencluster" + random_gen())
     clustertype = "XenServer"
     hypervisor = "XenServer"
 
-class KvmClusterFactory(ClusterFactory):
+class KvmCluster(ClusterFactory):
     clustername = factory.Sequence(lambda n: "kvmcluster" + random_gen())
     clustertype = "KVM"
     hypervisor = "KVM"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/diskoffering.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/diskoffering.py b/tools/marvin/marvin/factory/data/diskoffering.py
index 48526b8..89a48b4 100644
--- a/tools/marvin/marvin/factory/data/diskoffering.py
+++ b/tools/marvin/marvin/factory/data/diskoffering.py
@@ -19,14 +19,14 @@ import factory
 from marvin.factory.diskoffering import DiskOfferingFactory
 from marvin.legacy.utils import random_gen
 
-class SharedDiskOfferingFactory(DiskOfferingFactory):
+class SharedDiskOffering(DiskOfferingFactory):
 
     displaytext = "SharedDiskOffering"
     name = factory.Sequence(lambda n : "SharedDiskOffering" + random_gen())
     storagetype = "shared"
     disksize = 10 #MB
 
-class LocalDiskOfferingFactory(DiskOfferingFactory):
+class LocalDiskOffering(DiskOfferingFactory):
 
     displaytext = "LocalDiskOffering"
     name = factory.Sequence(lambda n : "LocalDiskOffering" + random_gen())

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/firewallrule.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/firewallrule.py b/tools/marvin/marvin/factory/data/firewallrule.py
index 692450b..44cc17f 100644
--- a/tools/marvin/marvin/factory/data/firewallrule.py
+++ b/tools/marvin/marvin/factory/data/firewallrule.py
@@ -17,13 +17,13 @@
 
 from marvin.factory.firewall import FirewallFactory
 
-class SshFirewallRuleFactory(FirewallFactory):
+class SshFirewallRule(FirewallFactory):
     protocol = 'tcp'
     startport = 22
     endport = 22
     cidrlist = '0.0.0.0/0'
 
-class HttpFirewallRuleFactory(FirewallFactory):
+class HttpFirewallRule(FirewallFactory):
     protocol = 'tcp'
     startport = 80
     endport = 80

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/host.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/host.py b/tools/marvin/marvin/factory/data/host.py
index 726ceb7..02d2433 100644
--- a/tools/marvin/marvin/factory/data/host.py
+++ b/tools/marvin/marvin/factory/data/host.py
@@ -17,14 +17,14 @@
 
 from marvin.factory.host import HostFactory
 
-class XenserverHostFactory(HostFactory):
+class XenserverHost(HostFactory):
 
     hypervisor = 'XenServer'
     password = 'password'
     username = 'root'
 
 
-class KvmHostFactory(HostFactory):
+class KvmHost(HostFactory):
 
     hypervisor = 'KVM'
     password = 'password'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/network.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/network.py b/tools/marvin/marvin/factory/data/network.py
index ad6101c..50c0086 100644
--- a/tools/marvin/marvin/factory/data/network.py
+++ b/tools/marvin/marvin/factory/data/network.py
@@ -18,31 +18,47 @@
 import factory
 from marvin.legacy.utils import random_gen
 from marvin.factory.network import NetworkFactory
-from marvin.factory.data.networkoffering import DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory
-from marvin.factory.data.networkoffering import DefaultSharedNetworkOfferingFactory
+from marvin.factory.data.networkoffering import DefaultIsolatedNetworkOfferingWithSourceNatService
+from marvin.factory.data.networkoffering import DefaultSharedNetworkOffering
+from marvin.factory.data.networkoffering import DefaultIsolatedNetworkOfferingForVpc
 
-class GuestIsolatedNetworkFactory(NetworkFactory):
+class GuestIsolatedNetwork(NetworkFactory):
 
     displaytext = factory.Sequence(lambda n: 'GuestIsolatedNetwork-%s' % random_gen())
     name = factory.Sequence(lambda n: 'GuestIsolatedNetwork-%s' % random_gen())
     networkoffering =\
     factory.SubFactory(
-        DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory,
+        DefaultIsolatedNetworkOfferingWithSourceNatService,
         apiclient=factory.SelfAttribute('..apiclient'),
         name=factory.Sequence(lambda n: 'GuestIsolatedNetworkOffering-%s' % random_gen()),
     )
     networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if no.networkoffering
else no.networkoffering)
     zoneid = None
 
-class SharedNetworkFactory(NetworkFactory):
+class SharedNetwork(NetworkFactory):
 
     displaytext = factory.Sequence(lambda n: 'SharedNetwork-%s' % random_gen())
-    name = factory.Sequence(lambda n: 'SharedNetwork-%d' % random_gen())
+    name = factory.Sequence(lambda n: 'SharedNetwork-%s' % random_gen())
     networkoffering = \
         factory.SubFactory(
-            DefaultSharedNetworkOfferingFactory,
+            DefaultSharedNetworkOffering,
             apiclient=factory.SelfAttribute('..apiclient'),
             name=factory.Sequence(lambda n: 'SharedNetworkOffering-%s' % random_gen())
         )
-    networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if not no.networkoffering
else no.networkoffering)
+    networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if no.networkoffering
else no.networkoffering)
+    zoneid = None
+
+class DefaultVpcNetwork(NetworkFactory):
+
+    displaytext = factory.Sequence(lambda n: 'DefaultVpcNetwork-%s' % random_gen())
+    name = factory.Sequence(lambda n: 'DefaultVpcNetwork-%s' % random_gen())
+    networkoffering = \
+        factory.SubFactory(
+            DefaultIsolatedNetworkOfferingForVpc,
+            apiclient=factory.SelfAttribute('..apiclient'),
+            name=factory.Sequence(lambda n: 'DefaultVpcNetwork-%s' % random_gen())
+        )
+    gateway = '10.0.0.1'
+    netmask = '255.255.255.192'
+    networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if no.networkoffering
else no.networkoffering)
     zoneid = None
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/networkoffering.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/networkoffering.py b/tools/marvin/marvin/factory/data/networkoffering.py
index 5b64cf6..1a65f85 100644
--- a/tools/marvin/marvin/factory/data/networkoffering.py
+++ b/tools/marvin/marvin/factory/data/networkoffering.py
@@ -20,7 +20,7 @@ from marvin.factory.networkoffering import NetworkOfferingFactory
 from marvin.legacy.utils import random_gen
 
 
-class DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory(NetworkOfferingFactory):
+class DefaultIsolatedNetworkOfferingWithSourceNatService(NetworkOfferingFactory):
     #FIXME: Service Capability Lists with CapabilityTypes (ElasticIP, RvR etc) needs handling
 
     displaytext = factory.Sequence(lambda n : "DefaultIsolatedNetworkOfferingWithSourceNatService"
+ random_gen())
@@ -51,7 +51,7 @@ class DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory(NetworkOfferingF
         self.update(apiclient=self.apiclient, id=self.id, state='Enabled')
 
 
-class DefaultSharedNetworkOfferingWithSGServiceFactory(NetworkOfferingFactory):
+class DefaultSharedNetworkOfferingWithSGService(NetworkOfferingFactory):
 
     displaytext = factory.Sequence(lambda n : "DefaultSharedNetworkOfferingWithSGService"
+ random_gen())
     name = factory.Sequence(lambda n : "DefaultSharedNetworkOfferingWithSGService" + random_gen())
@@ -86,7 +86,7 @@ class DefaultSharedNetworkOfferingWithSGServiceFactory(NetworkOfferingFactory):
         self.update(apiclient=self.apiclient, id=self.id, state='Enabled')
 
 
-class DefaultSharedNetworkOfferingFactory(NetworkOfferingFactory):
+class DefaultSharedNetworkOffering(NetworkOfferingFactory):
 
     displaytext = factory.Sequence(lambda n : "DefaultSharedNetworkOfferingFactory-%s" %
random_gen())
     name = factory.Sequence(lambda n : "DefaultSharedNetworkOfferingFactory-%s" % random_gen())
@@ -115,3 +115,34 @@ class DefaultSharedNetworkOfferingFactory(NetworkOfferingFactory):
         if not create:
             return
         self.update(apiclient=self.apiclient, id=self.id, state='Enabled')
+
+
+class DefaultIsolatedNetworkOfferingForVpc(NetworkOfferingFactory):
+
+    displaytext = factory.Sequence(lambda n : "DefaultIsolatedNetworkOfferingForVpc-%s" %
random_gen())
+    name = factory.Sequence(lambda n : "DefaultIsolatedNetworkOfferingForVpc-%s" % random_gen())
+    availability = "Optional"
+    supportedservices = "SourceNat,Dns,Lb,PortForwarding,StaticNat,NetworkACL,Dhcp,Vpn,UserData"
+    guestiptype = "Isolated"
+    traffictype = "GUEST"
+
+    specifyVlan = False
+    specifyIpRanges = False
+    isPersistent = False
+    conserveMode = False
+
+    serviceProviderList = []
+    for service in map(lambda l: l.strip(' '), supportedservices.split(',')):
+        serviceProviderList.append(
+            {
+                'service': service,
+                'provider': 'VpcVirtualRouter'
+            }
+        )
+
+    # enable the offering post generation
+    @factory.post_generation
+    def enable(self, create, extracted, **kwargs):
+        if not create:
+            return
+        self.update(apiclient=self.apiclient, id=self.id, state='Enabled')

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/securitygroup.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/securitygroup.py b/tools/marvin/marvin/factory/data/securitygroup.py
new file mode 100644
index 0000000..1e6d375
--- /dev/null
+++ b/tools/marvin/marvin/factory/data/securitygroup.py
@@ -0,0 +1,72 @@
+# 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.legacy.utils import random_gen
+from marvin.entity.securitygroup import SecurityGroup
+from marvin.factory.securitygroup import SecurityGroupFactory
+
+class SecurityGroupSshIngress(SecurityGroupFactory):
+    """
+    Allow port 22 (ingress) into the guest
+    """
+    name = factory.Sequence(lambda n: 'SshSecurityGroupIngress-' + random_gen())
+    protocol = 'tcp'
+    cidrlist = '0.0.0.0/0'
+    startport = 22
+    endport = 22
+
+    @factory.post_generation
+    def authorizeIngress(self, create, extracted, **kwargs):
+        if not create:
+            return
+        sg = SecurityGroup.list(name=self.name)
+        if not sg:
+            self.authorizeSecurityGroupIngress(
+                self.apiclient,
+                name=self.name,
+                protocol=self.protocol,
+                cidrlist=self.cidrlist,
+                startport=self.startport,
+                endport=self.endport
+            )
+
+
+class SecurityGroupSshEgress(SecurityGroupFactory):
+    """
+    Allow port 22 (egress) out of the guest
+    """
+    name = factory.Sequence(lambda n: 'SshSecurityGroupEgress-' + random_gen())
+    protocol = 'tcp'
+    cidrlist = '0.0.0.0/0'
+    startport = 22
+    endport = 22
+
+    @factory.post_generation
+    def authorizeEgress(self, create, extracted, **kwargs):
+        if not create:
+            return
+        sg = SecurityGroup.list(name=self.name)
+        if not sg:
+            self.authorizeSecurityGroupEgress(
+                self.apiclient,
+                name=self.name,
+                protocol=self.protocol,
+                cidrlist=self.cidrlist,
+                startport=self.startport,
+                endport=self.endport
+            )

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/serviceoffering.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/serviceoffering.py b/tools/marvin/marvin/factory/data/serviceoffering.py
index 955657e..cc62358 100644
--- a/tools/marvin/marvin/factory/data/serviceoffering.py
+++ b/tools/marvin/marvin/factory/data/serviceoffering.py
@@ -19,7 +19,7 @@ import factory
 from marvin.factory.serviceoffering import ServiceOfferingFactory
 from marvin.legacy.utils import random_gen
 
-class SmallServiceOfferingFactory(ServiceOfferingFactory):
+class SmallServiceOffering(ServiceOfferingFactory):
     cpunumber = 1
     cpuspeed = 100 #Mhz
     memory = 100 #MB

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/staticnat.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/staticnat.py b/tools/marvin/marvin/factory/data/staticnat.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/tools/marvin/marvin/factory/data/staticnat.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.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/template.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/template.py b/tools/marvin/marvin/factory/data/template.py
index 4c576fb..445899e 100644
--- a/tools/marvin/marvin/factory/data/template.py
+++ b/tools/marvin/marvin/factory/data/template.py
@@ -17,7 +17,7 @@
 
 from marvin.factory.template import TemplateFactory
 
-class DefaultBuiltInTemplateFactory(TemplateFactory):
+class DefaultBuiltInTemplate(TemplateFactory):
     ostype = 'CentOS 5.3 (64-bit)'
     displaytext = 'CentOS 5.3 (64-bit)'
     name = 'CentOS 5.3 (64-bit)'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/user.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/user.py b/tools/marvin/marvin/factory/data/user.py
index d5fa456..588c294 100644
--- a/tools/marvin/marvin/factory/data/user.py
+++ b/tools/marvin/marvin/factory/data/user.py
@@ -17,17 +17,17 @@
 
 import factory
 from marvin.factory.user import UserFactory
-from marvin.factory.data.account import UserAccountFactory
+from marvin.factory.data.account import UserAccount
 from marvin.legacy.utils import random_gen
 
-class UserFactory(UserFactory):
+class User(UserFactory):
 
     firstname = factory.Sequence(lambda n: random_gen())
     lastname = factory.Sequence(lambda n: random_gen())
     email = factory.LazyAttribute(lambda e: '{0}.{1}@cloudstack.org'.format(e.firstname,
e.lastname).lower())
     username = factory.Sequence(lambda n: random_gen())
     password = 'password'
-    account = factory.SubFactory(UserAccountFactory,
+    account = factory.SubFactory(UserAccount,
         apiclient=factory.SelfAttribute('..apiclient'),
         accounttype=0,
         firstname=factory.SelfAttribute('..firstname'),
@@ -37,9 +37,9 @@ class UserFactory(UserFactory):
         username=factory.SelfAttribute('..username'),
     )
 
-class AdminUserFactory(UserFactory):
+class AdminUser(UserFactory):
 
-    account = factory.SubFactory(UserAccountFactory,
+    account = factory.SubFactory(UserAccount,
         apiclient=factory.SelfAttribute('..apiclient'),
         accounttype=1,
         firstname=factory.SelfAttribute('..firstname'),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/vm.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/vm.py b/tools/marvin/marvin/factory/data/vm.py
index a09abe7..b9e6345 100644
--- a/tools/marvin/marvin/factory/data/vm.py
+++ b/tools/marvin/marvin/factory/data/vm.py
@@ -15,18 +15,77 @@
 # specific language governing permissions and limitations
 # under the License.
 
+import factory
 from marvin.factory.virtualmachine import VirtualMachineFactory
+from marvin.entity.ipaddress import IpAddress
+from marvin.entity.network import Network
+from marvin.factory.data.firewallrule import SshFirewallRule
+from marvin.factory.data.vpc import DefaultVpc
+from marvin.factory.data.network import DefaultVpcNetwork
 
-class VirtualMachineIsolatedNetwork(VirtualMachineFactory):
+class VirtualMachineWithStaticNat(VirtualMachineFactory):
+    """VirtualMachine in an isolated network of an advanced zone
+
+    Open a static-nat rule to connect to the guest over port 22
+    """
+
+    @factory.post_generation
+    def staticNat(self, create, extracted, **kwargs):
+        if not create:
+            return
+        ipassoc = IpAddress(
+            apiclient=self.apiclient,
+            account=self.account,
+            domainid=self.domainid,
+            zoneid=self.zoneid,
+        )
+        ssh_fwrule = SshFirewallRule(
+            apiclient=self.apiclient,
+            ipaddressid=ipassoc.id
+        )
+        ntwks = Network.list(
+            apiclient=self.apiclient,
+            account=self.account,
+            domainid=self.domainid,
+        )
+        ntwks[0].enableStaticNat(
+            apiclient=self.apiclient,
+            ipaddressid=ipassoc.id,
+            virtualmachineid=self.id,
+        )
+        self.ssh_ip = ipassoc.ipaddress
+        self.public_ip = ipassoc.ipaddress
+
+
+class VirtualMachineWithIngress(VirtualMachineFactory):
+    """VirtualMachine created in a basic zone with security groups
+
+    Allow port 22 (ingress) into the guest
     """
-    Creates a virtualmachine in an isolated network typically in an advanced zone inside
a user account
+    @factory.post_generation
+    def allowIngress(self, create, extracted, **kwargs):
+        if not create:
+            return
 
-    Uses a serviceoffering of tinyInstance of the shared storage type
-    Uses a builtin template available
-    Deploys in the first zone available
+
+class VpcVirtualMachine(VirtualMachineFactory):
+    """
+    VirtualMachine within a VPC created by DefaultVPC offering
     """
 
-    apiclient = None
-    serviceofferingid = None
-    templateid = None
-    zoneid = None
+    vpc = factory.SubFactory(
+        DefaultVpc,
+        apiclient=factory.SelfAttribute('..apiclient'),
+        account=factory.SelfAttribute('..account'),
+        domainid=factory.SelfAttribute('..domainid'),
+        zoneid=factory.SelfAttribute('..zoneid')
+    )
+    ntwk = factory.SubFactory(
+        DefaultVpcNetwork,
+        apiclient=factory.SelfAttribute('..apiclient'),
+        account=factory.SelfAttribute('..account'),
+        domainid=factory.SelfAttribute('..domainid'),
+        zoneid=factory.SelfAttribute('..zoneid'),
+        vpcid=factory.SelfAttribute('..vpc.id')
+    )
+    networkid=factory.LazyAttribute(lambda n: n.ntwk.id if n else None)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/vpc.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/vpc.py b/tools/marvin/marvin/factory/data/vpc.py
new file mode 100644
index 0000000..fc0379c
--- /dev/null
+++ b/tools/marvin/marvin/factory/data/vpc.py
@@ -0,0 +1,35 @@
+# 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.factory.vpc import VpcFactory
+from marvin.factory.data.vpcoffering import DefaultVpcOffering
+from marvin.legacy.utils import random_gen
+
+class DefaultVpc(VpcFactory):
+
+    name = factory.Sequence(lambda e: "DefaultVpc" + random_gen())
+    cidr = '10.0.0.1/24'
+    displaytext = name
+    zoneid = None
+    apiclient = None
+    vpcoffering = \
+        factory.SubFactory(
+            DefaultVpcOffering,
+            apiclient=factory.SelfAttribute('..apiclient')
+        )
+    vpcofferingid = factory.LazyAttribute(lambda vo: vo.vpcoffering.id if vo.vpcoffering
else vo.vpcoffering)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/vpcoffering.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/vpcoffering.py b/tools/marvin/marvin/factory/data/vpcoffering.py
new file mode 100644
index 0000000..c0040c6
--- /dev/null
+++ b/tools/marvin/marvin/factory/data/vpcoffering.py
@@ -0,0 +1,43 @@
+# 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.factory.vpcoffering import VpcOfferingFactory
+from marvin.legacy.utils import random_gen
+
+class DefaultVpcOffering(VpcOfferingFactory):
+
+    apiclient = None
+    displaytext = factory.Sequence(lambda n: 'Default VPC offering' + random_gen())
+    name = factory.Sequence(lambda n: 'Default VPC offering' + random_gen())
+    supportedservices = 'SourceNat,Dns,Lb,PortForwarding,StaticNat,NetworkACL,Dhcp,Vpn,UserData'
+
+    serviceProviderList = []
+    for service in map(lambda l: l.strip(' '), supportedservices.split(',')):
+        serviceProviderList.append(
+            {
+                'service': service,
+                'provider': 'VpcVirtualRouter'
+            }
+        )
+
+    # enable the offering post generation
+    @factory.post_generation
+    def enable(self, create, extracted, **kwargs):
+        if not create:
+            return
+        self.update(id=self.id, state='Enabled')

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4b35df/tools/marvin/marvin/factory/data/zone.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/zone.py b/tools/marvin/marvin/factory/data/zone.py
index 67c1cb4..80cb67a 100644
--- a/tools/marvin/marvin/factory/data/zone.py
+++ b/tools/marvin/marvin/factory/data/zone.py
@@ -19,14 +19,14 @@ import factory
 from marvin.factory.zone import ZoneFactory
 from marvin.legacy.utils import random_gen
 
-class AdvancedZoneFactory(ZoneFactory):
+class AdvancedZone(ZoneFactory):
     name = factory.Sequence(lambda n: "advzone" + random_gen())
     networktype = "Advanced"
     dns1 = "8.8.8.8"
     internaldns1 = "8.8.8.8"
 
 
-class BasicZoneFactory(ZoneFactory):
+class BasicZone(ZoneFactory):
     name = factory.Sequence(lambda n: "basiczone" + random_gen())
     networktype = "Basic"
     dns1 = "8.8.8.8"


Mime
View raw message