2020"""
2121
2222import marvin
23+ from utils import is_server_ssh_ready , random_gen
2324from marvin .cloudstackAPI import *
2425from marvin .codes import (FAILED , FAIL , PASS , RUNNING , STOPPED ,
2526 STARTING , DESTROYED , EXPUNGING ,
@@ -607,6 +608,12 @@ def delete(self, apiclient):
607608 cmd .id = self .id
608609 apiclient .destroyVirtualMachine (cmd )
609610
611+ def expung (self , apiclient ):
612+ """Expung an Instance"""
613+ cmd = expungeVirtualMachine .expungeVirtualMachineCmd ()
614+ cmd .id = self .id
615+ apiclient .expungeVirtualMachine (cmd )
616+
610617 def migrate (self , apiclient , hostid = None ):
611618 """migrate an Instance"""
612619 cmd = migrateVirtualMachine .migrateVirtualMachineCmd ()
@@ -1483,6 +1490,18 @@ def create(cls, apiclient, services, ipaddressid=None,
14831490 cmd .vpcid = vpcid
14841491 return StaticNATRule (apiclient .createFirewallRule (cmd ).__dict__ )
14851492
1493+ @classmethod
1494+ def createIpForwardingRule (cls , apiclient , startport , endport , protocol , ipaddressid , openfirewall ):
1495+ """Creates static ip forwarding rule"""
1496+
1497+ cmd = createIpForwardingRule .createIpForwardingRuleCmd ()
1498+ cmd .startport = startport
1499+ cmd .endport = endport
1500+ cmd .protocol = protocol
1501+ cmd .openfirewall = openfirewall
1502+ cmd .ipaddressid = ipaddressid
1503+ return StaticNATRule (apiclient .createIpForwardingRule (cmd ).__dict__ )
1504+
14861505 def delete (self , apiclient ):
14871506 """Delete IP forwarding rule"""
14881507 cmd = deleteIpForwardingRule .deleteIpForwardingRuleCmd ()
@@ -1614,6 +1633,162 @@ def list(cls, apiclient, **kwargs):
16141633 cmd .listall = True
16151634 return (apiclient .listFirewallRules (cmd ))
16161635
1636+ class Autoscale :
1637+
1638+ """Manage Auto scale"""
1639+
1640+ def __init__ (self , items ):
1641+ self .__dict__ .update (items )
1642+
1643+ @classmethod
1644+ def listCounters (cls , apiclient , ** kwargs ):
1645+ """Lists all available Counters."""
1646+
1647+ cmd = listCounters .listCountersCmd ()
1648+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1649+ return (apiclient .listCounters (cmd ))
1650+
1651+ @classmethod
1652+ def createCondition (cls , apiclient , counterid , relationaloperator , threshold ):
1653+ """creates condition."""
1654+
1655+ cmd = createCondition .createConditionCmd ()
1656+ cmd .counterid = counterid
1657+ cmd .relationaloperator = relationaloperator
1658+ cmd .threshold = threshold
1659+ return (apiclient .createCondition (cmd ))
1660+
1661+ @classmethod
1662+ def listConditions (cls , apiclient , ** kwargs ):
1663+ """Lists all available Conditions."""
1664+
1665+ cmd = listConditions .listConditionsCmd ()
1666+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1667+ return (apiclient .listConditions (cmd ))
1668+
1669+ @classmethod
1670+ def listAutoscalePolicies (cls , apiclient , ** kwargs ):
1671+ """Lists all available Autoscale Policies."""
1672+
1673+ cmd = listAutoScalePolicies .listAutoScalePoliciesCmd ()
1674+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1675+ return (apiclient .listAutoScalePolicies (cmd ))
1676+
1677+ @classmethod
1678+ def createAutoscalePolicy (cls , apiclient , action , conditionids , duration , quiettime = None ):
1679+ """creates condition."""
1680+
1681+ cmd = createAutoScalePolicy .createAutoScalePolicyCmd ()
1682+ cmd .action = action
1683+ cmd .conditionids = conditionids
1684+ cmd .duration = duration
1685+ if quiettime :
1686+ cmd .quiettime = quiettime
1687+
1688+ return (apiclient .createAutoScalePolicy (cmd ))
1689+
1690+ @classmethod
1691+ def updateAutoscalePolicy (cls , apiclient , id , ** kwargs ):
1692+ """Updates Autoscale Policy."""
1693+
1694+ cmd = updateAutoScalePolicy .updateAutoScalePolicyCmd ()
1695+ cmd .id = id
1696+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1697+ return (apiclient .updateAutoScalePolicy (cmd ))
1698+
1699+ @classmethod
1700+ def listAutoscaleVmPofiles (cls , apiclient , ** kwargs ):
1701+ """Lists all available AutoscaleVM Profiles."""
1702+
1703+ cmd = listAutoScaleVmProfiles .listAutoScaleVmProfilesCmd ()
1704+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1705+ return (apiclient .listAutoScaleVmProfiles (cmd ))
1706+
1707+ @classmethod
1708+ def createAutoscaleVmProfile (cls , apiclient , serviceofferingid , zoneid , templateid ,
1709+ autoscaleuserid = None , destroyvmgraceperiod = None , counterparam = None ):
1710+ """creates Autoscale VM Profile."""
1711+
1712+ cmd = createAutoScaleVmProfile .createAutoScaleVmProfileCmd ()
1713+ cmd .serviceofferingid = serviceofferingid
1714+ cmd .zoneid = zoneid
1715+ cmd .templateid = templateid
1716+ if autoscaleuserid :
1717+ cmd .autoscaleuserid = autoscaleuserid
1718+
1719+ if destroyvmgraceperiod :
1720+ cmd .destroyvmgraceperiod = destroyvmgraceperiod
1721+
1722+ if counterparam :
1723+ for name , value in counterparam .items ():
1724+ cmd .counterparam .append ({
1725+ 'name' : name ,
1726+ 'value' : value
1727+ })
1728+
1729+ return (apiclient .createAutoScaleVmProfile (cmd ))
1730+
1731+ @classmethod
1732+ def updateAutoscaleVMProfile (cls , apiclient , id , ** kwargs ):
1733+ """Updates Autoscale Policy."""
1734+
1735+ cmd = updateAutoScaleVmProfile .updateAutoScaleVmProfileCmd ()
1736+ cmd .id = id
1737+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1738+ return (apiclient .updateAutoScaleVmProfile (cmd ))
1739+
1740+ @classmethod
1741+ def createAutoscaleVmGroup (cls , apiclient , lbruleid , minmembers , maxmembers ,
1742+ scaledownpolicyids , scaleuppolicyids , vmprofileid , interval = None ):
1743+ """creates Autoscale VM Group."""
1744+
1745+ cmd = createAutoScaleVmGroup .createAutoScaleVmGroupCmd ()
1746+ cmd .lbruleid = lbruleid
1747+ cmd .minmembers = minmembers
1748+ cmd .maxmembers = maxmembers
1749+ cmd .scaledownpolicyids = scaledownpolicyids
1750+ cmd .scaleuppolicyids = scaleuppolicyids
1751+ cmd .vmprofileid = vmprofileid
1752+ if interval :
1753+ cmd .interval = interval
1754+
1755+ return (apiclient .createAutoScaleVmGroup (cmd ))
1756+
1757+ @classmethod
1758+ def listAutoscaleVmGroup (cls , apiclient , ** kwargs ):
1759+ """Lists all available AutoscaleVM Group."""
1760+
1761+ cmd = listAutoScaleVmGroups .listAutoScaleVmGroupsCmd ()
1762+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1763+ return (apiclient .listAutoScaleVmGroups (cmd ))
1764+
1765+ @classmethod
1766+ def enableAutoscaleVmGroup (cls , apiclient , id , ** kwargs ):
1767+ """Enables AutoscaleVM Group."""
1768+
1769+ cmd = enableAutoScaleVmGroup .enableAutoScaleVmGroupCmd ()
1770+ cmd .id = id
1771+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1772+ return (apiclient .enableAutoScaleVmGroup (cmd ))
1773+
1774+ @classmethod
1775+ def disableAutoscaleVmGroup (cls , apiclient , id , ** kwargs ):
1776+ """Disables AutoscaleVM Group."""
1777+
1778+ cmd = disableAutoScaleVmGroup .disableAutoScaleVmGroupCmd ()
1779+ cmd .id = id
1780+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1781+ return (apiclient .disableAutoScaleVmGroup (cmd ))
1782+
1783+ @classmethod
1784+ def updateAutoscaleVMGroup (cls , apiclient , id , ** kwargs ):
1785+ """Updates Autoscale VM Group."""
1786+
1787+ cmd = updateAutoScaleVmGroup .updateAutoScaleVmGroupCmd ()
1788+ cmd .id = id
1789+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
1790+ return (apiclient .updateAutoScaleVmGroup (cmd ))
1791+
16171792
16181793class ServiceOffering :
16191794
@@ -1982,6 +2157,18 @@ def list(cls, apiclient, **kwargs):
19822157 cmd .listall = True
19832158 return (apiclient .listLoadBalancerRules (cmd ))
19842159
2160+ @classmethod
2161+ def listLoadBalancerRuleInstances (cls , apiclient , id , applied = None , ** kwargs ):
2162+ """Lists load balancing rule Instances"""
2163+
2164+ cmd = listLoadBalancerRuleInstances .listLoadBalancerRuleInstancesCmd ()
2165+ cmd .id = id
2166+ if applied :
2167+ cmd .applied = applied
2168+
2169+ [setattr (cmd , k , v ) for k , v in kwargs .items ()]
2170+ return apiclient .listLoadBalancerRuleInstances (cmd )
2171+
19852172
19862173class Cluster :
19872174 """Manage Cluster life cycle"""
@@ -2467,7 +2654,7 @@ def __init__(self, items):
24672654
24682655 @classmethod
24692656 def create (cls , apiclient , publicipid , account = None , domainid = None ,
2470- projectid = None , networkid = None , vpcid = None ):
2657+ projectid = None , networkid = None , vpcid = None , openfirewall = None ):
24712658 """Create VPN for Public IP address"""
24722659 cmd = createRemoteAccessVpn .createRemoteAccessVpnCmd ()
24732660 cmd .publicipid = publicipid
@@ -2481,6 +2668,8 @@ def create(cls, apiclient, publicipid, account=None, domainid=None,
24812668 cmd .networkid = networkid
24822669 if vpcid :
24832670 cmd .vpcid = vpcid
2671+ if openfirewall :
2672+ cmd .openfirewall = openfirewall
24842673 return Vpn (apiclient .createRemoteAccessVpn (cmd ).__dict__ )
24852674
24862675 def delete (self , apiclient ):
0 commit comments