Esempio n. 1
0
 def get_parser(self, prog_name):
     parser = super(GateAddTarget, self).get_parser(prog_name)
     parser.add_argument(
         'gate_id',
         metavar='<gate_id>',
         help=_('ID of gate to create')
     )
     parser.add_argument(
         'server_id',
         metavar='<server_id>',
         help=_('nova ID of target to add to gate')
     )
     
     parser.add_argument(
         'name',
         metavar='<name>',
         help=_('target to add to specified gate')
     )
     parser.add_argument(
         '--routable',
         action='store_true',
         default=True,
         help=_('Refer to state network VM target VM is connected to')
     )
     return parser
Esempio n. 2
0
 def get_parser(self, prog_name):
     parser = super(GateRemoveKey, self).get_parser(prog_name)
     parser.add_argument(
         'gate_id',
         metavar='<gate_id>',
         help=_('gate to delete')
     )
     parser.add_argument(
         'key_id',
         metavar='<key_id>',
         help=_('gate to delete')
     )
     return parser
Esempio n. 3
0
 def get_parser(self, prog_name):
     parser = super(GateRemoveTarget, self).get_parser(prog_name)
     parser.add_argument(
         'gate_id',
         metavar='<gate_id>',
         help=_('gate to delete')
     )
     parser.add_argument(
         'target_id',
         metavar='<target_id>',
         help=_('target to add to specified gate')
     )
     return parser
Esempio n. 4
0
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)
        knob_client = self.app.client_manager.knob

        fields = {
            'name': parsed_args.name,
            'net_id': parsed_args.net_id,
            'public_net_id': parsed_args.public_net_id,
            }
        if parsed_args.flavor:
            fields['flavor'] = parsed_args.flavor
        if parsed_args.image:
            fields['image'] = parsed_args.image
        if parsed_args.security_group:
            fields['security_groups'] = parsed_args.security_group
       
        print (fields) 
        try:
            gate = knob_client.gates.create(**fields)
        except exceptions.HTTPNotFound:
            raise exceptions.CommandError(_('Gate not found: %s')
                                   % parsed_args.name)
                
        rows = list(six.itervalues(gate))
        columns = list(six.iterkeys(gate))
        return columns, rows
Esempio n. 5
0
 def take_action(self, parsed_args):
     self.log.debug('take_action(%s)', parsed_args)
     knob_client = self.app.client_manager.knob
     
     try:
         key_content = open(parsed_args.key_file).read().strip()
     except:
         print ("FATAL: key file '%s' could not be opened." % parsed_args.key_file)
         return None
     
     fields = {
         'name': parsed_args.name,
         'key_content': key_content,
         }
     try:
         key = knob_client.gates.add_key(parsed_args.gate_id, **fields)
     except exceptions.HTTPNotFound:
         raise exceptions.CommandError(_('Key is not added to gate: %s')
                                % parsed_args.gate_id)
             
     print ('Key: %(key)s add to Gate: %(gate)s' % 
            {'key': parsed_args.id, 'gate': parsed_args.gate_id})
     
     rows = list(six.itervalues(key))
     columns = list(six.iterkeys(key))
     return columns, rows
Esempio n. 6
0
 def get_parser(self, prog_name):
     parser = super(GateListKeys, self).get_parser(prog_name)
     parser.add_argument(
         "gate_id",
         metavar='<gate_id>',
         help=_("Request facet terms for all projects (admin only)")
     )
     return parser
Esempio n. 7
0
 def get_parser(self, prog_name):
     parser = super(GateListTargets, self).get_parser(prog_name)
     parser.add_argument(
         'gate_id',
         metavar='<gate_id>',
         help=_('gate to delete')
     )
     return parser
Esempio n. 8
0
 def take_action(self, parsed_args):
     self.log.debug('take_action(%s)', parsed_args)
     knob_client = self.app.client_manager.knob
     try:
         knob_client.gates.delete(parsed_args.gate_id)
     except exceptions.HTTPNotFound:
         raise exceptions.CommandError(_('Gate not found: %s')
                                % parsed_args.gate_id)
Esempio n. 9
0
    def get_parser(self, prog_name):
        parser = super(GateAddKey, self).get_parser(prog_name)
        parser.add_argument(
            'gate_id',
            metavar='<gate_id>',
            help=_('gate to add public key to it')
        )
        parser.add_argument(
            'key_file',
            metavar='<key_file>',
            help=_('public key file path')
        )
        parser.add_argument(
            'name',
            metavar='<name>',
            help=_('Key name')
        )

        return parser
Esempio n. 10
0
 def get_parser(self, prog_name):
     parser = super(ListGate, self).get_parser(prog_name)
     parser.add_argument(
         "--all-projects",
         action='store_true',
         default=False,
         help=_("Request facet terms for all projects (admin only)")
     )
             
     return parser
Esempio n. 11
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        knob_client = self.app.client_manager.knob
        try:
            gate = knob_client.gates.get(parsed_args.gate_id)
        except exceptions.HTTPNotFound:
            raise exceptions.CommandError(_('Gate not found: %s')
                                   % parsed_args.gate_id)
            
        rows = list(six.itervalues(gate))
        columns = list(six.iterkeys(gate))
        return columns, rows
Esempio n. 12
0
 def take_action(self, parsed_args):
     self.log.debug('take_action(%s)', parsed_args)
     knob_client = self.app.client_manager.knob
     
     fields = {
         'gate_id': parsed_args.gate_id,
         'server_id': parsed_args.server_id,
         'name': parsed_args.name,
         'routable': parsed_args.routable,
         }
     try:
         target = knob_client.gates.add_target(parsed_args.gate_id, 
                                               **fields)
     except exceptions.HTTPNotFound:
         raise exceptions.CommandError(_('Gate not found: %s')
                                % parsed_args.gate_id)
             
     print ('Target VM: %(target)s add to Gate: %(gate)s' % 
            {'target': parsed_args.server_id, 'gate': parsed_args.gate_id})
     return target['name']
Esempio n. 13
0
 def get_parser(self, prog_name):
     parser = super(CreateGate, self).get_parser(prog_name)
     parser.add_argument(
         'name',
         metavar='<name>',
         help=_('Name of gate to create')
     )
     
     parser.add_argument(
         '--net-id',
         required=True,
         metavar='<net-id>',
         help=_('Network to build gate server on it')
     )
     
     parser.add_argument(
         '--public-net-id',
         required=True,
         metavar='<public-net-id>',
         help=_('Network to build gate server on it')
     )
     
     parser.add_argument(
         '--image',
         metavar='<image>',
         help=_('Image to boot from')
     )
     
     parser.add_argument(
         '--flavor',
         metavar='<flavor>',
         help=_('Create server with this flavor (name or ID)'),
     )
     parser.add_argument(
         '--security-group',
         metavar='<security-group-name>',
         help=_('Security group to assign to this server (name or ID) '
                '(repeat option to set multiple groups)')
     )
     
     return parser