예제 #1
0
파일: endpoint.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(CreateEndpoint, self).get_parser(prog_name)
     parser.add_argument(
         'service',
         metavar='<service>',
         help=_('New endpoint service (name or ID)'),
     )
     parser.add_argument(
         '--publicurl',
         metavar='<url>',
         required=True,
         help=_('New endpoint public URL (required)'),
     )
     parser.add_argument(
         '--adminurl',
         metavar='<url>',
         help=_('New endpoint admin URL'),
     )
     parser.add_argument(
         '--internalurl',
         metavar='<url>',
         help=_('New endpoint internal URL'),
     )
     parser.add_argument(
         '--region',
         metavar='<region-id>',
         help=_('New endpoint region ID'),
     )
     return parser
예제 #2
0
파일: resource.py 프로젝트: xinni-ge/eclcli
    def get_parser(self, prog_name):
        parser = super(ResourceList, self).get_parser(prog_name)
        parser.add_argument('stack',
                            metavar='<stack>',
                            help=_('Name or ID of stack to query'))
        parser.add_argument(
            '--long',
            action='store_true',
            help=_('Enable detailed information presented for each resource '
                   'in resource list'))
        # parser.add_argument(
        #     '-n', '--nested-depth',
        #     metavar='<nested-depth>',
        #     type=int,
        #     help=_('Depth of nested stacks from which to display resources')
        # )

        # parser.add_argument(
        #     '--filter',
        #     metavar='<key=value>',
        #     action='append',
        #     help=_('Filter parameters to apply on returned resources based on '
        #            'their name, status, type, action, id and '
        #            'physcial_resource_id')
        # )

        return parser
예제 #3
0
파일: resource.py 프로젝트: xinni-ge/eclcli
def _resource_signal(heat_client, args):
    fields = {'stack_id': args.stack, 'resource_name': args.resource}
    data = args.data
    data_file = args.data_file
    if data and data_file:
        raise exc.CommandError(
            _('Should only specify one of data or '
              'data-file'))

    if data_file:
        data_url = heat_utils.normalise_file_path_to_url(data_file)
        data = request.urlopen(data_url).read()

    if data:
        try:
            data = jsonutils.loads(data)
        except ValueError as ex:
            raise exc.CommandError(_('Data should be in JSON format: %s') % ex)
        if not isinstance(data, dict):
            raise exc.CommandError(_('Data should be a JSON dict'))

        fields['data'] = data
    try:
        heat_client.resources.signal(**fields)
    except heat_exc.HTTPNotFound:
        raise exc.CommandError(
            _('Stack %(stack)s or resource %(resource)s '
              'not found.') % {
                  'stack': args.stack,
                  'resource': args.resource
              })
예제 #4
0
    def get_parser(self, prog_name):
        parser = super(CreateVirtualNetworkAppliance, self).\
            get_parser(prog_name)
        parser.add_argument('virtual_network_appliance_plan_id',
                            metavar='<virtual-network-appliance-plan-id>',
                            help='ID of virtual network appliance plan')

        parser.add_argument(
            '--interface',
            metavar="<net-id=net-uuid,ip-address=ip-addr,name=interface-name,"
            "description=interface-description,tags=interface-tags>",
            action='append',
            default=[],
            help=_("Specify interface parameter for "
                   "virtual network appliance. "
                   "You can specify only one interface in creation of "
                   "virtual network appliance. "
                   "net-id: attach interface to network with this UUID, "
                   "ip-address: IPv4 fixed address for interface. "
                   "(You can specify only one address in creation), "
                   "name: Name of Interface (optional)."
                   "description: Description of the interface,"
                   "tags: Tags of the interface,"
                   "      (e.g. '{\"tag1\": 1,\"tag2\": \"a\"...}' )"),
        )

        parser.add_argument(
            '--name',
            metavar='<name>',
            help=_('Name of virtual network appliance'),
        )

        parser.add_argument(
            '--description',
            metavar='<description>',
            help=_('Description of virtual network appliance'),
        )

        parser.add_argument(
            "--tags",
            help="Tags of virtual network appliance" \
                " (e.g. '{\"tag1\": 1,\"tag2\": \"a\"...}' )",
            metavar='<string>'
        )

        parser.add_argument(
            '--default-gateway',
            metavar='<default-gateway>',
            help=_('Default gateway of virtual network appliance'),
        )

        parser.add_argument(
            '--availability-zone',
            metavar='<availability-zone>',
            help=_('Availability zone that virtual network appliance '
                   'will be created'),
        )

        return parser
예제 #5
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity
        auth_ref = self.app.client_manager.auth_ref

        # No user or project specified, list all roles in the system
        if not parsed_args.user and not parsed_args.project:
            columns = ('ID', 'Name')
            data = identity_client.roles.list()
        elif parsed_args.user and parsed_args.project:
            user = utils.find_resource(
                identity_client.users,
                parsed_args.user,
            )
            project = utils.find_resource(
                identity_client.projects,
                parsed_args.project,
            )
            data = identity_client.roles.roles_for_user(user.id, project.id)

        elif parsed_args.user:
            user = utils.find_resource(
                identity_client.users,
                parsed_args.user,
            )
            if self.app.client_manager.auth_ref:
                project = utils.find_resource(identity_client.projects,
                                              auth_ref.project_id)
            else:
                msg = _("Project must be specified")
                raise exceptions.CommandError(msg)
            data = identity_client.roles.roles_for_user(user.id, project.id)
        elif parsed_args.project:
            project = utils.find_resource(
                identity_client.projects,
                parsed_args.project,
            )
            if self.app.client_manager.auth_ref:
                user = utils.find_resource(identity_client.users,
                                           auth_ref.user_id)
            else:
                msg = _("User must be specified")
                raise exceptions.CommandError(msg)
            data = identity_client.roles.roles_for_user(user.id, project.id)

        if parsed_args.user or parsed_args.project:
            columns = ('ID', 'Name', 'Project', 'User')
            for user_role in data:
                user_role.user = user.name
                user_role.project = project.name

        return (columns, (utils.get_item_properties(
            s,
            columns,
            formatters={},
        ) for s in data))
예제 #6
0
파일: resource.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(ResourceMetadata, self).get_parser(prog_name)
     parser.add_argument(
         'stack',
         metavar='<stack>',
         help=_('Stack to display (name or ID)'),
     )
     parser.add_argument(
         'resource',
         metavar='<resource>',
         help=_('Name of the resource to show the metadata for'))
     return parser
예제 #7
0
 def get_parser(self, prog_name):
     parser = super(DeleteEC2Creds, self).get_parser(prog_name)
     parser.add_argument(
         'access_key',
         metavar='<access-key>',
         help=_('Credentials access key'),
     )
     parser.add_argument(
         '--user',
         metavar='<user>',
         help=_('Delete credentials for user (name or ID)'),
     )
     return parser
예제 #8
0
 def get_parser(self, prog_name):
     parser = super(CreateRole, self).get_parser(prog_name)
     parser.add_argument(
         'role_name',
         metavar='<name>',
         help=_('New role name'),
     )
     parser.add_argument(
         '--or-show',
         action='store_true',
         help=_('Return existing role'),
     )
     return parser
예제 #9
0
파일: user.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(ListUser, self).get_parser(prog_name)
     parser.add_argument(
         '--project',
         metavar='<project>',
         help=_('Filter users by project (name or ID)'),
     )
     parser.add_argument(
         '--long',
         action='store_true',
         default=False,
         help=_('List additional fields in output'))
     return parser
예제 #10
0
파일: service.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(ShowService, self).get_parser(prog_name)
     parser.add_argument(
         'service',
         metavar='<service>',
         help=_('Service to display (type, name or ID)'),
     )
     parser.add_argument(
         '--catalog',
         action='store_true',
         default=False,
         help=_('Show service catalog information'),
     )
     return parser
예제 #11
0
 def get_parser(self, prog_name):
     parser = super(ListUserRole, self).get_parser(prog_name)
     parser.add_argument(
         'user',
         metavar='<user>',
         nargs='?',
         help=_('User to list (name or ID)'),
     )
     parser.add_argument(
         '--project',
         metavar='<project>',
         help=_('Filter users by <project> (name or ID)'),
     )
     return parser
예제 #12
0
파일: ec2creds.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(ShowEC2Creds, self).get_parser(prog_name)
     parser.add_argument(
         'access_key',
         metavar='<access-key>',
         help=_('Credentials access key'),
     )
     parser.add_argument(
         '--user',
         metavar='<user>',
         help=_('Show credentials for user (name or ID)'),
     )
     common.add_user_domain_option_to_parser(parser)
     return parser
예제 #13
0
파일: resource.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(ResourceShow, self).get_parser(prog_name)
     parser.add_argument('stack',
                         metavar='<stack>',
                         help=_('Name or ID of stack to query'))
     parser.add_argument('resource',
                         metavar='<resource>',
                         help=_('Name or ID of resource'))
     # parser.add_argument(
     #     '--with-attr',
     #     metavar='<attribute>',
     #     action='append',
     #     help=_('Attribute to show, can be specified multiple times')
     # )
     return parser
예제 #14
0
    def take_action(self, parsed_args):
        vnf_client = self.app.eclsdk.conn.virtual_network_appliance

        target = vnf_client.\
            get_virtual_network_appliance(
            parsed_args.virtual_network_appliance)

        rows = ['ID', 'Name', 'Description', 'Tags']
        row_headers = rows

        # serialize request parmeter as JSON
        requested_param = {}
        if hasattr(parsed_args, 'name') and parsed_args.name is not None:
            requested_param['name'] = parsed_args.name
        if hasattr(parsed_args,
                   'description') and parsed_args.description is not None:
            requested_param['description'] = parsed_args.description
        if hasattr(parsed_args, 'tags') and parsed_args.tags is not None:
            tags = parsed_args.tags or '{}'
            try:
                requested_param['tags'] = json.loads(tags)
            except Exception:
                msg = _("You must specify JSON object format")
                raise exceptions.CommandError(msg)

        # serialize current parmeter as JSON
        current_param = {
            'name': target.name,
            'description': target.description,
            'tags': target.tags,
        }
        origin_param = copy.deepcopy(current_param)
        merged_param = jmp.merge(current_param, requested_param)
        patch = jmp.create_patch(origin_param, merged_param)

        if target.tags != requested_param['tags']:
            patch[tags] = requested_param['tags']

        if not patch:
            msg = _('No change will be expected')
            raise exceptions.CommandError(msg)

        data = vnf_client.update_virtual_network_appliance(
            parsed_args.virtual_network_appliance, **patch)

        _set_interface_names_for_display(data)

        return row_headers, utils.get_item_properties(data, rows)
예제 #15
0
파일: endpoint.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(DeleteEndpoint, self).get_parser(prog_name)
     parser.add_argument(
         'endpoint',
         metavar='<endpoint-id>',
         help=_('Endpoint ID to delete'))
     return parser
예제 #16
0
 def get_parser(self, prog_name):
     parser = super(CreateDomain, self).get_parser(prog_name)
     parser.add_argument(
         'name',
         metavar='<domain-name>',
         help='New domain name',
     )
     parser.add_argument(
         '--description',
         metavar='<description>',
         help='New domain description',
     )
     enable_group = parser.add_mutually_exclusive_group()
     enable_group.add_argument(
         '--enable',
         action='store_true',
         help='Enable domain (default)',
     )
     enable_group.add_argument(
         '--disable',
         action='store_true',
         help='Disable domain',
     )
     parser.add_argument(
         '--or-show',
         action='store_true',
         help=_('Return existing domain'),
     )
     return parser
예제 #17
0
    def get_parser(self, prog_name):
        parser = super(UpdateVirtualNetworkApplianceAAPs, self).\
            get_parser(prog_name)
        parser.add_argument('virtual_network_appliance',
                            metavar='<virtual-network-appliance-id>',
                            help='Name or ID of virtual network appliance')

        parser.add_argument(
            '--allowed-address-pair',
            metavar="<interface-slot-no=number,ip-address=ip-addr,"
            "mac-address=mac-addr,type=type,vrid=vrid>",
            action='append',
            default=[],
            help=_("Specify Allowed Address Pair(A.A.P) parameter for "
                   "virtual network appliance. "
                   "slot-no: sequential number of interface,"
                   "ip-address: IP address of A.A.P, "
                   "mac-address: MAC address of A.A.P, "
                   "type: Type of A.A.P. You can use 'vrrp' or '', "
                   "vrid: VRID of A.A.P. You can use this only in case vrrp, "
                   "You can specify same slot number multiple times."
                   "(e.g: --allowed-address-pair slot-no=1,ip-address=1.1.1.1 "
                   "--allowed-address-pair slot-no=1,ipaddress=2.2.2.2 ...) , "
                   "In this case, all values relates to slot-no=1 "
                   "will be appended as interface_1.allowed_address_pairs "
                   "list."),
        )

        return parser
예제 #18
0
 def get_parser(self, prog_name):
     parser = super(ShowVirtualNetworkApplianceConsole, self).\
         get_parser(prog_name)
     parser.add_argument(
         'virtual_network_appliance',
         metavar='<virtual-network-appliance-id>',
         help=_('Virtual Network Appliance ID to show console url'),
     )
     type_group = parser.add_mutually_exclusive_group()
     type_group.add_argument(
         '--novnc',
         dest='url_type',
         action='store_const',
         const='novnc',
         default='novnc',
         help='Show noVNC console URL (default)',
     )
     type_group.add_argument(
         '--xvpvnc',
         dest='url_type',
         action='store_const',
         const='xvpvnc',
         help='Show xpvnc console URL',
     )
     return parser
예제 #19
0
파일: resource.py 프로젝트: xinni-ge/eclcli
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)

        client = self.app.client_manager.orchestration

        fields = {
            # 'nested_depth': parsed_args.nested_depth,
            'with_detail': parsed_args.long,
            # 'filters': heat_utils.format_parameters(parsed_args.filter),
        }

        try:
            resources = client.resources.list(parsed_args.stack, **fields)
        except heat_exc.HTTPNotFound:
            msg = _('Stack not found: %s') % parsed_args.stack
            raise exc.CommandError(msg)

        columns = [
            'physical_resource_id',
            'resource_type',
            'resource_status',
            # 'updated_time'
        ]

        if len(resources) >= 1 and not hasattr(resources[0], 'resource_name'):
            columns.insert(0, 'logical_resource_id')
        else:
            columns.insert(0, 'resource_name')

        # if parsed_args.nested_depth or parsed_args.long:
        if parsed_args.long:
            columns.append('stack_name')

        return (columns, (utils.get_item_properties(r, columns)
                          for r in resources))
예제 #20
0
파일: service.py 프로젝트: xinni-ge/eclcli
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity

        type_or_name = parsed_args.type_or_name
        name = parsed_args.name
        type = parsed_args.type

        # If only a single positional is present, it's a <type>.
        # This is not currently legal so it is considered a new case.
        if not type and not name:
            type = type_or_name
        # If --type option is present then positional is handled as <name>;
        # display deprecation message.
        elif type:
            name = type_or_name
            self.log.warning(
                _('The argument --type is deprecated, use service'
                  ' create --name <service-name> type instead.'))
        # If --name option is present the positional is handled as <type>.
        # Making --type optional is new, but back-compatible
        elif name:
            type = type_or_name

        service = identity_client.services.create(name, type,
                                                  parsed_args.description)

        info = {}
        info.update(service._info)
        return zip(*sorted(six.iteritems(info)))
예제 #21
0
    def get_parser(self, prog_name):
        parser = super(UpdateVirtualNetworkApplianceInterfaces, self).\
            get_parser(prog_name)
        parser.add_argument(
            'interface',
            metavar="<slot-no=number,name=interface-name,"
            "description=interface-description,"
            "tags=interface-tags,net-id=net-uuid,"
            "fixed-ips=ip-addr1:ip-addr2...>",
            action='store',
            nargs='+',
            help=_("Specify interface parameter "
                   "for virtual network appliance. "
                   "slot-no: sequential number of interface,"
                   "name: Name of the interface,"
                   "description: Description of the interface,"
                   "tags: Tags of the interface,"
                   "      (e.g. '{\"tag1\": 1,\"tag2\": \"a\"...}' )"
                   "net-id: attach interface to network with this UUID, "
                   "fixed-ips: IPv4 fixed address for NIC. "
                   "You can specif multiple ip address by using ':' "
                   "(e.g: 1.1.1.1:2.2.2.2:...)"))
        parser.add_argument('virtual_network_appliance',
                            metavar='<virtual-network-appliance-id>',
                            type=_type_uuid,
                            help='Name or ID of virtual network appliance')

        return parser
예제 #22
0
 def get_parser(self, prog_name):
     parser = super(ShowRegion, self).get_parser(prog_name)
     parser.add_argument(
         'region',
         metavar='<region-id>',
         help=_('Region to display'),
     )
     return parser
예제 #23
0
def _type_uuid(uuid):
    regex = re.compile(
        '^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z',
        re.I)
    if not regex.match(uuid):
        msg = _("%r is not a valid uuid")
        raise exceptions.CommandError(msg % uuid)
    return uuid
예제 #24
0
 def get_parser(self, prog_name):
     parser = super(DeleteRegion, self).get_parser(prog_name)
     parser.add_argument(
         'region',
         metavar='<region-id>',
         help=_('Region ID to delete'),
     )
     return parser
예제 #25
0
 def get_parser(self, prog_name):
     parser = super(ListRegion, self).get_parser(prog_name)
     parser.add_argument(
         '--parent-region',
         metavar='<region-id>',
         help=_('Filter by parent region ID'),
     )
     return parser
예제 #26
0
 def get_parser(self, prog_name):
     parser = super(ListEC2Creds, self).get_parser(prog_name)
     parser.add_argument(
         '--user',
         metavar='<user>',
         help=_('Filter list by user (name or ID)'),
     )
     return parser
예제 #27
0
파일: token.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(RevokeToken, self).get_parser(prog_name)
     parser.add_argument(
         'token',
         metavar='<token>',
         help=_('Token to be deleted'),
     )
     return parser
예제 #28
0
파일: catalog.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(ShowCatalog, self).get_parser(prog_name)
     parser.add_argument(
         'service',
         metavar='<service>',
         help=_('Service to display (type or name)'),
     )
     return parser
예제 #29
0
파일: service.py 프로젝트: xinni-ge/eclcli
 def get_parser(self, prog_name):
     parser = super(DeleteService, self).get_parser(prog_name)
     parser.add_argument(
         'service',
         metavar='<service>',
         help=_('Service to delete (name or ID)'),
     )
     return parser
예제 #30
0
 def get_parser(self, prog_name):
     parser = super(UnsetProject, self).get_parser(prog_name)
     parser.add_argument(
         'project',
         metavar='<project>',
         help=_('Project to modify (name or ID)'),
     )
     parser.add_argument(
         '--property',
         metavar='<key>',
         action='append',
         default=[],
         help=_('Unset a project property '
                '(repeat option to unset multiple properties)'),
         required=True,
     )
     return parser