コード例 #1
0
 def __key_cmd(self, argv):
     """Implements the key command
     """
     #
     # We always show all keys; the -a option is redundant
     # but is supported for symmetry reasons.
     #
     selector = ResourceSelector()
     disp = DisplayOptions()
     region = None
     user_name = None
     opt_list, args = getopt.getopt(argv, "alr:u:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-u':
                 user_name = opt[1]
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if False:
         # modifying command
         pass
     else:
         self.__key_list_cmd(region, selector, user_name, disp)
コード例 #2
0
 def __rds_inst_cmd(self, argv):
     """Implements the 'rds inst' command
     """
     cmd_terminate = False
     all_instances = False
     disp = DisplayOptions()
     region = None
     opt_list, args = getopt.getopt(argv, "alr:Tx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 all_instances = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-T':
                 cmd_terminate = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_terminate:
         self.__rds_inst_terminate(region, args)
     else:
         if args:
             if len(args) != 1:
                 print "Only a single RDS instance id may be specified"
                 return
             dbinstance_id = args[0]
         else:
             dbinstance_id = None
         if all_instances or dbinstance_id:
             self.__rds_inst_list_cmd(region,
                                 None if all_instances else dbinstance_id,
                                 disp)
コード例 #3
0
 def __rds_subnetg_cmd(self, argv):
     """Implements the 'rds subnetg' command
     """
     all_subnet_groups = False
     disp = DisplayOptions()
     region = None
     cmd_delete = False
     opt_list, args = getopt.getopt(argv, "aDlr:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 all_subnet_groups = True
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_delete:
         self.__rds_subnetg_delete_cmd(region, args)
     else:
         if args:
             if len(args) != 1:
                 print "Only a single RDS subnet name may be specified"
                 return
             subnetg_name = args[0]
         else:
             subnetg_name = None
         if all_subnet_groups or subnetg_name:
             self.__rds_subnetg_list_cmd(region,
                             None if all_subnet_groups else subnetg_name,
                             disp)
コード例 #4
0
 def __nacl_cmd(self, argv):
     """Implements the nacl command
     """
     all_network_acls = False
     disp = DisplayOptions()
     region = None
     opt_list, args = getopt.getopt(argv, "alr:tx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 all_network_acls = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if False:
         pass
     else:
         if all_network_acls or args:
             self.__nacl_list_cmd(region,
                                     None if all_network_acls else args,
                                     disp)
コード例 #5
0
 def __keypair_cmd(self, argv):
     """Implements the keypair command
     """
     #
     # We always show all key pairs; the -a option is redundant
     # but is supported for symmetry reasons.
     #
     selector = ResourceSelector()
     disp = DisplayOptions()
     region = None
     opt_list, args = getopt.getopt(argv, "af:lr:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if False:
         # modifying command
         pass
     else:
         selector.resource_id_list = args
         self.__keypair_list_cmd(region, selector, disp)
コード例 #6
0
 def __dhcp_cmd(self, argv):
     """Implements the dhcp command
     """
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     cmd_delete = False
     cmd_associate = False
     opt_list, args = getopt.getopt(argv, "aDlr:Stx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-S':
                 cmd_associate = True
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_delete:
         self.__dhcp_delete_cmd(region, args)
     elif cmd_associate:
         self.__dhcp_associate_cmd(region, args)
     else:
         selector.resource_id_list = args
         self.__dhcp_list_cmd(region, selector, disp)
コード例 #7
0
 def __aki_cmd(self, argv):
     """Implements the aki command
     """
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     opt_list, args = getopt.getopt(argv, "af:lr:tx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if False:
         # modifying command
         pass
     else:
         selector.resource_id_list = args
         self.__aki_list_cmd(region, selector, disp)
コード例 #8
0
 def __cert_cmd(self, argv):
     """Implements the cert command
     """
     #
     # We always show all certificates; the -a option is redundant
     # but is supported for symmetry reasons.
     #
     all_certs = True
     cmd_upload = False
     cmd_delete = False
     disp = DisplayOptions()
     region = None
     path_prefix = None
     signing_cert = False    # assume server cert
     user_name = None
     cert_chain_file = None
     opt_list, args = getopt.getopt(argv, "ac:lp:r:sUu:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 all_certs = True
             elif opt[0] == '-c':
                 cert_chain_file = opt[1]
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-p':
                 path_prefix = opt[1]
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-s':
                 signing_cert = True
             elif opt[0] == '-U':
                 cmd_upload = True
             elif opt[0] == '-u':
                 user_name = opt[1]
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_upload:
         if signing_cert:
             print "Ability to upload signing certs not yet implemented"
             return
         self.__cert_upload_cmd(region, disp,
                             cert_chain_file, path_prefix, args)
     elif cmd_delete:
         self.__cert_delete_cmd(region, args)
     else:
         if signing_cert:
             self.__cert_list_signing_cmd(region, path_prefix, disp)
         else:
             self.__cert_list_server_cmd(region, user_name, disp)
コード例 #9
0
 def __eip_cmd(self, argv):
     """Implements the eip command
     """
     in_vpc = False
     cmd_allocate = False
     cmd_release = False
     cmd_associate = False
     cmd_disassociate = False
     move_address = False
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     opt_list, args = getopt.getopt(argv, "Aaf:lmRr:StXxV")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-A':
                 cmd_allocate = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-m':
                 move_address = True
             elif opt[0] == '-R':
                 cmd_release = True
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-S':
                 cmd_associate = True
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-X':
                 cmd_disassociate = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
             elif opt[0] == '-V':
                 in_vpc = True
     if cmd_allocate:
         self.__eip_allocate(region, in_vpc, args)
     elif cmd_release:
         self.__eip_release(region, args)
     elif cmd_associate:
         self.__eip_associate(region, move_address, args)
     elif cmd_disassociate:
         self.__eip_disassociate(region, args)
     else:
         selector.resource_id_list = args
         self.__eip_list_cmd(region, selector, disp)
コード例 #10
0
 def __igw_cmd(self, argv):
     """Implements the igw command
     """
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     cmd_create = False
     cmd_delete = False
     cmd_detach = False
     cmd_attach = False
     opt_list, args = getopt.getopt(argv, "aCDf:lq:rStv:Xx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-C':
                 cmd_create = True
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-S':
                 cmd_attach = True
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-v':
                 vpc_id = opt[1]
                 selector.add_filter('attachment.vpc-id', vpc_id)
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
             elif opt[0] == '-X':
                 cmd_detach = True
     if cmd_create:
         self.__igw_create_cmd(region)
     elif cmd_delete:
         self.__igw_delete_cmd(region, args)
     elif cmd_attach:
         self.__igw_attach_cmd(region, args)
     elif cmd_detach:
         self.__igw_detach_cmd(region, args)
     else:
         selector.resource_id_list = args
         self.__igw_list_cmd(region, selector, disp)
コード例 #11
0
 def __ami_cmd(self, argv):
     """Implements the ami command
     """
     cmd_delete = False
     cmd_create = False
     description = None
     virtualization_type = None
     selector = ResourceSelector()
     disp = DisplayOptions()
     region = None
     owner_list = []
     opt_list, args = getopt.getopt(argv, "aCd:Df:lnq:r:tU:v:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-C':
                 cmd_create = True
             elif opt[0] == '-d':
                 description = opt[1]
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-n':
                 disp.display_name = True
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-U':
                 owner_list.append(opt[1])
             elif opt[0] == '-v':
                 virtualization_type = opt[1]
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_delete:
         selector.resource_id_list = args
         self.__ami_delete(region, selector)
     elif cmd_create:
         self.__ami_create(region, description, virtualization_type, args)
     else:
         selector.resource_id_list = args
         self.__ami_list_cmd(region, selector, disp, owner_list)
コード例 #12
0
ファイル: clsh.py プロジェクト: CloudVelox/simple-cloud-shell
 def __zone_cmd(self, argv):
     """Implements the zone command
     """
     all_zones = False
     disp = DisplayOptions()
     region = None
     opt_list, args = getopt.getopt(argv, "alr:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 all_zones = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if all_zones or args:
         self.__zone_list_cmd(region, None if all_zones else args, disp)
コード例 #13
0
 def __subnet_cmd(self, argv):
     """Implements the subnet command
     """
     cmd_create = False
     cmd_delete = False
     selector = ResourceSelector()
     disp = DisplayOptions()
     region = None
     opt_list, args = getopt.getopt(argv, "aCDf:lq:r:xtv:")
     vpc_id = None
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-C':
                 cmd_create = True
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-v':
                 vpc_id = opt[1]
                 selector.add_filter('vpc-id', vpc_id)
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_create:
         # the vpc-id may be specified via option, or as an argument
         self.__subnet_create_cmd(region, vpc_id, args)
     elif cmd_delete:
         self.__subnet_delete_cmd(region, args)
     else:
         selector.resource_id_list = args
         self.__subnet_list_cmd(region, selector, disp)
コード例 #14
0
 def __vpc_cmd(self, argv):
     """Implements the vpc command
     """
     cmd_delete = False
     cmd_create = False
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     opt_list, args = getopt.getopt(argv, "aCDf:lq:r:tx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-C':
                 cmd_create = True
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_create:
         self.__vpc_create_cmd(region, args)
     elif cmd_delete:
         self.__vpc_delete_cmd(region, args)
     else:
         selector.resource_id_list = args
         self.__vpc_list_cmd(region, selector, disp)
コード例 #15
0
 def __sg_cmd(self, argv):
     """Implements the sg command
     """
     cmd_authorize = False
     cmd_revoke = False
     cmd_delete = False
     cmd_create = False
     selector = ResourceSelector()
     disp = DisplayOptions()
     region = None
     subnet_spec = None
     port_spec = None
     principal_sg_id = None
     vpc_id = None   # used when creating a SG
     opt_list, args = getopt.getopt(argv, "aACDf:g:kln:p:q:Rr:s:tv:x")
     for opt in opt_list:
         if opt[0] == '-A':
             cmd_authorize = True
         elif opt[0] == '-C':
             cmd_create = True
         elif opt[0] == '-D':
             cmd_delete = True
         elif opt[0] == '-a':
             selector.select_all = True
         elif opt[0] == '-f':
             selector.add_filter_spec(opt[1])
         elif opt[0] == '-g':
             principal_sg_id = opt[1]
         elif opt[0] == '-k':
             disp.display_count = True
         elif opt[0] == '-l':
             disp.display = DisplayOptions.LONG
         elif opt[0] == '-n':
             selector.add_filter('group-name', opt[1])
         elif opt[0] == '-p':
             port_spec = _PortSpec(opt[1])
         elif opt[0] == '-q':
             selector.add_tag_filter_spec(opt[1])
         elif opt[0] == '-R':
             cmd_revoke = True
         elif opt[0] == '-r':
             region = opt[1]
         elif opt[0] == '-s':
             subnet_spec = opt[1]
         elif opt[0] == '-t':
             disp.display_tags = True
         elif opt[0] == '-v':
             selector.add_filter('vpc-id', opt[1])
             vpc_id = opt[1]
         elif opt[0] == '-x':
             disp.display = DisplayOptions.EXTENDED
     if cmd_authorize:
         self.__sg_authorize_cmd(region, True, args,
                             port_spec, subnet_spec, principal_sg_id)
     elif cmd_revoke:
         self.__sg_authorize_cmd(region, False, args,
                             port_spec, subnet_spec, principal_sg_id)
     elif cmd_delete:
         self.__sg_delete_cmd(region, args)
     elif cmd_create:
         self.__sg_create_cmd(region, vpc_id, args)
     else:
         selector.resource_id_list = args
         self.__sg_list_cmd(region, selector, disp)
コード例 #16
0
 def __eni_cmd(self, argv):
     """Implements the eni command
     """
     cmd_create = False
     cmd_delete = False
     cmd_attach = False
     cmd_detach = False
     cmd_source_dest_check = False
     source_dest_check = None
     description = None
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     opt_list, args = getopt.getopt(argv, "aBCDd:f:i:lPq:r:StXx")
     if opt_list:
         for opt in opt_list:
             if opt[0] == "-a":
                 selector.select_all = True
             elif opt[0] == "-B":
                 cmd_source_dest_check = True
                 source_dest_check = True
             elif opt[0] == "-C":
                 cmd_create = True
             elif opt[0] == "-D":
                 cmd_delete = True
             elif opt[0] == "-d":
                 description = opt[1]
             elif opt[0] == "-f":
                 selector.add_filter_spec(opt[1])
             elif opt[0] == "-i":
                 selector.add_filter("attachment.instance-id", opt[1])
             elif opt[0] == "-l":
                 disp.display = DisplayOptions.LONG
             elif opt[0] == "-P":
                 cmd_source_dest_check = True
                 source_dest_check = False
             elif opt[0] == "-q":
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == "-r":
                 region = opt[1]
             elif opt[0] == "-S":
                 cmd_attach = True
             elif opt[0] == "-t":
                 disp.display_tags = True
             elif opt[0] == "-X":
                 cmd_detach = True
             elif opt[0] == "-x":
                 disp.display = DisplayOptions.EXTENDED
     if cmd_create:
         self.__eni_create_cmd(region, description, args)
     elif cmd_delete:
         self.__eni_delete_cmd(region, args)
     elif cmd_attach:
         self.__eni_attach_cmd(region, args)
     elif cmd_detach:
         self.__eni_detach_cmd(region, args)
     elif cmd_source_dest_check:
         self.__eni_source_dest_check(region, source_dest_check, args)
     else:
         selector.resource_id_list = args
         self.__eni_list_cmd(region, selector, disp)
コード例 #17
0
 def __snap_cmd(self, argv):
     """Implements the snap command
     """
     cmd_create_snapshot = False
     cmd_delete_snapshot = False
     cmd_share_snapshot = False
     cmd_unshare_snapshot = False
     description = None
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     opt_list, args = getopt.getopt(argv, "aCDd:f:klm:nO:o:q:r:SsxtUz:")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-C':
                 cmd_create_snapshot = True
             elif opt[0] == '-D':
                 cmd_delete_snapshot = True
             elif opt[0] == '-d':
                 description = opt[1]
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-k':
                 disp.display_count = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-m':
                 selector.match_pattern = opt[1]
             elif opt[0] == '-n':
                 disp.display_name = True
             elif opt[0] == '-O':
                 disp.set_output_file(opt[1])
             elif opt[0] == '-o':
                 self.__add_display_order(disp, opt[1])
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-S':
                 cmd_share_snapshot = True
             elif opt[0] == '-s':
                 disp.display_size = True
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
             elif opt[0] == '-U':
                 cmd_unshare_snapshot = True
             elif opt[0] == '-z':
                 selector.add_filter('status', opt[1])
     if cmd_create_snapshot:
         self.__snap_create(region, description, args)
     elif cmd_delete_snapshot:
         selector.resource_id_list = args
         self.__snap_delete(region, selector)
     elif cmd_share_snapshot:
         self.__snap_share(region, True, args)
     elif cmd_unshare_snapshot:
         self.__snap_share(region, False, args)
     else:
         selector.resource_id_list = args
         self.__snap_list_cmd(region, selector, disp)
コード例 #18
0
 def __vol_cmd(self, argv):
     """Implements the vol command
     """
     cmd_detach = False
     cmd_attach = False
     cmd_create = False
     cmd_delete = False
     cmd_move = False
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     instance_id = None
     # Volume type, when creating a new volume
     vol_type = None
     opt_list, args = getopt.getopt(argv, "aCc:Df:i:klMnO:o:q:r:SstXxz:")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-C':
                 cmd_create = True
             elif opt[0] == '-c':
                 vol_type = opt[1]
             elif opt[0] == '-D':
                 cmd_delete = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-i':
                 instance_id = opt[1]
                 selector.add_filter('attachment.instance-id', instance_id)
             elif opt[0] == '-k':
                 disp.display_count = True
             elif opt[0] == '-M':
                 cmd_move = True
             elif opt[0] == '-n':
                 disp.display_name = True
             elif opt[0] == '-O':
                 disp.set_output_file(opt[1])
             elif opt[0] == '-o':
                 self.__add_display_order(disp, opt[1])
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-S':
                 cmd_attach = True
             elif opt[0] == '-s':
                 disp.display_size = True
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-X':
                 cmd_detach = True
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
             elif opt[0] == '-z':
                 selector.add_filter('status', opt[1])
     if cmd_detach:
         selector.resource_id_list = args
         self.__vol_detach_cmd(region, instance_id, selector)
     elif cmd_attach:
         self.__vol_attach_cmd(region, args)
     elif cmd_create:
         self.__vol_create_cmd(region, vol_type, args)
     elif cmd_delete:
         selector.resource_id_list = args
         self.__vol_delete_cmd(region, selector)
     elif cmd_move:
         self.__vol_move_cmd(region, args)
     else:
         selector.resource_id_list = args
         self.__vol_list_cmd(region, selector, disp)
コード例 #19
0
 def __elb_cmd(self, argv):
     """Implements the elb command
     """
     all_elbs = False
     cmd_create_elb = False
     cmd_delete_elb = False
     cmd_modify_add = False
     cmd_modify_remove = False
     cmd_query_instance_health = False
     cmd_config_healthcheck = False
     disp = DisplayOptions()
     disp.display_policies = False
     region = None
     policy_name = None
     healthcheck_spec = None
     subnet_list = []
     listener_list = []
     sg_id_list = []
     instance_id_list = []
     opt_list, args = getopt.getopt(argv, "AaCDg:H:hi:L:lpP:Rr:s:x")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 all_elbs = True
             elif opt[0] == '-A':
                 cmd_modify_add = True
             elif opt[0] == '-C':
                 cmd_create_elb = True
             elif opt[0] == '-D':
                 cmd_delete_elb = True
             elif opt[0] == '-g':
                 sg_id_list.extend(opt[1].split(','))
             elif opt[0] == '-H':
                 healthcheck_spec = opt[1]
                 cmd_config_healthcheck = True
             elif opt[0] == '-h':
                 cmd_query_instance_health = True
             elif opt[0] == '-L':
                 listener_list.append(opt[1])
             elif opt[0] == '-i':
                 instance_id_list.extend(opt[1].split(','))
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-p':
                 disp.display_policies = True
             elif opt[0] == '-P':
                 policy_name = opt[1]
             elif opt[0] == '-R':
                 cmd_modify_remove = True
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-s':
                 subnet_list.extend(opt[1].split(','))
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
     if cmd_create_elb:
         self.__elb_create_cmd(region, subnet_list,
                             listener_list, sg_id_list, args)
     elif cmd_modify_add:
         if policy_name:
             self.__elb_policy_add(region, policy_name,
                                                     listener_list, args)
         else:
             self.__elb_modify_add_cmd(region, listener_list, sg_id_list,
                     subnet_list, instance_id_list, args)
     elif cmd_modify_remove:
         if policy_name:
             self.__elb_policy_remove(region, policy_name,
                                                     listener_list, args)
         else:
             self.__elb_modify_remove_cmd(region, listener_list, sg_id_list,
                     subnet_list, instance_id_list, args)
     elif cmd_delete_elb:
         self.__elb_delete_cmd(region, args)
     elif cmd_config_healthcheck:
         self.__elb_config_healthcheck(region, healthcheck_spec, args)
     elif cmd_query_instance_health:
         self.__elb_instance_health(region, args)
     else:
         if all_elbs or args:
             self.__elb_list_cmd(region,
                                 None if all_elbs else args,
                                 disp)
コード例 #20
0
 def __inst_cmd(self, argv):
     """Implements the inst command
     """
     cmd_terminate = False
     cmd_run_instance = False
     cmd_start_instance = False
     cmd_stop_instance = False
     cmd_reboot_instance = False
     cmd_set_attribute = False
     #cmd_instance_access = False
     ebs_optimized = None
     instance_type = None
     disp = DisplayOptions()
     selector = ResourceSelector()
     region = None
     keypair_name = None
     user_data = None
     shutdown_action = 'stop'
     opt_list, args = getopt.getopt(argv,
                             "aABc:ef:K:klO:nq:Rr:Ss:Ttu:v:XxZz:")
     if opt_list:
         for opt in opt_list:
             if opt[0] == '-a':
                 selector.select_all = True
             elif opt[0] == '-A':
                     cmd_set_attribute = True
             elif opt[0] == '-B':
                 cmd_reboot_instance = True
             elif opt[0] == '-c':
                 instance_type = opt[1]
             elif opt[0] == '-e':
                 ebs_optimized = True
             elif opt[0] == '-f':
                 selector.add_filter_spec(opt[1])
             elif opt[0] == '-K':
                 keypair_name = opt[1]
             elif opt[0] == '-k':
                 disp.display_count = True
             elif opt[0] == '-l':
                 disp.display = DisplayOptions.LONG
             elif opt[0] == '-O':
                 disp.set_output_file(opt[1])
             elif opt[0] == '-n':
                 disp.display_name = True
             elif opt[0] == '-q':
                 selector.add_tag_filter_spec(opt[1])
             elif opt[0] == '-R':
                 cmd_run_instance = True
             elif opt[0] == '-r':
                 region = opt[1]
             elif opt[0] == '-S':
                 cmd_start_instance = True
             elif opt[0] == '-s':
                 shutdown_action = opt[1]
             elif opt[0] == '-T':
                 cmd_terminate = True
             elif opt[0] == '-t':
                 disp.display_tags = True
             elif opt[0] == '-u':
                 user_data = opt[1]
             elif opt[0] == '-v':
                 selector.add_filter('vpc-id', opt[1])
             elif opt[0] == '-x':
                 disp.display = DisplayOptions.EXTENDED
             elif opt[0] == '-Z':
                 cmd_stop_instance = True
             elif opt[0] == '-z':
                 selector.add_filter('instance-state-name', opt[1])
     if cmd_terminate:
         self.__inst_terminate_cmd(region, args)
     elif cmd_run_instance:
         self.__inst_run_cmd(region, ebs_optimized, instance_type,
                                     keypair_name, user_data,
                                     shutdown_action, args)
     elif cmd_start_instance:
         self.__inst_start_cmd(region, instance_type, args)
     elif cmd_stop_instance:
         self.__inst_stop_cmd(region, args)
     elif cmd_reboot_instance:
         self.__inst_reboot_cmd(region, args)
     elif cmd_set_attribute:
         self.__inst_set_attribute(region, args)
     else:
         selector.set_resource_ids(args, 'i-')
         self.__inst_list_cmd(region, selector, disp)