[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a

Garrett Holmstrom gholms at fedoraproject.org
Sun Jun 16 02:30:48 UTC 2013


The following commit has been merged in the master branch:
commit 7904714c4750ee32e1507280c199a551f2c68c18
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Sat Mar 30 22:35:55 2013 -0700

    Implement CreateLoadBalancerListeners
    
    Fixes TOOLS-237

diff --git a/bin/euelb-create-lb-listeners b/bin/euelb-create-lb-listeners
new file mode 100755
index 0000000..ce00e5c
--- /dev/null
+++ b/bin/euelb-create-lb-listeners
@@ -0,0 +1,6 @@
+#!/usr/bin/python -tt
+
+import euca2ools.commands.elasticloadbalancing.createloadbalancerlisteners
+
+if __name__ == '__main__':
+    euca2ools.commands.elasticloadbalancing.createloadbalancerlisteners.CreateLoadBalancerListeners.run()
diff --git a/euca2ools/commands/elasticloadbalancing/createloadbalancer.py b/euca2ools/commands/elasticloadbalancing/argtypes.py
similarity index 64%
copy from euca2ools/commands/elasticloadbalancing/createloadbalancer.py
copy to euca2ools/commands/elasticloadbalancing/argtypes.py
index d4ad028..da82bd6 100644
--- a/euca2ools/commands/elasticloadbalancing/createloadbalancer.py
+++ b/euca2ools/commands/elasticloadbalancing/argtypes.py
@@ -29,10 +29,6 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 import argparse
-from euca2ools.commands.argtypes import delimited_list
-from euca2ools.commands.elasticloadbalancing import ELBRequest
-from requestbuilder import Arg, MutuallyExclusiveArgList
-from requestbuilder.mixins import TabifyingCommand
 
 
 def listener(listener_str):
@@ -110,42 +106,3 @@ def listener(listener_str):
     if 'cert-id' in pairs:
         listener_dict['SSLCertificateId'] = pairs['cert-id']
     return listener_dict
-
-
-class CreateLoadBalancer(ELBRequest, TabifyingCommand):
-    DESCRIPTION = ('Create a load balancer\n\nAfter the load balancer is '
-                   'created, instances must be registered with it separately.')
-    ARGS = [Arg('LoadBalancerName', metavar='ELB',
-                help='name of the new load balancer (required)'),
-            MutuallyExclusiveArgList(True,
-                Arg('-s', '--subnets', metavar='SUBNET1,SUBNET2,...',
-                    dest='Subnets.member', type=delimited_list(','),
-                    help='''[VPC only] subnets the load balancer should run in
-                    (required)'''),
-                Arg('-z', '--availability-zones', metavar='ZONE1,ZONE2,...',
-                    dest='AvailabilityZones.member', type=delimited_list(','),
-                    help='''[Non-VPC only] availability zones the load balancer
-                    should run in (required)''')),
-            Arg('-l', '--listener', dest='Listeners.member', action='append',
-                metavar=('"lb-port=PORT, protocol={HTTP,HTTPS,SSL,TCP}, '
-                         'instance-port=PORT, instance-protocol={HTTP,HTTPS,'
-                         'SSL,TCP}, cert-id=ARN"'), required=True,
-                type=listener,
-                help='''port/protocol settings for the load balancer, where
-                lb-port is the external port number, protocol is the external
-                protocol, instance-port is the back end server port number,
-                instance-protocol is the protocol to use for routing traffic to
-                back end instances, and cert-id is the ARN of the server
-                certificate to use for encrypted connections.  lb-port,
-                protocol, and instance-port are required.  This option may be
-                used multiple times.  (at least 1 required)'''),
-            Arg('-i', '--scheme', dest='Scheme', choices=('internal',),
-                metavar='internal', help='''[VPC only] "internal" to make the
-                new load balancer private to a VPC'''),
-            Arg('-g', '--security-groups', dest='SecurityGroups.member',
-                metavar='GROUP1,GROUP2,...', type=delimited_list(','),
-                help='''[VPC only] IDs of the security groups to assign to the
-                new load balancer''')]
-
-    def print_result(self, result):
-        print self.tabify(('DNS_NAME', result.get('DNSName')))
diff --git a/euca2ools/commands/elasticloadbalancing/createloadbalancer.py b/euca2ools/commands/elasticloadbalancing/createloadbalancer.py
index d4ad028..f537adb 100644
--- a/euca2ools/commands/elasticloadbalancing/createloadbalancer.py
+++ b/euca2ools/commands/elasticloadbalancing/createloadbalancer.py
@@ -28,90 +28,13 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-import argparse
 from euca2ools.commands.argtypes import delimited_list
 from euca2ools.commands.elasticloadbalancing import ELBRequest
+from euca2ools.commands.elasticloadbalancing.argtypes import listener
 from requestbuilder import Arg, MutuallyExclusiveArgList
 from requestbuilder.mixins import TabifyingCommand
 
 
-def listener(listener_str):
-    bits = listener_str.split(',')
-    pairs = {}
-    for pair_str in listener_str.strip().split(','):
-        if pair_str:
-            try:
-                key, val = pair_str.split('=')
-            except ValueError:
-                raise argparse.ArgumentTypeError(
-                    "listener '{0}': element '{1}' must have format KEY=VALUE"
-                    .format(listener_str, pair_str))
-            pairs[key.strip()] = val.strip()
-
-    extra_keys = (set(pairs.keys()) -
-                  set(('protocol', 'lb-port', 'instance-port',
-                       'instance-protocol', 'cert-id')))
-    if len(extra_keys) > 0:
-        raise argparse.ArgumentTypeError(
-            "listener '{0}': invalid element(s): {1}".format(listener_str,
-                ', '.join("'{0}'".format(key) for key in extra_keys)))
-
-    listener_dict = {}
-    if 'protocol' in pairs:
-        if pairs['protocol'] in ('HTTP', 'HTTPS', 'SSL', 'TCP'):
-            listener_dict['Protocol'] = pairs['protocol']
-        else:
-            raise argparse.ArgumentTypeError(
-                "listener '{0}': protocol '{1}' is invalid (choose from "
-                "'HTTP', 'HTTPS', 'SSL', 'TCP')"
-                .format(listener_str, pairs['protocol']))
-    else:
-        raise argparse.ArgumentTypeError(
-            "listener '{0}': protocol is required".format(listener_str))
-    if 'lb-port' in pairs:
-        try:
-            listener_dict['LoadBalancerPort'] = int(pairs['lb-port'])
-        except ValueError:
-            raise argparse.ArgumentTypeError(
-                "listener '{0}': lb-port must be an integer"
-                .format(listener_str))
-    else:
-        raise argparse.ArgumentTypeError(
-            "listener '{0}': lb-port is required".format(listener_str))
-    if 'instance-port' in pairs:
-        try:
-            listener_dict['InstancePort'] = int(pairs['instance-port'])
-        except ValueError:
-            raise argparse.ArgumentTypeError(
-                "listener '{0}': instance-port must be an integer"
-                .format(listener_str))
-    else:
-        raise argparse.ArgumentTypeError(
-            "listener '{0}': instance-port is required".format(listener_str))
-    if 'instance-protocol' in pairs:
-        if pairs['instance-protocol'] in ('HTTP', 'HTTPS'):
-            if pairs['protocol'] not in ('HTTP', 'HTTPS'):
-                raise argparse.ArgumentTypeError(
-                    "listener '{0}': instance-protocol must be 'HTTP' or "
-                    "'HTTPS' when protocol is 'HTTP' or 'HTTPS'"
-                    .format(listener_str))
-        elif pairs['instance-protocol'] in ('SSL', 'TCP'):
-            if pairs['protocol'] not in ('SSL', 'TCP'):
-                raise argparse.ArgumentTypeError(
-                    "listener '{0}': instance-protocol must be 'SSL' or "
-                    "'TCP' when protocol is 'SSL' or 'TCP'"
-                    .format(listener_str))
-        else:
-            raise argparse.ArgumentTypeError(
-                "listener '{0}': instance-protocol '{1}' is invalid (choose "
-                "from 'HTTP', 'HTTPS', 'SSL', 'TCP')"
-                .format(listener_str, pairs['instance-protocol']))
-        listener_dict['InstanceProtocol'] = pairs['instance-protocol']
-    if 'cert-id' in pairs:
-        listener_dict['SSLCertificateId'] = pairs['cert-id']
-    return listener_dict
-
-
 class CreateLoadBalancer(ELBRequest, TabifyingCommand):
     DESCRIPTION = ('Create a load balancer\n\nAfter the load balancer is '
                    'created, instances must be registered with it separately.')
diff --git a/euca2ools/commands/elasticloadbalancing/deleteloadbalancer.py b/euca2ools/commands/elasticloadbalancing/createloadbalancerlisteners.py
similarity index 57%
copy from euca2ools/commands/elasticloadbalancing/deleteloadbalancer.py
copy to euca2ools/commands/elasticloadbalancing/createloadbalancerlisteners.py
index 8fe3592..b948283 100644
--- a/euca2ools/commands/elasticloadbalancing/deleteloadbalancer.py
+++ b/euca2ools/commands/elasticloadbalancing/createloadbalancerlisteners.py
@@ -29,11 +29,24 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 from euca2ools.commands.elasticloadbalancing import ELBRequest
+from euca2ools.commands.elasticloadbalancing.argtypes import listener
 from requestbuilder import Arg
 
 
-class DeleteLoadBalancer(ELBRequest):
-    DESCRIPTION = ('Delete a load balancer\n\nIf the load balancer does not '
-                   'exist, this command still succeeds.')
+class CreateLoadBalancerListeners(ELBRequest):
+    DESCRIPTION = 'Add one or more listeners to a load balancer'
     ARGS = [Arg('LoadBalancerName', metavar='ELB',
-                help='name of the load balancer to delete (required)')]
+                help='name of the load balancer to modify (required)'),
+            Arg('-l', '--listener', dest='Listeners.member', action='append',
+                metavar=('"lb-port=PORT, protocol={HTTP,HTTPS,SSL,TCP}, '
+                         'instance-port=PORT, instance-protocol={HTTP,HTTPS,'
+                         'SSL,TCP}, cert-id=ARN"'), required=True,
+                type=listener,
+                help='''port/protocol settings for the load balancer, where
+                lb-port is the external port number, protocol is the external
+                protocol, instance-port is the back end server port number,
+                instance-protocol is the protocol to use for routing traffic to
+                back end instances, and cert-id is the ARN of the server
+                certificate to use for encrypted connections.  lb-port,
+                protocol, and instance-port are required.  This option may be
+                used multiple times.  (at least 1 required)''')]

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list