├── src
├── extensions
│ ├── COMMANDS
│ │ ├── __init__.py
│ │ ├── REQUIREDCOMMANDS
│ │ │ ├── __init__.py
│ │ │ ├── ExitCommand.py
│ │ │ └── HelpCommand.py
│ │ ├── LogoutCommand.py
│ │ ├── CommitCommand.py
│ │ ├── StatusCommand.py
│ │ ├── TypesCommand.py
│ │ └── SelectCommand.py
│ ├── RAW COMMANDS
│ │ ├── __init__.py
│ │ ├── RawHeadCommand.py
│ │ ├── RawPutCommand.py
│ │ ├── RawDeleteCommand.py
│ │ ├── RawPostCommand.py
│ │ ├── RawPatchCommand.py
│ │ └── RawGetCommand.py
│ └── __init__.py
├── versioning.py
└── rdmc_base_classes.py
├── docs
└── slate
│ ├── source
│ ├── includes
│ │ ├── _commands.md
│ │ ├── _overview.md
│ │ ├── _installation.md
│ │ ├── _support.md
│ │ ├── _macrocommandsandscripts.md
│ │ ├── _errors.md
│ │ └── _usage.md
│ ├── fonts
│ │ ├── slate.eot
│ │ ├── slate.ttf
│ │ ├── slate.woff
│ │ ├── slate.woff2
│ │ └── slate.svg
│ ├── images
│ │ ├── logo.png
│ │ ├── navbar.png
│ │ ├── FileBasedMode_1.png
│ │ ├── checkbox-small.png
│ │ └── InteractiveMode_1.png
│ ├── javascripts
│ │ ├── all_nosearch.js
│ │ ├── all.js
│ │ ├── app
│ │ │ ├── _toc.js
│ │ │ ├── _search.js
│ │ │ └── _lang.js
│ │ └── lib
│ │ │ ├── _jquery.highlight.js
│ │ │ ├── _energize.js
│ │ │ └── _imagesloaded.min.js
│ ├── index.html.md
│ ├── stylesheets
│ │ ├── _icon-font.scss
│ │ ├── print.css.scss
│ │ ├── _variables.scss
│ │ └── _normalize.scss
│ └── layouts
│ │ └── layout.erb
│ ├── .travis.yml
│ ├── Gemfile
│ ├── .gitignore
│ ├── .github
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── ISSUE_TEMPLATE.md
│ ├── LICENSE
│ ├── config.rb
│ ├── Vagrantfile
│ ├── CHANGELOG.md
│ ├── Readme.txt
│ ├── Gemfile.lock
│ ├── font-selection.json
│ ├── README.md
│ └── deploy.sh
├── .settings
└── org.eclipse.core.resources.prefs
├── .gitignore
├── CHANGELOG.md
├── .pydevproject
├── .project
├── AUTHORS.md
├── redfish.conf
├── LICENSE.md
├── rdmc-pyinstaller-mac.spec
├── rdmc-pyinstaller-lin.spec
├── rdmc-pyinstaller-windows.spec
├── README.rst
└── extension_template
└── NewCommand.py
/src/extensions/COMMANDS/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/REQUIREDCOMMANDS/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/slate/source/includes/_commands.md:
--------------------------------------------------------------------------------
1 | # Commands for the Redfish Utility
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/rdmc.py=utf-8
3 |
--------------------------------------------------------------------------------
/docs/slate/source/fonts/slate.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/fonts/slate.eot
--------------------------------------------------------------------------------
/docs/slate/source/fonts/slate.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/fonts/slate.ttf
--------------------------------------------------------------------------------
/docs/slate/source/fonts/slate.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/fonts/slate.woff
--------------------------------------------------------------------------------
/docs/slate/source/fonts/slate.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/fonts/slate.woff2
--------------------------------------------------------------------------------
/docs/slate/source/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/images/logo.png
--------------------------------------------------------------------------------
/docs/slate/source/images/navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/images/navbar.png
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/all_nosearch.js:
--------------------------------------------------------------------------------
1 | //= require ./lib/_energize
2 | //= require ./app/_lang
3 | //= require ./app/_toc
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 |
5 | src/redfish.log
6 | /build
7 | /dist
8 |
9 | .settings
--------------------------------------------------------------------------------
/docs/slate/source/images/FileBasedMode_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/images/FileBasedMode_1.png
--------------------------------------------------------------------------------
/docs/slate/source/images/checkbox-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/images/checkbox-small.png
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/all.js:
--------------------------------------------------------------------------------
1 | //= require ./lib/_energize
2 | //= require ./app/_lang
3 | //= require ./app/_search
4 | //= require ./app/_toc
5 |
--------------------------------------------------------------------------------
/docs/slate/source/images/InteractiveMode_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMTF/python-redfish-utility/HEAD/docs/slate/source/images/InteractiveMode_1.png
--------------------------------------------------------------------------------
/docs/slate/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 |
3 | language: ruby
4 |
5 | rvm:
6 | - 2.0.0
7 | - 2.1.0
8 |
9 | cache: bundler
10 | script: bundle exec middleman build
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [1.0.1] - 2018-05-25
4 | - Made changes to support both Python2 and Python3
5 |
6 | ## [1.0.0] - 2017-01-12
7 | - Initial Public Release -- supports Redfish 1.0 features
8 |
--------------------------------------------------------------------------------
/docs/slate/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # Middleman
4 | gem 'middleman', '~>4.0.0'
5 | gem 'middleman-gh-pages', '~> 0.0.3'
6 | gem 'middleman-syntax', '~> 2.1.0'
7 | gem 'middleman-autoprefixer', '~> 2.7.0'
8 | gem "middleman-sprockets", "~> 4.0.0.rc"
9 | gem 'rouge', '~> 1.10.1'
10 | gem 'redcarpet', '~> 3.3.2'
11 |
--------------------------------------------------------------------------------
/docs/slate/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | coverage
6 | InstalledFiles
7 | lib/bundler/man
8 | pkg
9 | rdoc
10 | spec/reports
11 | test/tmp
12 | test/version_tmp
13 | tmp
14 | *.DS_STORE
15 | build/
16 | .cache
17 | .vagrant
18 | .sass-cache
19 |
20 | # YARD artifacts
21 | .yardoc
22 | _yardoc
23 | doc/
24 | .idea/
25 |
--------------------------------------------------------------------------------
/docs/slate/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Make sure you've checked off all these things before submitting:
2 |
3 | - [ ] This pull request isn't for a company's fork, it's intended for the upstream Slate shared by everybody.
4 | - [ ] This pull request is submitted to the `dev` branch.
5 | - [ ] If it makes frontend changes, this pull request has been tested in the latest version of Firefox, Chrome, IE, and Safari.
6 |
--------------------------------------------------------------------------------
/docs/slate/source/includes/_overview.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | The Redfish Utility is a command line interface that allows you to manage servers that take advantage of Redfish APIs. For this release of the utility, you can manage any server running a Redfish API. You can install the utility on your computer for remote use. In addition to using the utility manually to execute individual commands, you can create scripts to automate tasks.
--------------------------------------------------------------------------------
/src/versioning.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ Version strings for the utility """
8 |
9 | __version__ = '1.0.1'
10 | __shortname__ = 'redfish'
11 | __longname__ = 'Redfish Utility'
12 | __extracontent__ = ''
13 |
--------------------------------------------------------------------------------
/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | /${PROJECT_DIR_NAME}/src
5 |
6 | python 2.7
7 | Default
8 |
9 |
--------------------------------------------------------------------------------
/docs/slate/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | If this is a question or feature request, make sure to:
2 |
3 | - [ ] The title starts with `Question:` or `Feature:`.
4 |
5 | If this is an bug report, not a question, make sure to:
6 |
7 | - [ ] I'm not running Windows (which is unsupported), or if I am, I can confirm this issue appears on another platform, or Vagrant.
8 | - [ ] This issue appears in the latest `dev` branch.
9 | - [ ] I've included my browser and Ruby version in this issue.
10 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | rdmc
4 |
5 |
6 | redfish
7 |
8 |
9 |
10 | org.python.pydev.PyDevBuilder
11 |
12 |
13 |
14 |
15 |
16 | org.python.pydev.pythonNature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/slate/source/index.html.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Redfish Utility 1.0 User Guide
3 |
4 | language_tabs:
5 | - shell: Shell
6 |
7 | toc_footers:
8 | - Distributed Management Task Force, Inc.
9 | - Copyright © 2016
10 |
11 | includes:
12 | - overview
13 | - installation
14 | - usage
15 | - commands
16 | - globalcommands
17 | - rawcommands
18 | - macrocommandsandscripts
19 | - support
20 | - errors
21 |
22 | search: true
23 | ---
24 |
25 |
26 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | # Original Contribution:
2 |
3 | * [Jack Garcia](//github.com/lumbajack) - HPE - Hewlett Packard Enterprise Restful API Group
4 | * [Matthew Kocurek](//github.com/Yergidy) - HPE - Hewlett Packard Enterprise Restful API Group
5 | * [Prithvi Subrahmanya](//github.com/PrithviBS) - HPE - Hewlett Packard Enterprise Restful API Group
6 |
7 | # Other Key Contributions:
8 |
9 | * For a list of people who have contributed to the codebase, see [GitHub's list of contributors](https://github.com/DMTF/python-redfish-utility/contributors).*
10 |
--------------------------------------------------------------------------------
/docs/slate/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2008-2013 Concur Technologies, Inc.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may
4 | not use this file except in compliance with the License. You may obtain
5 | a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 | License for the specific language governing permissions and limitations
13 | under the License.
--------------------------------------------------------------------------------
/docs/slate/source/stylesheets/_icon-font.scss:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'slate';
3 | src:font-url('slate.eot?-syv14m');
4 | src:font-url('slate.eot?#iefix-syv14m') format('embedded-opentype'),
5 | font-url('slate.woff2?-syv14m') format('woff2'),
6 | font-url('slate.woff?-syv14m') format('woff'),
7 | font-url('slate.ttf?-syv14m') format('truetype'),
8 | font-url('slate.svg?-syv14m#slate') format('svg');
9 | font-weight: normal;
10 | font-style: normal;
11 | }
12 |
13 | %icon {
14 | font-family: 'slate';
15 | speak: none;
16 | font-style: normal;
17 | font-weight: normal;
18 | font-variant: normal;
19 | text-transform: none;
20 | line-height: 1;
21 | }
22 |
23 | %icon-exclamation-sign {
24 | @extend %icon;
25 | content: "\e600";
26 | }
27 | %icon-info-sign {
28 | @extend %icon;
29 | content: "\e602";
30 | }
31 | %icon-ok-sign {
32 | @extend %icon;
33 | content: "\e606";
34 | }
35 | %icon-search {
36 | @extend %icon;
37 | content: "\e607";
38 | }
39 |
--------------------------------------------------------------------------------
/src/extensions/__init__.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | import os
8 | import sys
9 | tl = []
10 | classNames = []
11 | _Commands = {}
12 |
13 | extensionDir = os.path.dirname(__file__)
14 |
15 | if os.name != 'nt':
16 | replacement = '/'
17 | else:
18 | replacement = '\\'
19 |
20 | for (cwd, dirs, filenames) in os.walk(extensionDir):
21 | dirs[:] = [d for d in dirs if not d[0] == '.']
22 | tl.append((cwd, [files for files in filenames if not files[0] == '.']))
23 |
24 | for cwd, names in tl:
25 | cn = cwd.split('extensions')[-1]
26 | cn = cn.replace(replacement, '.')
27 | for name in names:
28 | if name.endswith('.py') and '__' not in name:
29 | name = name.replace('.py', '')
30 | classNames.append(cn+'.'+name+'.'+name)
--------------------------------------------------------------------------------
/docs/slate/config.rb:
--------------------------------------------------------------------------------
1 | # Markdown
2 | set :markdown_engine, :redcarpet
3 | set :markdown,
4 | fenced_code_blocks: true,
5 | smartypants: true,
6 | disable_indented_code_blocks: true,
7 | prettify: true,
8 | tables: true,
9 | with_toc_data: true,
10 | no_intra_emphasis: true
11 |
12 | # Assets
13 | set :css_dir, 'stylesheets'
14 | set :js_dir, 'javascripts'
15 | set :images_dir, 'images'
16 | set :fonts_dir, 'fonts'
17 |
18 | # Activate the syntax highlighter
19 | activate :syntax
20 |
21 | activate :autoprefixer do |config|
22 | config.browsers = ['last 2 version', 'Firefox ESR']
23 | config.cascade = false
24 | config.inline = true
25 | end
26 |
27 | # Github pages require relative links
28 | activate :relative_assets
29 | set :relative_links, true
30 |
31 | # Build Configuration
32 | configure :build do
33 | # If you're having trouble with Middleman hanging, commenting
34 | # out the following two lines has been known to help
35 | activate :minify_css
36 | activate :minify_javascript
37 | # activate :relative_assets
38 | # activate :asset_hash
39 | # activate :gzip
40 | end
41 |
42 | # Deploy Configuration
43 | # If you want Middleman to listen on a different port, you can set that below
44 | set :port, 4567
45 |
--------------------------------------------------------------------------------
/docs/slate/source/includes/_installation.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | ## Requirements
4 |
5 | The following is a list of requirements for the server you want to manage with the utility:
6 |
7 | - Remote management: Redfish compatable server with or without an OS installed.
8 |
9 | ### Installing the Redfish Utility
10 |
11 | The following installation steps describe how to install the utility on a Windows OS or Linux OS.
12 | #### Windows
13 | 1. Download the Redfish Utility (Windows MSI package) from [utilitydownloadlocation]().
14 | 2. Install the package on a laptop or server that has access to the managed server network.
15 |
16 | #### Linux
17 | 1. Download the Redfish Utility (Linux RPM package) from [utilitydownloadlocation]().
18 | 2. Install the package on a laptop or server that has access to the managed server network.
19 |
20 | ### Starting the Redfish Utility
21 |
22 | #### Windows
23 | 1. Click the Start menu.
24 | 2. Click **placeholder location** → **Redfish Utility**.
25 | 3. Right-click the **Redfish Utility** prompt, and then click **Run as Administrator**.
26 |
27 | #### Linux
28 | 1. Open a terminal window.
29 | 2. To start interactive mode, run the command **/usr/sbin/redfish** (using administrator privileges).
30 |
31 |
--------------------------------------------------------------------------------
/docs/slate/source/includes/_support.md:
--------------------------------------------------------------------------------
1 | # Resources
2 |
3 | ## Websites and documents
4 |
5 | ### Websites
6 |
7 | Website | Link
8 | --------|-------
9 | Distributed Management Task Force Inc. Website | [https://www.dmtf.org/]([https://www.dmtf.org/)
10 | DMTF GitHub | [https://github.com/DMTF](https://github.com/DMTF)
11 | DMTF YouTube | [https://www.youtube.com/c/DmtfOrg](https://www.youtube.com/c/DmtfOrg)
12 | Join Scalable Platforms Management Forum (SPMF) | [http://www.dmtf.org/join/spmf](http://www.dmtf.org/join/spmf)
13 | Redfish(TM) API | [https://www.dmtf.org/standards/redfish](https://www.dmtf.org/standards/redfish)
14 | Redfish(TM) Developer Hub | [http://redfish.dmtf.org/](http://redfish.dmtf.org/)
15 | Redfish(TM) User Forum | [http://redfishforum.com/](http://redfishforum.com/)
16 | Redfish(TM) Mockups | [http://redfish.dmtf.org/redfish/v1/mockup/](http://redfish.dmtf.org/redfish/v1/mockup/)
17 | Redfish(TM) Schema Index | [http://redfish.dmtf.org/redfish/schema_index](http://redfish.dmtf.org/redfish/schema_index)
18 |
19 |
20 | ### Documents
21 |
22 | - [Redfish(TM) Scalable Platforms Management API Specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.0.0.pdf)
23 | - [Redfish(TM) FAQ](https://www.dmtf.org/sites/default/files/standards/documents/DSP2045_1.0.0.pdf)
24 |
--------------------------------------------------------------------------------
/redfish.conf:
--------------------------------------------------------------------------------
1 | [redfish]
2 | #The Redfish Utility reads the following environment variables, and applies them at runtime.
3 | #Note that they can be overridden by command line switches.
4 |
5 | ##### Cache Settings #####
6 | ##########################################
7 | # option to disable caching of all data
8 | #cache = False
9 |
10 | ##### Credential Settings #####
11 | ##########################################
12 | # option to use the provided url to login
13 | #url = https://127.0.0.1
14 |
15 | # option to use the provided username to login
16 | #username = admin
17 |
18 | # option to use the provided password to login
19 | #password = password
20 |
21 | ##### Commit Settings #####
22 | ##########################################
23 | # flag to commit in all places where applicable
24 | #commit = True
25 |
26 | ##### Output Default Settings #####
27 | ##########################################
28 | # flag to change output format in all places where applicable
29 | #format = json
30 |
31 | ##### Default Save/Load Settings #####
32 | ##########################################
33 | # option to set default save output file
34 | #savefile = redfish.json
35 |
36 | # option to set default load input file
37 | #loadfile = redfish.json
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/docs/slate/Vagrantfile:
--------------------------------------------------------------------------------
1 | Vagrant.configure(2) do |config|
2 | config.vm.box = "ubuntu/trusty64"
3 | config.vm.network :forwarded_port, guest: 4567, host: 4567
4 |
5 | config.vm.provision "bootstrap",
6 | type: "shell",
7 | inline: <<-SHELL
8 | sudo apt-get update
9 | sudo apt-get install -yq ruby2.0 ruby2.0-dev pkg-config build-essential nodejs git libxml2-dev libxslt-dev
10 | sudo apt-get autoremove -yq
11 | gem2.0 install --no-ri --no-rdoc bundler
12 | SHELL
13 |
14 | # add the local user git config to the vm
15 | config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
16 |
17 | config.vm.provision "install",
18 | type: "shell",
19 | privileged: false,
20 | inline: <<-SHELL
21 | echo "=============================================="
22 | echo "Installing app dependencies"
23 | cd /vagrant
24 | bundle config build.nokogiri --use-system-libraries
25 | bundle install
26 | SHELL
27 |
28 | config.vm.provision "run",
29 | type: "shell",
30 | privileged: false,
31 | run: "always",
32 | inline: <<-SHELL
33 | echo "=============================================="
34 | echo "Starting up middleman at http://localhost:4567"
35 | echo "If it does not come up, check the ~/middleman.log file for any error messages"
36 | cd /vagrant
37 | bundle exec middleman server --force-polling -l 1 &> ~/middleman.log &
38 | SHELL
39 | end
40 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2016-2024, Contributing Member(s) of Distributed Management Task
4 | Force, Inc.. All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification,
7 | are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation and/or
14 | other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its contributors
17 | may be used to endorse or promote products derived from this software without
18 | specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/app/_toc.js:
--------------------------------------------------------------------------------
1 | //= require ../lib/_jquery
2 | //= require ../lib/_jquery_ui
3 | //= require ../lib/_jquery.tocify
4 | //= require ../lib/_imagesloaded.min
5 | (function (global) {
6 | 'use strict';
7 |
8 | var closeToc = function() {
9 | $(".tocify-wrapper").removeClass('open');
10 | $("#nav-button").removeClass('open');
11 | };
12 |
13 | var makeToc = function() {
14 | global.toc = $("#toc").tocify({
15 | selectors: 'h1, h2, h3',
16 | extendPage: false,
17 | theme: 'none',
18 | smoothScroll: false,
19 | showEffectSpeed: 0,
20 | hideEffectSpeed: 180,
21 | ignoreSelector: '.toc-ignore',
22 | highlightOffset: 60,
23 | scrollTo: -1,
24 | scrollHistory: true,
25 | hashGenerator: function (text, element) {
26 | return element.prop('id');
27 | }
28 | }).data('toc-tocify');
29 |
30 | $("#nav-button").click(function() {
31 | $(".tocify-wrapper").toggleClass('open');
32 | $("#nav-button").toggleClass('open');
33 | return false;
34 | });
35 |
36 | $(".page-wrapper").click(closeToc);
37 | $(".tocify-item").click(closeToc);
38 | };
39 |
40 | // Hack to make already open sections to start opened,
41 | // instead of displaying an ugly animation
42 | function animate() {
43 | setTimeout(function() {
44 | toc.setOption('showEffectSpeed', 180);
45 | }, 50);
46 | }
47 |
48 | $(function() {
49 | makeToc();
50 | animate();
51 | setupLanguages($('body').data('languages'));
52 | $('.content').imagesLoaded( function() {
53 | global.toc.calculateHeights();
54 | });
55 | });
56 | })(window);
57 |
58 |
--------------------------------------------------------------------------------
/rdmc-pyinstaller-mac.spec:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- mode: python -*-
8 | import os
9 |
10 | block_cipher = None
11 |
12 | def hiddenImportGet():
13 | tl = []
14 | classNames = []
15 | _Commands = {}
16 |
17 | extensionDir = os.path.dirname(os.getcwd()+ '/src')
18 |
19 | replacement = '/'
20 |
21 | for (cwd, dirs, filenames) in os.walk(extensionDir):
22 | dirs[:] = [d for d in dirs if not d[0] == '.']
23 | tl.append((cwd,[files for files in filenames if not files[0] == '.']))
24 |
25 | for cwd, names in tl:
26 | cn = cwd.split('extensions')[-1]
27 | cn = cn.replace(replacement, '.')
28 | for name in names:
29 | if '.pyc' not in name and '__init__' not in name:
30 | name = name.replace('.py', '')
31 | classNames.append('extensions'+cn+'.'+name)
32 | return classNames
33 |
34 | a = Analysis(['.//src//rdmc.py'],
35 | pathex=[],
36 | binaries=None,
37 | datas=[('.//src//extensions', 'extensions')],
38 | hiddenimports=hiddenImportGet(),
39 | hookspath=[],
40 | runtime_hooks=[],
41 | excludes=[],
42 | cipher=block_cipher)
43 |
44 |
45 | pyz = PYZ(a.pure)
46 | exe = EXE(pyz,
47 | a.scripts,
48 | a.binaries,
49 | a.zipfiles,
50 | a.datas,
51 | name='redfish',
52 | debug=False,
53 | strip=None,
54 | upx=True,
55 | icon='',
56 | console=True )
57 |
--------------------------------------------------------------------------------
/rdmc-pyinstaller-lin.spec:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- mode: python -*-
8 | import os
9 |
10 | block_cipher = None
11 |
12 | def hiddenImportGet():
13 | tl = []
14 | classNames = []
15 | _Commands = {}
16 |
17 | extensionDir = os.path.dirname(os.getcwd()+ '/src')
18 |
19 | replacement = '/'
20 |
21 | for (cwd, dirs, filenames) in os.walk(extensionDir):
22 | dirs[:] = [d for d in dirs if not d[0] == '.']
23 | tl.append((cwd,[files for files in filenames if not files[0] == '.']))
24 |
25 | for cwd, names in tl:
26 | cn = cwd.split('extensions')[-1]
27 | cn = cn.replace(replacement, '.')
28 | for name in names:
29 | if '.pyc' not in name and '__init__' not in name:
30 | name = name.replace('.py', '')
31 | classNames.append('extensions'+cn+'.'+name)
32 | return classNames
33 |
34 | a = Analysis(['.//src//rdmc.py'],
35 | pathex=[],
36 | binaries=None,
37 | datas=[('.//src//extensions', 'extensions')],
38 | hiddenimports=hiddenImportGet(),
39 | hookspath=[],
40 | runtime_hooks=[],
41 | excludes=[],
42 | cipher=block_cipher)
43 |
44 | pyz = PYZ(a.pure, a.zipped_data,
45 | cipher=block_cipher)
46 | exe = EXE(pyz,
47 | a.scripts,
48 | a.binaries,
49 | a.zipfiles,
50 | a.datas,
51 | name='redfish',
52 | debug=False,
53 | strip=False,
54 | upx=True,
55 | icon = '',
56 | console=True )
57 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/REQUIREDCOMMANDS/ExitCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ Exit Command for rdmc """
8 |
9 | import sys
10 |
11 | from rdmc_base_classes import RdmcCommandBase
12 | from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS
13 |
14 | class ExitCommand(RdmcCommandBase):
15 | """ Exit class to handle exiting from interactive mode """
16 | def __init__(self, rdmcObj):
17 | RdmcCommandBase.__init__(self,\
18 | name='exit',\
19 | usage='exit\n\n\tRun to exit from the interactive shell\n\t' \
20 | 'example: exit',\
21 | summary='Exits from the interactive shell.',\
22 | aliases=['quit'])
23 |
24 | self._rdmc = rdmcObj
25 | self.logoutobj = rdmcObj.commandsDict["LogoutCommand"](rdmcObj)
26 |
27 | def run(self, line):
28 | """If an argument is present, print help else exit
29 |
30 | :param line: command line input
31 | :type line: string.
32 | """
33 | try:
34 | (_, args) = self._parse_arglist(line)
35 | except:
36 | if ("-h" in line) or ("--help" in line):
37 | return ReturnCodes.SUCCESS
38 | else:
39 | raise InvalidCommandLineErrorOPTS("")
40 |
41 | if args is None or len(args) == 0 or not line:
42 | self.logoutobj.run("")
43 | sys.stdout.write('Bye for now\n')
44 |
45 | #System exit
46 | sys.exit(ReturnCodes.SUCCESS)
47 | else:
48 | sys.stderr.write("Exit command does not take any parameters.\n")
49 | raise InvalidCommandLineErrorOPTS("Invalid command line arguments.")
--------------------------------------------------------------------------------
/rdmc-pyinstaller-windows.spec:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- mode: python -*-
8 | import os
9 |
10 | block_cipher = None
11 |
12 | def hiddenImportGet():
13 | tl = []
14 | classNames = []
15 | _Commands = {}
16 |
17 | extensionDir = os.path.dirname(os.getcwd()+ '\\src')
18 |
19 | if os.name != 'nt':
20 | replacement = '/'
21 | else:
22 | replacement = '\\'
23 |
24 | for (cwd, dirs, filenames) in os.walk(extensionDir):
25 | dirs[:] = [d for d in dirs if not d[0] == '.']
26 | tl.append((cwd,[files for files in filenames if not files[0] == '.']))
27 |
28 | for cwd, names in tl:
29 | cn = cwd.split('extensions')[-1]
30 | cn = cn.replace(replacement, '.')
31 | for name in names:
32 | if '.pyc' not in name and '__init__' not in name:
33 | name = name.replace('.py', '')
34 | classNames.append('extensions'+cn+'.'+name)
35 | return classNames
36 |
37 | a = Analysis(['.\\src\\rdmc.py'],
38 | pathex=['.\\src'],
39 | binaries=None,
40 | datas=[('.\\src\\extensions', 'extensions')],
41 | hiddenimports=hiddenImportGet(),
42 | hookspath=[],
43 | runtime_hooks=[],
44 | excludes=[],
45 | win_no_prefer_redirects=False,
46 | win_private_assemblies=False,
47 | cipher=block_cipher)
48 |
49 |
50 |
51 | pyz = PYZ(a.pure, a.zipped_data,
52 | cipher=block_cipher)
53 | exe = EXE(pyz,
54 | a.scripts,
55 | a.binaries,
56 | a.zipfiles,
57 | a.datas,
58 | name='redfish',
59 | debug=False,
60 | strip=False,
61 | upx=True,
62 | icon = '',
63 | console=True )
--------------------------------------------------------------------------------
/docs/slate/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## Version 1.3.3
4 |
5 | *June 11, 2016*
6 |
7 | Documentation and example changes.
8 |
9 | ## Version 1.3.2
10 |
11 | *February 3, 2016*
12 |
13 | A small bugfix for slightly incorrect background colors on code samples in some cases.
14 |
15 | ## Version 1.3.1
16 |
17 | *January 31, 2016*
18 |
19 | A small bugfix for incorrect whitespace in code blocks.
20 |
21 | ## Version 1.3
22 |
23 | *January 27, 2016*
24 |
25 | We've upgraded Middleman and a number of other dependencies, which should fix quite a few bugs.
26 |
27 | Instead of `rake build` and `rake deploy`, you should now run `bundle exec middleman build --clean` to build your server, and `./deploy.sh` to deploy it to Github Pages.
28 |
29 | ## Version 1.2
30 |
31 | *June 20, 2015*
32 |
33 | **Fixes:**
34 |
35 | - Remove crash on invalid languages
36 | - Update Tocify to scroll to the highlighted header in the Table of Contents
37 | - Fix variable leak and update search algorithms
38 | - Update Python examples to be valid Python
39 | - Update gems
40 | - More misc. bugfixes of Javascript errors
41 | - Add Dockerfile
42 | - Remove unused gems
43 | - Optimize images, fonts, and generated asset files
44 | - Add chinese font support
45 | - Remove RedCarpet header ID patch
46 | - Update language tabs to not disturb existing query strings
47 |
48 | ## Version 1.1
49 |
50 | *July 27, 2014*
51 |
52 | **Fixes:**
53 |
54 | - Finally, a fix for the redcarpet upgrade bug
55 |
56 | ## Version 1.0
57 |
58 | *July 2, 2014*
59 |
60 | [View Issues](https://github.com/tripit/slate/issues?milestone=1&state=closed)
61 |
62 | **Features:**
63 |
64 | - Responsive designs for phones and tablets
65 | - Started tagging versions
66 |
67 | **Fixes:**
68 |
69 | - Fixed 'unrecognized expression' error
70 | - Fixed #undefined hash bug
71 | - Fixed bug where the current language tab would be unselected
72 | - Fixed bug where tocify wouldn't highlight the current section while searching
73 | - Fixed bug where ids of header tags would have special characters that caused problems
74 | - Updated layout so that pages with disabled search wouldn't load search.js
75 | - Cleaned up Javascript
76 |
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/app/_search.js:
--------------------------------------------------------------------------------
1 | //= require ../lib/_lunr
2 | //= require ../lib/_jquery
3 | //= require ../lib/_jquery.highlight
4 | (function () {
5 | 'use strict';
6 |
7 | var content, searchResults;
8 | var highlightOpts = { element: 'span', className: 'search-highlight' };
9 |
10 | var index = new lunr.Index();
11 |
12 | index.ref('id');
13 | index.field('title', { boost: 10 });
14 | index.field('body');
15 | index.pipeline.add(lunr.trimmer, lunr.stopWordFilter);
16 |
17 | $(populate);
18 | $(bind);
19 |
20 | function populate() {
21 | $('h1, h2').each(function() {
22 | var title = $(this);
23 | var body = title.nextUntil('h1, h2');
24 | index.add({
25 | id: title.prop('id'),
26 | title: title.text(),
27 | body: body.text()
28 | });
29 | });
30 | }
31 |
32 | function bind() {
33 | content = $('.content');
34 | searchResults = $('.search-results');
35 |
36 | $('#input-search').on('keyup', search);
37 | }
38 |
39 | function search(event) {
40 | unhighlight();
41 | searchResults.addClass('visible');
42 |
43 | // ESC clears the field
44 | if (event.keyCode === 27) this.value = '';
45 |
46 | if (this.value) {
47 | var results = index.search(this.value).filter(function(r) {
48 | return r.score > 0.0001;
49 | });
50 |
51 | if (results.length) {
52 | searchResults.empty();
53 | $.each(results, function (index, result) {
54 | var elem = document.getElementById(result.ref);
55 | searchResults.append("
" + $(elem).text() + "");
56 | });
57 | highlight.call(this);
58 | } else {
59 | searchResults.html('');
60 | $('.search-results li').text('No Results Found for "' + this.value + '"');
61 | }
62 | } else {
63 | unhighlight();
64 | searchResults.removeClass('visible');
65 | }
66 | }
67 |
68 | function highlight() {
69 | if (this.value) content.highlight(this.value, highlightOpts);
70 | }
71 |
72 | function unhighlight() {
73 | content.unhighlight(highlightOpts);
74 | }
75 | })();
76 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/LogoutCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- coding: utf-8 -*-
8 | """ Logout Command for RDMC """
9 |
10 | import sys
11 |
12 | from optparse import OptionParser
13 | from rdmc_base_classes import RdmcCommandBase
14 |
15 | from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS
16 |
17 | class LogoutCommand(RdmcCommandBase):
18 | """ Constructor """
19 | def __init__(self, rdmcObj):
20 | RdmcCommandBase.__init__(self,\
21 | name='logout',\
22 | usage='logout\n\n\tRun to end the current session and disconnect' \
23 | ' from the server\n\texample: logout',\
24 | summary='Ends the current session and disconnects from the' \
25 | ' server.',\
26 | aliases=[],\
27 | optparser=OptionParser())
28 | self.definearguments(self.parser)
29 | self._rdmc = rdmcObj
30 |
31 | def logoutfunction(self, line):
32 | """ Main logout worker function
33 |
34 | :param line: command line input
35 | :type line: string.
36 | """
37 | try:
38 | (_, _) = self._parse_arglist(line)
39 | except:
40 | if ("-h" in line) or ("--help" in line):
41 | return ReturnCodes.SUCCESS
42 | else:
43 | raise InvalidCommandLineErrorOPTS("")
44 |
45 | self._rdmc.app.logout("")
46 |
47 | def run(self, line):
48 | """ Wrapper function for main logout function
49 |
50 | :param line: command line input
51 | :type line: string.
52 | """
53 | sys.stdout.write("Logging session out.\n")
54 | self.logoutfunction(line)
55 | #Return code
56 | return ReturnCodes.SUCCESS
57 |
58 | def definearguments(self, customparser):
59 | """ Wrapper function for new command main function
60 |
61 | :param customparser: command line input
62 | :type customparser: parser.
63 | """
64 | if not customparser:
65 | return
66 |
67 |
--------------------------------------------------------------------------------
/docs/slate/source/includes/_macrocommandsandscripts.md:
--------------------------------------------------------------------------------
1 | # Script Examples
2 |
3 | The command catalog provided by the Redfish Utility enables a wide variety of options to manipulate and work with the server. Multiple commands chained together have the potential to provide higher-level functionality and meet any needs that arise depending on the task at hand.
4 |
5 |
6 | ## Selecting and getting properties from a type.
7 |
8 | ```
9 | :: selectget.bat [URI] [USERNAME] [PASSWORD]
10 | @echo off
11 |
12 | set argC=0
13 | for %%x in (%*) do Set /A argC+=1
14 | if %argC% LSS 3 goto :failCondition
15 | goto :main
16 |
17 | :failCondition
18 | @echo Usage:
19 | @echo selectget.bat [URI] [USERNAME] [PASSWORD]
20 | goto :EOF
21 |
22 | :main
23 | @echo *****************************************
24 | @echo ************* Logging in... *************
25 | @echo *****************************************
26 | redfish.exe login %1 -u %2 -p %3
27 | @echo *****************************************
28 | @echo *** selecting ComputerSystem type... ****
29 | @echo *****************************************
30 | redfish.exe select ComputerSystem.
31 | @echo *****************************************
32 | @echo ********** getting AssetTag... **********
33 | @echo *****************************************
34 | redfish.exe get AssetTag
35 | pause
36 | ```
37 |
38 | This is a batch file that logs into a remote server, selects the `ComputerSystem` type, and gets the `AssetTag` value.
39 |
40 | ## Saving and loading a file using file-based editing mode
41 |
42 | ```
43 | :: saveload.bat [SELECTOR] [FILENAME]
44 | :: Specify a type with the SELECTOR tag, and
45 | :: save to a file called FILENAME
46 | @echo off
47 | set argC=0
48 | for %%x in (%*) do Set /A argC+=1
49 | if %argC% LSS 2 goto :failCondition
50 | goto :main
51 |
52 | :failCondition
53 | @echo Usage:
54 | @echo saveload.bat [SELECTOR] [FILENAME]
55 | @echo specify a type with the SELECTOR tag, and
56 | @echo save to a file called FILENAME
57 | goto :EOF
58 |
59 | :main
60 | redfish.exe login
61 | redfish.exe save --selector=%1 --json -f %2
62 | @echo Edit the file, then:
63 | pause
64 | redfish.exe load -f %2
65 | ```
66 |
67 | This is a file-based edit mode helper for the Redfish Utility
68 |
69 | 1. Run to download selected type to a file called `redfish.json`
70 |
71 | 2. Edit the `redfish.json` file to make changes.
72 |
73 | 3. Press any key running batch program to continue with program, uploading the newly edited program to the server.
74 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | python-redfish-utility
2 | ==============
3 | .. image:: https://travis-ci.org/DMTF/python-redfish-utility.svg?branch=main
4 | :target: https://travis-ci.org/DMTF/python-redfish-utility
5 | .. image:: https://img.shields.io/github/release/DMTF/python-redfish-utility.svg?maxAge=2592000
6 | :target:
7 | .. image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
8 | :target: https://raw.githubusercontent.com/DMTF/python-redfish-utility/main/LICENSE
9 | .. image:: https://api.codacy.com/project/badge/Grade/1283adc3972d42b4a3ddb9b96660bc07
10 | :target: https://www.codacy.com/app/rexysmydog/python-redfish-utility?utm_source=github.com&utm_medium=referral&utm_content=DMTF/python-redfish-utility&utm_campaign=Badge_Grade
11 |
12 |
13 | .. contents:: :depth: 1
14 |
15 | Description
16 | ----------
17 |
18 | The Redfish Utility is a command line interface that allows you to manage servers that take advantage of Redfish APIs. For this release of the utility, you can manage any server running a Redfish API. You can install the utility on your computer for remote use. In addition to using the utility manually to execute individual commands, you can create scripts to automate tasks.
19 |
20 | Running the utility from command line
21 | ~~~~~~~~~~~~~~~~~~~~~~~~~
22 |
23 | .. code-block:: console
24 |
25 | python.exe rdmc.py
26 |
27 | Building an executable from file source
28 | ~~~~~~~~~~~~~~~~~~~~~~~~~
29 |
30 | For this process you will need to install pyinstaller for python.
31 |
32 | .. code-block:: console
33 |
34 | python.exe pyinstaller rdmc-pyinstaller-windows.spec
35 |
36 | Requirements
37 | ----------
38 | No special requirements.
39 |
40 | Usage
41 | ----------
42 | For further usage please refer to our slate documentation: `https://dmtf.github.io/python-redfish-utility/ `_
43 |
44 | Contributing
45 | ----------
46 |
47 | 1. Fork it!
48 | 2. Create your feature branch: `git checkout -b my-new-feature`
49 | 3. Commit your changes: `git commit -am 'Add some feature'`
50 | 4. Push to the branch: `git push origin my-new-feature`
51 | 5. Submit a pull request :D
52 |
53 | History
54 | ----------
55 |
56 | * 01/12/2017: Initial Commit
57 |
58 | Copyright and License
59 | ---------------------
60 |
61 | Copyright Notice:
62 | Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
63 | License: BSD 3-Clause License. For full text see link: `https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md `_
64 |
--------------------------------------------------------------------------------
/docs/slate/source/includes/_errors.md:
--------------------------------------------------------------------------------
1 | # Error Codes
2 |
3 |
4 |
5 | The Redfish Utility uses the following error codes:
6 |
7 | Error Code | Description
8 | ---------- | -------
9 | 1 | Error occurred while reading the configuration file. See the error message for details.
10 | 2 | Error occurred when user tried to invoke a command that isn't enabled.
11 | 3 | Invalid command line syntax. Use the **-h** parameter for complete command line parameters.
12 | 4 | The input JSON file is in an invalid format.
13 | 5 | Windows User not admin.
14 | 6 | No contents found for operation.
15 | 7 | Invalid File input error.
16 | 8 | No changes made or found.
17 | 9 | No Valid info error.
18 | 10 | Error occurred while parsing user command line inputs. See the error message for details.
19 | 11 | Warning occurred during command line inputs parsing. See the error message for details.
20 | 12 | Invalid individual command usage. Use the **-h** parameter for individual command line parameters.
21 | 13 | Error occurred when user tries to invoke a command that doesn’t exist.
22 | 21 | Occurs when there are no clients active (usually when user hasn't logged in).
23 | 22 | Error occurred when attempting to operate on another instance while logged in.
24 | 23 | Error occurred when attempting to select an instance that does not exist.
25 | 24 | Error occurred when attempting to access an object type without first selecting it.
26 | 25 | Error occurred when attempting to access an object type without first selecting it while using filters.
27 | 26 | Error occurred when attempting to set an object type without first selecting it.
28 | 27 | Error occurred when selection argument fails to match anything.
29 | 28 | Error occurred when validating user input against schema files.
30 | 30 | RIS session expired.
31 | 31 | Error occurred when retry attempts to reach the selected server have been exhausted.
32 | 32 | Occurs when invalid credentials have been provided.
33 | 33 | Error occurred when correct credentials have been provided and server is unresponsive.
34 | 36 | Error occurred due to an unexpected response.
35 | 40 | Same settings error.
36 | 44 | No current session established.
37 | 45 | Failure during commit operation
38 | 51 | Multiple server configuration failure
39 | 52 | Multiple server input file error.
40 | 53 | Load skip setting error.
41 | 61 | Error occurred when trying to change a value.
42 | 62 | The requested path was not found.
43 | 255 | A general error occurred while manipulating server settings. See the error message for details
44 |
--------------------------------------------------------------------------------
/docs/slate/Readme.txt:
--------------------------------------------------------------------------------
1 | This is the slate build for the HPE RESTful Interface Tool Documentation website.
2 | ========================================
3 | It's based on Slate.
4 |
5 | run these commands locally (in this folder) to start:
6 | bundle install
7 | bundle exec middleman server
8 |
9 | Note: There may be some dependencies that your Ruby needs to download. This is supported in Linux or OS X.
10 | Windows may work, but is unsupported.
11 |
12 | You can now see the docs at:
13 |
14 | http://localhost:4567
15 |
16 | Building the Website
17 | =========================
18 | run in this directory:
19 | bundle exec middleman build --clean
20 |
21 | This creates a folder named "build" with the static HTML files that need to be uploaded.
22 |
23 | Structure of Docs
24 | =========================
25 | Everything is written in Markdown.
26 |
27 | index.html.md is the CORE file. Everything else is written and placed in the "includes" folder.
28 |
29 | The order shown in the "includes:" subheader is the order the pages are inserted.
30 |
31 | # Header 1
32 | ## Header 2
33 | ### Header 3
34 | #### Header 4
35 |
36 | Headers 1-4 are divided on the left's Table of Contents for ease of locating.
37 |
38 | All new markdown files MUST have an underscore. i.e. "_example.md". In the index.html.md this is referenced:
39 | - example
40 |
41 | Note: the underscore is not included when listing it in the index.html.md file.
42 |
43 | A markdown file DOES NOT have to begin with Header 1. If it starts with a subheader,
44 | it will be loaded into the last section found.
45 |
46 | Formatting Codeblocks
47 | =========================
48 | For these docs, use ```code here```, instead of:
49 | ```shell
50 | code here
51 | ```
52 |
53 | Some of our commands don't do very well with the Shell auto-highlighting/formatting.
54 |
55 | Aside tags
56 | =========================
57 | Aside tags can be used for info, notice, warning (classes).
58 | Also, note that within the tag, it becomes HTML, and no longer markdown, so use to bold, etc.
59 |
60 | Customization
61 | ==========================
62 | Basic changes to sizes, padding and colors are in 'variables.scss' in the stylesheets folder.
63 |
64 | Other places to make changes are:
65 | 'screen.css.scss'
66 | 'print.css.scss'
67 |
68 | Uploading to Github Pages
69 | ==========================
70 | Put the files from the 'build' folder into the gh-pages branch in the hprest repo. Make sure the main page is called index.html!
71 |
72 | Uploading to Your Own Server
73 | =============================
74 | bundle exec middleman build --clean
75 |
76 | Slate Documentation Links
77 | ==========================
78 | https://github.com/lord/slate/wiki
--------------------------------------------------------------------------------
/docs/slate/source/fonts/slate.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/REQUIREDCOMMANDS/HelpCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ Help Command for RDMC """
8 |
9 | import sys
10 |
11 | from optparse import OptionParser
12 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
13 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
14 | InvalidCommandLineErrorOPTS
15 |
16 | class HelpCommand(RdmcCommandBase):
17 | """ Constructor """
18 | def __init__(self, **kwargs):
19 | RdmcCommandBase.__init__(self,\
20 | name='help',\
21 | usage='help [COMMAND]\n\n\tFor more detailed command descriptions' \
22 | ' use the help command feature\n\texample: help login',\
23 | summary='Displays command line syntax and'\
24 | ' help menus for individual commands.'\
25 | ' Example: help login',\
26 | aliases=[],\
27 | optparser=OptionParser())
28 | self.config_required = False
29 | self._rdmc = None
30 | if 'rdmc' in kwargs:
31 | self._rdmc = kwargs['rdmc']
32 |
33 | def run(self, line):
34 | """ Wrapper function for help main function
35 |
36 | :param line: command line input
37 | :type line: string.
38 | """
39 | try:
40 | (_, args) = self._parse_arglist(line)
41 | except:
42 | if ("-h" in line) or ("--help" in line):
43 | return ReturnCodes.SUCCESS
44 | else:
45 | raise InvalidCommandLineErrorOPTS("")
46 |
47 | if args is None or len(args) == 0 or not line:
48 | RdmcOptionParser().print_help()
49 | if self._rdmc:
50 | cmddict = self._rdmc.get_commands()
51 | sorted_keys = sorted(list(cmddict.keys()))
52 |
53 | for key in sorted_keys:
54 | if key[0] == '_':
55 | continue
56 | else:
57 | sys.stdout.write('\n%s\n' % key)
58 |
59 | for cmd in cmddict[key]:
60 | cmd.print_summary()
61 | else:
62 | if self._rdmc:
63 | cmddict = self._rdmc.get_commands()
64 | sorted_keys = list(cmddict.keys())
65 | for key in sorted_keys:
66 | for cmd in cmddict[key]:
67 | if cmd.ismatch(args[0]):
68 | cmd.print_help()
69 | return
70 |
71 | raise InvalidCommandLineError("Command '%s' not found." % args[0])
72 | #Return code
73 | return ReturnCodes.SUCCESS
74 |
75 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/CommitCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ Commit Command for RDMC """
8 |
9 | import sys
10 |
11 | from optparse import OptionParser
12 | from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, \
13 | NoChangesFoundOrMadeError, NoCurrentSessionEstablished
14 |
15 | from rdmc_base_classes import RdmcCommandBase
16 |
17 | class CommitCommand(RdmcCommandBase):
18 | """ Constructor """
19 | def __init__(self, rdmcObj):
20 | RdmcCommandBase.__init__(self,\
21 | name='commit',\
22 | usage='commit [OPTIONS]\n\n\tRun to apply all changes made during the' \
23 | ' current session\n\texample: commit',\
24 | summary='Applies all the changes made during the current' \
25 | ' session.',\
26 | aliases=[],\
27 | optparser=OptionParser())
28 | self.definearguments(self.parser)
29 | self._rdmc = rdmcObj
30 | self.logoutobj = rdmcObj.commandsDict["LogoutCommand"](rdmcObj)
31 |
32 | def commitfunction(self, options=None):
33 | """ Main commit worker function
34 |
35 | :param options: command line options
36 | :type options: list.
37 | """
38 | self.commitvalidation()
39 |
40 | sys.stdout.write("Committing changes...\n")
41 |
42 | if not self._rdmc.app.commit(verbose=self._rdmc.opts.verbose):
43 | raise NoChangesFoundOrMadeError("No changes found or made " \
44 | "during commit operation.")
45 |
46 | self.logoutobj.logoutfunction("")
47 |
48 | def run(self, line):
49 | """ Wrapper function for commit main function
50 |
51 | :param line: command line input
52 | :type line: string.
53 | """
54 | try:
55 | (options, _) = self._parse_arglist(line)
56 | except:
57 | if ("-h" in line) or ("--help" in line):
58 | return ReturnCodes.SUCCESS
59 | else:
60 | raise InvalidCommandLineErrorOPTS("")
61 |
62 | self.commitfunction(options)
63 |
64 | #Return code
65 | return ReturnCodes.SUCCESS
66 |
67 | def commitvalidation(self):
68 | """ Commit method validation function """
69 | try:
70 | self._rdmc.app.get_current_client()
71 | except:
72 | raise NoCurrentSessionEstablished("Please login and make setting" \
73 | " changes before using commit command.")
74 |
75 | def definearguments(self, customparser):
76 | """ Wrapper function for new command main function
77 |
78 | :param customparser: command line input
79 | :type customparser: parser.
80 | """
81 | if not customparser:
82 | return
83 |
84 |
--------------------------------------------------------------------------------
/extension_template/NewCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- coding: utf-8 -*-
8 | """ New Command for RDMC """
9 |
10 | import sys
11 |
12 | from optparse import OptionParser
13 | from rdmc_base_classes import RdmcCommandBase
14 | from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS
15 |
16 | class NewCommand(RdmcCommandBase):
17 | """ Main new command template class """
18 | def __init__(self, rdmcObj):
19 | RdmcCommandBase.__init__(self,\
20 | name='newcommand',\
21 | usage='newcommand [OPTIONS]\n\n\tRun to show the new command is ' \
22 | 'working\n\texample: newcommand',\
23 | summary='New command tutorial.',\
24 | aliases=[],\
25 | optparser=OptionParser())
26 | self.definearguments(self.parser)
27 | self._rdmc = rdmcObj
28 |
29 | def newcommandfunction(self, options=None):
30 | """ Main new command worker function
31 |
32 | :param options: command options
33 | :type options: options.
34 | """
35 | self.newcommandvalidation()
36 |
37 | # TODO: This is where you would add your main worker code
38 | # Refer to other commands for an example of this function
39 | sys.stdout.write(u"Hello World. It's me %s.\n" % options.name)
40 |
41 | def run(self, line):
42 | """ Wrapper function for new command main function
43 |
44 | :param line: command line input
45 | :type line: string.
46 | """
47 | try:
48 | (options, _) = self._parse_arglist(line)
49 | except:
50 | if ("-h" in line) or ("--help" in line):
51 | return ReturnCodes.SUCCESS
52 | else:
53 | raise InvalidCommandLineErrorOPTS("")
54 |
55 | self.newcommandfunction(options)
56 |
57 | #Return code
58 | return ReturnCodes.SUCCESS
59 |
60 | def newcommandvalidation(self):
61 | """ new command method validation function """
62 | try:
63 | # TODO: Any validation required need to be placed here.
64 | # Refer to other commands for an example of this function
65 | pass
66 | except:
67 | raise
68 |
69 | def definearguments(self, customparser):
70 | """ Wrapper function for new command main function
71 |
72 | :param customparser: command line input
73 | :type customparser: parser.
74 | """
75 | if not customparser:
76 | return
77 |
78 | # TODO: This is where you add all your command line arguments.
79 | # For more information on this section research optparse for python
80 |
81 | customparser.add_option(
82 | '--name',
83 | dest='name',
84 | help="""Use the provided the output name.""",
85 | default="REDFISH",
86 | )
87 |
88 |
--------------------------------------------------------------------------------
/docs/slate/source/stylesheets/print.css.scss:
--------------------------------------------------------------------------------
1 | @charset "utf-8";
2 | @import 'normalize';
3 | @import 'variables';
4 | @import 'icon-font';
5 |
6 | /*
7 | Copyright 2008-2013 Concur Technologies, Inc.
8 |
9 | Licensed under the Apache License, Version 2.0 (the "License"); you may
10 | not use this file except in compliance with the License. You may obtain
11 | a copy of the License at
12 |
13 | http://www.apache.org/licenses/LICENSE-2.0
14 |
15 | Unless required by applicable law or agreed to in writing, software
16 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18 | License for the specific language governing permissions and limitations
19 | under the License.
20 | */
21 |
22 | $print-color: #999;
23 | $print-color-light: #ccc;
24 | $print-font-size: 12px;
25 |
26 | body {
27 | @extend %default-font;
28 | }
29 |
30 | .tocify, .toc-footer, .lang-selector, .search, #nav-button {
31 | display: none;
32 | }
33 |
34 | .tocify-wrapper>img {
35 | margin: 0 auto;
36 | display: block;
37 | }
38 |
39 | .content {
40 | font-size: 12px;
41 |
42 | pre, code {
43 | @extend %code-font;
44 | @extend %break-words;
45 | border: 1px solid $print-color;
46 | border-radius: 5px;
47 | font-size: 0.8em;
48 | }
49 |
50 | pre {
51 | code {
52 | border: 0;
53 | }
54 | }
55 |
56 | pre {
57 | padding: 1.3em;
58 | }
59 |
60 | code {
61 | padding: 0.2em;
62 | }
63 |
64 | table {
65 | border: 1px solid $print-color;
66 | tr {
67 | border-bottom: 1px solid $print-color;
68 | }
69 | td,th {
70 | padding: 0.7em;
71 | }
72 | }
73 |
74 | p {
75 | line-height: 1.5;
76 | }
77 |
78 | a {
79 | text-decoration: none;
80 | color: #000;
81 | }
82 |
83 | h1 {
84 | @extend %header-font;
85 | font-size: 2.5em;
86 | padding-top: 0.5em;
87 | padding-bottom: 0.5em;
88 | margin-top: 1em;
89 | margin-bottom: $h1-margin-bottom;
90 | border: 2px solid $print-color-light;
91 | border-width: 2px 0;
92 | text-align: center;
93 | }
94 |
95 | h2 {
96 | @extend %header-font;
97 | font-size: 1.8em;
98 | margin-top: 2em;
99 | border-top: 2px solid $print-color-light;
100 | padding-top: 0.8em;
101 | }
102 |
103 | h1+h2, h1+div+h2 {
104 | border-top: none;
105 | padding-top: 0;
106 | margin-top: 0;
107 | }
108 |
109 | h3, h4 {
110 | @extend %header-font;
111 | font-size: 0.8em;
112 | margin-top: 1.5em;
113 | margin-bottom: 0.8em;
114 | text-transform: uppercase;
115 | }
116 |
117 | h5, h6 {
118 | text-transform: uppercase;
119 | }
120 |
121 | aside {
122 | padding: 1em;
123 | border: 1px solid $print-color-light;
124 | border-radius: 5px;
125 | margin-top: 1.5em;
126 | margin-bottom: 1.5em;
127 | line-height: 1.6;
128 | }
129 |
130 | aside:before {
131 | vertical-align: middle;
132 | padding-right: 0.5em;
133 | font-size: 14px;
134 | }
135 |
136 | aside.notice:before {
137 | @extend %icon-info-sign;
138 | }
139 |
140 | aside.warning:before {
141 | @extend %icon-exclamation-sign;
142 | }
143 |
144 | aside.success:before {
145 | @extend %icon-ok-sign;
146 | }
147 | }
--------------------------------------------------------------------------------
/docs/slate/source/layouts/layout.erb:
--------------------------------------------------------------------------------
1 | <%#
2 | Copyright 2008-2013 Concur Technologies, Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License"); you may
5 | not use this file except in compliance with the License. You may obtain
6 | a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | License for the specific language governing permissions and limitations
14 | under the License.
15 | %>
16 | <% language_tabs = current_page.data.language_tabs || [] %>
17 |
18 |
19 |
20 |
21 |
22 |
23 | <%= current_page.data.title || "API Documentation" %>
24 |
25 |
28 | <%= stylesheet_link_tag :screen, media: :screen %>
29 | <%= stylesheet_link_tag :print, media: :print %>
30 | <% if current_page.data.search %>
31 | <%= javascript_include_tag "all" %>
32 | <% else %>
33 | <%= javascript_include_tag "all_nosearch" %>
34 | <% end %>
35 |
36 |
37 |
38 |
39 |
40 | NAV
41 | <%= image_tag('navbar.png') %>
42 |
43 |
44 |
45 | <%= image_tag "logo.png" %>
46 | <% if language_tabs %>
47 |
56 | <% end %>
57 | <% if current_page.data.search %>
58 |
59 |
60 |
61 |
62 | <% end %>
63 |
64 |
65 | <% if current_page.data.toc_footers %>
66 |
71 | <% end %>
72 |
73 |
74 |
75 |
76 | <%= yield %>
77 | <% current_page.data.includes && current_page.data.includes.each do |include| %>
78 | <%= partial "includes/#{include}" %>
79 | <% end %>
80 |
81 |
82 | <% if language_tabs %>
83 |
92 | <% end %>
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/docs/slate/source/stylesheets/_variables.scss:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2008-2013 Concur Technologies, Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License"); you may
5 | not use this file except in compliance with the License. You may obtain
6 | a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | License for the specific language governing permissions and limitations
14 | under the License.
15 | */
16 |
17 |
18 | ////////////////////////////////////////////////////////////////////////////////
19 | // CUSTOMIZE SLATE
20 | ////////////////////////////////////////////////////////////////////////////////
21 | // Use these settings to help adjust the appearance of Slate
22 |
23 |
24 | // BACKGROUND COLORS
25 | ////////////////////
26 | $nav-bg: #393939;
27 | $examples-bg: #393939;
28 | $code-bg: #292929;
29 | $code-annotation-bg: #1c1c1c;
30 | $nav-subitem-bg: #262626;
31 | $nav-active-bg: #2467af;
32 | $lang-select-border: #000;
33 | $lang-select-bg: #222;
34 | $lang-select-active-bg: $examples-bg; // feel free to change this to blue or something
35 | $lang-select-pressed-bg: #111; // color of language tab bg when mouse is pressed
36 | $main-bg: #eaf2f6;
37 | $aside-notice-bg: #8fbcd4;
38 | $aside-warning-bg: #c97a7e;
39 | $aside-success-bg: #6ac174;
40 | $search-notice-bg: #c97a7e;
41 |
42 |
43 | // TEXT COLORS
44 | ////////////////////
45 | $main-text: #333; // main content text color
46 | $nav-text: #fff;
47 | $nav-active-text: #fff;
48 | $lang-select-text: #fff; // color of unselected language tab text
49 | $lang-select-active-text: #fff; // color of selected language tab text
50 | $lang-select-pressed-text: #fff; // color of language tab text when mouse is pressed
51 |
52 |
53 | // SIZES
54 | ////////////////////
55 | $nav-width: 230px; // width of the navbar
56 | $examples-width: 50%; // portion of the screen taken up by code examples
57 | $logo-margin: 20px; // margin between nav items and logo, ignored if search is active
58 | $main-padding: 28px; // padding to left and right of content & examples
59 | $nav-padding: 15px; // padding to left and right of navbar
60 | $nav-v-padding: 10px; // padding used vertically around search boxes and results
61 | $nav-indent: 10px; // extra padding for ToC subitems
62 | $code-annotation-padding: 13px; // padding inside code annotations
63 | $h1-margin-bottom: 21px; // padding under the largest header tags
64 | $tablet-width: 930px; // min width before reverting to tablet size
65 | $phone-width: $tablet-width - $nav-width; // min width before reverting to mobile size
66 |
67 |
68 | // FONTS
69 | ////////////////////
70 | %default-font {
71 | font-family: "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei","微软雅黑", STXihei, "华文细黑", sans-serif;
72 | font-size: 13px;
73 | }
74 |
75 | %header-font {
76 | @extend %default-font;
77 | font-weight: bold;
78 | }
79 |
80 | %code-font {
81 | font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, serif;
82 | font-size: 12px;
83 | line-height: 1.5;
84 | }
85 |
86 |
87 | // OTHER
88 | ////////////////////
89 | $nav-active-shadow: #000;
90 | $nav-footer-border-color: #666;
91 | $nav-embossed-border-top: #000;
92 | $nav-embossed-border-bottom: #939393;
93 | $main-embossed-text-shadow: 0px 1px 0px #fff;
94 | $search-box-border-color: #666;
95 |
96 |
97 | ////////////////////////////////////////////////////////////////////////////////
98 | // INTERNAL
99 | ////////////////////////////////////////////////////////////////////////////////
100 | // These settings are probably best left alone.
101 |
102 | %break-words {
103 | word-break: break-all;
104 | hyphens: auto;
105 | }
106 |
--------------------------------------------------------------------------------
/docs/slate/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | activesupport (4.2.5.1)
5 | i18n (~> 0.7)
6 | json (~> 1.7, >= 1.7.7)
7 | minitest (~> 5.1)
8 | thread_safe (~> 0.3, >= 0.3.4)
9 | tzinfo (~> 1.1)
10 | addressable (2.4.0)
11 | autoprefixer-rails (6.3.1)
12 | execjs
13 | json
14 | backports (3.6.7)
15 | capybara (2.5.0)
16 | mime-types (>= 1.16)
17 | nokogiri (>= 1.3.3)
18 | rack (>= 1.0.0)
19 | rack-test (>= 0.5.4)
20 | xpath (~> 2.0)
21 | coffee-script (2.4.1)
22 | coffee-script-source
23 | execjs
24 | coffee-script-source (1.10.0)
25 | compass-import-once (1.0.5)
26 | sass (>= 3.2, < 3.5)
27 | concurrent-ruby (0.9.2)
28 | contracts (0.12.0)
29 | erubis (2.7.0)
30 | execjs (2.6.0)
31 | fastimage (1.8.1)
32 | addressable (~> 2.3, >= 2.3.5)
33 | ffi (1.9.10)
34 | ffi (1.9.10-x64-mingw32)
35 | ffi (1.9.10-x86-mingw32)
36 | haml (4.0.7)
37 | tilt
38 | hamster (2.0.0)
39 | concurrent-ruby (~> 0.8)
40 | hashie (3.4.3)
41 | i18n (0.7.0)
42 | json (1.8.3)
43 | kramdown (1.9.0)
44 | listen (3.0.5)
45 | rb-fsevent (>= 0.9.3)
46 | rb-inotify (>= 0.9)
47 | middleman (4.0.0)
48 | coffee-script (~> 2.2)
49 | compass-import-once (= 1.0.5)
50 | haml (>= 4.0.5)
51 | kramdown (~> 1.2)
52 | middleman-cli (= 4.0.0)
53 | middleman-core (= 4.0.0)
54 | sass (>= 3.4.0, < 4.0)
55 | middleman-autoprefixer (2.7.0)
56 | autoprefixer-rails (>= 6.3.1, < 7.0.0)
57 | middleman-core (>= 3.3.3)
58 | middleman-cli (4.0.0)
59 | thor (>= 0.17.0, < 2.0)
60 | middleman-core (4.0.0)
61 | activesupport (~> 4.2)
62 | addressable (~> 2.4.0)
63 | backports (~> 3.6)
64 | bundler (~> 1.1)
65 | capybara (~> 2.5.0)
66 | contracts (~> 0.12.0)
67 | erubis
68 | execjs (~> 2.0)
69 | fastimage (~> 1.8)
70 | hamster (~> 2.0)
71 | hashie (~> 3.4)
72 | i18n (~> 0.7.0)
73 | listen (~> 3.0)
74 | padrino-helpers (~> 0.13.0)
75 | rack (>= 1.4.5, < 2.0)
76 | sass (>= 3.4)
77 | tilt (~> 1.4.1)
78 | uglifier (~> 2.6)
79 | middleman-gh-pages (0.0.3)
80 | rake (> 0.9.3)
81 | middleman-sprockets (4.0.0.rc.1)
82 | middleman-core (>= 4.0.0.rc.1)
83 | sprockets (~> 3.0)
84 | middleman-syntax (2.1.0)
85 | middleman-core (>= 3.2)
86 | rouge (~> 1.0)
87 | mime-types (3.0)
88 | mime-types-data (~> 3.2015)
89 | mime-types-data (3.2015.1120)
90 | mini_portile2 (2.1.0)
91 | minitest (5.8.4)
92 | nokogiri (1.8.2)
93 | mini_portile2 (~> 2.1.0)
94 | nokogiri (1.8.2-x64-mingw32)
95 | mini_portile2 (~> 2.1.0)
96 | nokogiri (1.8.2-x86-mingw32)
97 | mini_portile2 (~> 2.1.0)
98 | padrino-helpers (0.13.1)
99 | i18n (~> 0.6, >= 0.6.7)
100 | padrino-support (= 0.13.1)
101 | tilt (~> 1.4.1)
102 | padrino-support (0.13.1)
103 | activesupport (>= 3.1)
104 | rack (1.6.4)
105 | rack-test (0.6.3)
106 | rack (>= 1.0)
107 | rake (10.4.2)
108 | rb-fsevent (0.9.7)
109 | rb-inotify (0.9.5)
110 | ffi (>= 0.5.0)
111 | redcarpet (3.3.4)
112 | rouge (1.10.1)
113 | sass (3.4.21)
114 | sprockets (3.7.2)
115 | rack (> 1, < 3)
116 | thor (0.19.1)
117 | thread_safe (0.3.5)
118 | tilt (1.4.1)
119 | tzinfo (1.2.2)
120 | thread_safe (~> 0.1)
121 | uglifier (2.7.2)
122 | execjs (>= 0.3.0)
123 | json (>= 1.8.0)
124 | xpath (2.0.0)
125 | nokogiri (~> 1.3)
126 |
127 | PLATFORMS
128 | ruby
129 | x64-mingw32
130 | x86-mingw32
131 |
132 | DEPENDENCIES
133 | middleman (~> 4.0.0)
134 | middleman-autoprefixer (~> 2.7.0)
135 | middleman-gh-pages (~> 0.0.3)
136 | middleman-sprockets (~> 4.0.0.rc)
137 | middleman-syntax (~> 2.1.0)
138 | redcarpet (~> 3.3.2)
139 | rouge (~> 1.10.1)
140 |
141 | BUNDLED WITH
142 | 1.13.6
143 |
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/lib/_jquery.highlight.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Highlight plugin
3 | *
4 | * Based on highlight v3 by Johann Burkard
5 | * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
6 | *
7 | * Code a little bit refactored and cleaned (in my humble opinion).
8 | * Most important changes:
9 | * - has an option to highlight only entire words (wordsOnly - false by default),
10 | * - has an option to be case sensitive (caseSensitive - false by default)
11 | * - highlight element tag and class names can be specified in options
12 | *
13 | * Usage:
14 | * // wrap every occurrance of text 'lorem' in content
15 | * // with (default options)
16 | * $('#content').highlight('lorem');
17 | *
18 | * // search for and highlight more terms at once
19 | * // so you can save some time on traversing DOM
20 | * $('#content').highlight(['lorem', 'ipsum']);
21 | * $('#content').highlight('lorem ipsum');
22 | *
23 | * // search only for entire word 'lorem'
24 | * $('#content').highlight('lorem', { wordsOnly: true });
25 | *
26 | * // don't ignore case during search of term 'lorem'
27 | * $('#content').highlight('lorem', { caseSensitive: true });
28 | *
29 | * // wrap every occurrance of term 'ipsum' in content
30 | * // with
31 | * $('#content').highlight('ipsum', { element: 'em', className: 'important' });
32 | *
33 | * // remove default highlight
34 | * $('#content').unhighlight();
35 | *
36 | * // remove custom highlight
37 | * $('#content').unhighlight({ element: 'em', className: 'important' });
38 | *
39 | *
40 | * Copyright (c) 2009 Bartek Szopka
41 | *
42 | * Licensed under MIT license.
43 | *
44 | */
45 |
46 | jQuery.extend({
47 | highlight: function (node, re, nodeName, className) {
48 | if (node.nodeType === 3) {
49 | var match = node.data.match(re);
50 | if (match) {
51 | var highlight = document.createElement(nodeName || 'span');
52 | highlight.className = className || 'highlight';
53 | var wordNode = node.splitText(match.index);
54 | wordNode.splitText(match[0].length);
55 | var wordClone = wordNode.cloneNode(true);
56 | highlight.appendChild(wordClone);
57 | wordNode.parentNode.replaceChild(highlight, wordNode);
58 | return 1; //skip added node in parent
59 | }
60 | } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
61 | !/(script|style)/i.test(node.tagName) && // ignore script and style nodes
62 | !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
63 | for (var i = 0; i < node.childNodes.length; i++) {
64 | i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
65 | }
66 | }
67 | return 0;
68 | }
69 | });
70 |
71 | jQuery.fn.unhighlight = function (options) {
72 | var settings = { className: 'highlight', element: 'span' };
73 | jQuery.extend(settings, options);
74 |
75 | return this.find(settings.element + "." + settings.className).each(function () {
76 | var parent = this.parentNode;
77 | parent.replaceChild(this.firstChild, this);
78 | parent.normalize();
79 | }).end();
80 | };
81 |
82 | jQuery.fn.highlight = function (words, options) {
83 | var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
84 | jQuery.extend(settings, options);
85 |
86 | if (words.constructor === String) {
87 | words = [words];
88 | }
89 | words = jQuery.grep(words, function(word, i){
90 | return word != '';
91 | });
92 | words = jQuery.map(words, function(word, i) {
93 | return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
94 | });
95 | if (words.length == 0) { return this; };
96 |
97 | var flag = settings.caseSensitive ? "" : "i";
98 | var pattern = "(" + words.join("|") + ")";
99 | if (settings.wordsOnly) {
100 | pattern = "\\b" + pattern + "\\b";
101 | }
102 | var re = new RegExp(pattern, flag);
103 |
104 | return this.each(function () {
105 | jQuery.highlight(this, re, settings.element, settings.className);
106 | });
107 | };
108 |
109 |
--------------------------------------------------------------------------------
/docs/slate/font-selection.json:
--------------------------------------------------------------------------------
1 | {
2 | "IcoMoonType": "selection",
3 | "icons": [
4 | {
5 | "icon": {
6 | "paths": [
7 | "M438.857 73.143q119.429 0 220.286 58.857t159.714 159.714 58.857 220.286-58.857 220.286-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857zM512 785.714v-108.571q0-8-5.143-13.429t-12.571-5.429h-109.714q-7.429 0-13.143 5.714t-5.714 13.143v108.571q0 7.429 5.714 13.143t13.143 5.714h109.714q7.429 0 12.571-5.429t5.143-13.429zM510.857 589.143l10.286-354.857q0-6.857-5.714-10.286-5.714-4.571-13.714-4.571h-125.714q-8 0-13.714 4.571-5.714 3.429-5.714 10.286l9.714 354.857q0 5.714 5.714 10t13.714 4.286h105.714q8 0 13.429-4.286t6-10z"
8 | ],
9 | "attrs": [],
10 | "isMulticolor": false,
11 | "tags": [
12 | "exclamation-circle"
13 | ],
14 | "defaultCode": 61546,
15 | "grid": 14
16 | },
17 | "attrs": [],
18 | "properties": {
19 | "id": 100,
20 | "order": 4,
21 | "prevSize": 28,
22 | "code": 58880,
23 | "name": "exclamation-sign",
24 | "ligatures": ""
25 | },
26 | "setIdx": 0,
27 | "iconIdx": 0
28 | },
29 | {
30 | "icon": {
31 | "paths": [
32 | "M585.143 786.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-54.857v-292.571q0-8-5.143-13.143t-13.143-5.143h-182.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h54.857v182.857h-54.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h256q8 0 13.143-5.143t5.143-13.143zM512 274.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-109.714q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h109.714q8 0 13.143-5.143t5.143-13.143zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z"
33 | ],
34 | "attrs": [],
35 | "isMulticolor": false,
36 | "tags": [
37 | "info-circle"
38 | ],
39 | "defaultCode": 61530,
40 | "grid": 14
41 | },
42 | "attrs": [],
43 | "properties": {
44 | "id": 85,
45 | "order": 3,
46 | "name": "info-sign",
47 | "prevSize": 28,
48 | "code": 58882
49 | },
50 | "setIdx": 0,
51 | "iconIdx": 2
52 | },
53 | {
54 | "icon": {
55 | "paths": [
56 | "M733.714 419.429q0-16-10.286-26.286l-52-51.429q-10.857-10.857-25.714-10.857t-25.714 10.857l-233.143 232.571-129.143-129.143q-10.857-10.857-25.714-10.857t-25.714 10.857l-52 51.429q-10.286 10.286-10.286 26.286 0 15.429 10.286 25.714l206.857 206.857q10.857 10.857 25.714 10.857 15.429 0 26.286-10.857l310.286-310.286q10.286-10.286 10.286-25.714zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z"
57 | ],
58 | "attrs": [],
59 | "isMulticolor": false,
60 | "tags": [
61 | "check-circle"
62 | ],
63 | "defaultCode": 61528,
64 | "grid": 14
65 | },
66 | "attrs": [],
67 | "properties": {
68 | "id": 83,
69 | "order": 9,
70 | "prevSize": 28,
71 | "code": 58886,
72 | "name": "ok-sign"
73 | },
74 | "setIdx": 0,
75 | "iconIdx": 6
76 | },
77 | {
78 | "icon": {
79 | "paths": [
80 | "M658.286 475.429q0-105.714-75.143-180.857t-180.857-75.143-180.857 75.143-75.143 180.857 75.143 180.857 180.857 75.143 180.857-75.143 75.143-180.857zM950.857 950.857q0 29.714-21.714 51.429t-51.429 21.714q-30.857 0-51.429-21.714l-196-195.429q-102.286 70.857-228 70.857-81.714 0-156.286-31.714t-128.571-85.714-85.714-128.571-31.714-156.286 31.714-156.286 85.714-128.571 128.571-85.714 156.286-31.714 156.286 31.714 128.571 85.714 85.714 128.571 31.714 156.286q0 125.714-70.857 228l196 196q21.143 21.143 21.143 51.429z"
81 | ],
82 | "width": 951,
83 | "attrs": [],
84 | "isMulticolor": false,
85 | "tags": [
86 | "search"
87 | ],
88 | "defaultCode": 61442,
89 | "grid": 14
90 | },
91 | "attrs": [],
92 | "properties": {
93 | "id": 2,
94 | "order": 1,
95 | "prevSize": 28,
96 | "code": 58887,
97 | "name": "icon-search"
98 | },
99 | "setIdx": 0,
100 | "iconIdx": 7
101 | }
102 | ],
103 | "height": 1024,
104 | "metadata": {
105 | "name": "slate",
106 | "license": "SIL OFL 1.1"
107 | },
108 | "preferences": {
109 | "showGlyphs": true,
110 | "showQuickUse": true,
111 | "showQuickUse2": true,
112 | "showSVGs": true,
113 | "fontPref": {
114 | "prefix": "icon-",
115 | "metadata": {
116 | "fontFamily": "slate",
117 | "majorVersion": 1,
118 | "minorVersion": 0,
119 | "description": "Based on FontAwesome",
120 | "license": "SIL OFL 1.1"
121 | },
122 | "metrics": {
123 | "emSize": 1024,
124 | "baseline": 6.25,
125 | "whitespace": 50
126 | },
127 | "resetPoint": 58880,
128 | "showSelector": false,
129 | "selector": "class",
130 | "classSelector": ".icon",
131 | "showMetrics": false,
132 | "showMetadata": true,
133 | "showVersion": true,
134 | "ie7": false
135 | },
136 | "imagePref": {
137 | "prefix": "icon-",
138 | "png": true,
139 | "useClassSelector": true,
140 | "color": 4473924,
141 | "bgColor": 16777215
142 | },
143 | "historySize": 100,
144 | "showCodes": true,
145 | "gridSize": 16,
146 | "showLiga": false
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/app/_lang.js:
--------------------------------------------------------------------------------
1 | //= require ../lib/_jquery
2 |
3 | /*
4 | Copyright 2008-2013 Concur Technologies, Inc.
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License"); you may
7 | not use this file except in compliance with the License. You may obtain
8 | a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 | License for the specific language governing permissions and limitations
16 | under the License.
17 | */
18 | (function (global) {
19 | 'use strict';
20 |
21 | var languages = [];
22 |
23 | global.setupLanguages = setupLanguages;
24 | global.activateLanguage = activateLanguage;
25 |
26 | function activateLanguage(language) {
27 | if (!language) return;
28 | if (language === "") return;
29 |
30 | $(".lang-selector a").removeClass('active');
31 | $(".lang-selector a[data-language-name='" + language + "']").addClass('active');
32 | for (var i=0; i < languages.length; i++) {
33 | $(".highlight." + languages[i]).hide();
34 | $(".lang-specific." + languages[i]).hide();
35 | }
36 | $(".highlight." + language).show();
37 | $(".lang-specific." + language).show();
38 |
39 | global.toc.calculateHeights();
40 |
41 | // scroll to the new location of the position
42 | if ($(window.location.hash).get(0)) {
43 | $(window.location.hash).get(0).scrollIntoView(true);
44 | }
45 | }
46 |
47 | // parseURL and stringifyURL are from https://github.com/sindresorhus/query-string
48 | // MIT licensed
49 | // https://github.com/sindresorhus/query-string/blob/7bee64c16f2da1a326579e96977b9227bf6da9e6/license
50 | function parseURL(str) {
51 | if (typeof str !== 'string') {
52 | return {};
53 | }
54 |
55 | str = str.trim().replace(/^(\?|#|&)/, '');
56 |
57 | if (!str) {
58 | return {};
59 | }
60 |
61 | return str.split('&').reduce(function (ret, param) {
62 | var parts = param.replace(/\+/g, ' ').split('=');
63 | var key = parts[0];
64 | var val = parts[1];
65 |
66 | key = decodeURIComponent(key);
67 | // missing `=` should be `null`:
68 | // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
69 | val = val === undefined ? null : decodeURIComponent(val);
70 |
71 | if (!ret.hasOwnProperty(key)) {
72 | ret[key] = val;
73 | } else if (Array.isArray(ret[key])) {
74 | ret[key].push(val);
75 | } else {
76 | ret[key] = [ret[key], val];
77 | }
78 |
79 | return ret;
80 | }, {});
81 | };
82 |
83 | function stringifyURL(obj) {
84 | return obj ? Object.keys(obj).sort().map(function (key) {
85 | var val = obj[key];
86 |
87 | if (Array.isArray(val)) {
88 | return val.sort().map(function (val2) {
89 | return encodeURIComponent(key) + '=' + encodeURIComponent(val2);
90 | }).join('&');
91 | }
92 |
93 | return encodeURIComponent(key) + '=' + encodeURIComponent(val);
94 | }).join('&') : '';
95 | };
96 |
97 | // gets the language set in the query string
98 | function getLanguageFromQueryString() {
99 | if (location.search.length >= 1) {
100 | var language = parseURL(location.search).language
101 | if (language) {
102 | return language;
103 | } else if (jQuery.inArray(location.search.substr(1), languages) != -1) {
104 | return location.search.substr(1);
105 | }
106 | }
107 |
108 | return false;
109 | }
110 |
111 | // returns a new query string with the new language in it
112 | function generateNewQueryString(language) {
113 | var url = parseURL(location.search);
114 | if (url.language) {
115 | url.language = language;
116 | return stringifyURL(url);
117 | }
118 | return language;
119 | }
120 |
121 | // if a button is clicked, add the state to the history
122 | function pushURL(language) {
123 | if (!history) { return; }
124 | var hash = window.location.hash;
125 | if (hash) {
126 | hash = hash.replace(/^#+/, '');
127 | }
128 | history.pushState({}, '', '?' + generateNewQueryString(language) + '#' + hash);
129 |
130 | // save language as next default
131 | localStorage.setItem("language", language);
132 | }
133 |
134 | function setupLanguages(l) {
135 | var defaultLanguage = localStorage.getItem("language");
136 |
137 | languages = l;
138 |
139 | var presetLanguage = getLanguageFromQueryString();
140 | if (presetLanguage) {
141 | // the language is in the URL, so use that language!
142 | activateLanguage(presetLanguage);
143 |
144 | localStorage.setItem("language", presetLanguage);
145 | } else if ((defaultLanguage !== null) && (jQuery.inArray(defaultLanguage, languages) != -1)) {
146 | // the language was the last selected one saved in localstorage, so use that language!
147 | activateLanguage(defaultLanguage);
148 | } else {
149 | // no language selected, so use the default
150 | activateLanguage(languages[0]);
151 | }
152 | }
153 |
154 | // if we click on a language tab, activate that language
155 | $(function() {
156 | $(".lang-selector a").on("click", function() {
157 | var language = $(this).data("language-name");
158 | pushURL(language);
159 | activateLanguage(language);
160 | return false;
161 | });
162 | window.onpopstate = function() {
163 | activateLanguage(getLanguageFromQueryString());
164 | };
165 | });
166 | })(window);
167 |
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/lib/_energize.js:
--------------------------------------------------------------------------------
1 | /**
2 | * energize.js v0.1.0
3 | *
4 | * Speeds up click events on mobile devices.
5 | * https://github.com/davidcalhoun/energize.js
6 | */
7 |
8 | (function() { // Sandbox
9 | /**
10 | * Don't add to non-touch devices, which don't need to be sped up
11 | */
12 | if(!('ontouchstart' in window)) return;
13 |
14 | var lastClick = {},
15 | isThresholdReached, touchstart, touchmove, touchend,
16 | click, closest;
17 |
18 | /**
19 | * isThresholdReached
20 | *
21 | * Compare touchstart with touchend xy coordinates,
22 | * and only fire simulated click event if the coordinates
23 | * are nearby. (don't want clicking to be confused with a swipe)
24 | */
25 | isThresholdReached = function(startXY, xy) {
26 | return Math.abs(startXY[0] - xy[0]) > 5 || Math.abs(startXY[1] - xy[1]) > 5;
27 | };
28 |
29 | /**
30 | * touchstart
31 | *
32 | * Save xy coordinates when the user starts touching the screen
33 | */
34 | touchstart = function(e) {
35 | this.startXY = [e.touches[0].clientX, e.touches[0].clientY];
36 | this.threshold = false;
37 | };
38 |
39 | /**
40 | * touchmove
41 | *
42 | * Check if the user is scrolling past the threshold.
43 | * Have to check here because touchend will not always fire
44 | * on some tested devices (Kindle Fire?)
45 | */
46 | touchmove = function(e) {
47 | // NOOP if the threshold has already been reached
48 | if(this.threshold) return false;
49 |
50 | this.threshold = isThresholdReached(this.startXY, [e.touches[0].clientX, e.touches[0].clientY]);
51 | };
52 |
53 | /**
54 | * touchend
55 | *
56 | * If the user didn't scroll past the threshold between
57 | * touchstart and touchend, fire a simulated click.
58 | *
59 | * (This will fire before a native click)
60 | */
61 | touchend = function(e) {
62 | // Don't fire a click if the user scrolled past the threshold
63 | if(this.threshold || isThresholdReached(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) {
64 | return;
65 | }
66 |
67 | /**
68 | * Create and fire a click event on the target element
69 | * https://developer.mozilla.org/en/DOM/event.initMouseEvent
70 | */
71 | var touch = e.changedTouches[0],
72 | evt = document.createEvent('MouseEvents');
73 | evt.initMouseEvent('click', true, true, window, 0, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
74 | evt.simulated = true; // distinguish from a normal (nonsimulated) click
75 | e.target.dispatchEvent(evt);
76 | };
77 |
78 | /**
79 | * click
80 | *
81 | * Because we've already fired a click event in touchend,
82 | * we need to listed for all native click events here
83 | * and suppress them as necessary.
84 | */
85 | click = function(e) {
86 | /**
87 | * Prevent ghost clicks by only allowing clicks we created
88 | * in the click event we fired (look for e.simulated)
89 | */
90 | var time = Date.now(),
91 | timeDiff = time - lastClick.time,
92 | x = e.clientX,
93 | y = e.clientY,
94 | xyDiff = [Math.abs(lastClick.x - x), Math.abs(lastClick.y - y)],
95 | target = closest(e.target, 'A') || e.target, // needed for standalone apps
96 | nodeName = target.nodeName,
97 | isLink = nodeName === 'A',
98 | standAlone = window.navigator.standalone && isLink && e.target.getAttribute("href");
99 |
100 | lastClick.time = time;
101 | lastClick.x = x;
102 | lastClick.y = y;
103 |
104 | /**
105 | * Unfortunately Android sometimes fires click events without touch events (seen on Kindle Fire),
106 | * so we have to add more logic to determine the time of the last click. Not perfect...
107 | *
108 | * Older, simpler check: if((!e.simulated) || standAlone)
109 | */
110 | if((!e.simulated && (timeDiff < 500 || (timeDiff < 1500 && xyDiff[0] < 50 && xyDiff[1] < 50))) || standAlone) {
111 | e.preventDefault();
112 | e.stopPropagation();
113 | if(!standAlone) return false;
114 | }
115 |
116 | /**
117 | * Special logic for standalone web apps
118 | * See http://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window
119 | */
120 | if(standAlone) {
121 | window.location = target.getAttribute("href");
122 | }
123 |
124 | /**
125 | * Add an energize-focus class to the targeted link (mimics :focus behavior)
126 | * TODO: test and/or remove? Does this work?
127 | */
128 | if(!target || !target.classList) return;
129 | target.classList.add("energize-focus");
130 | window.setTimeout(function(){
131 | target.classList.remove("energize-focus");
132 | }, 150);
133 | };
134 |
135 | /**
136 | * closest
137 | * @param {HTMLElement} node current node to start searching from.
138 | * @param {string} tagName the (uppercase) name of the tag you're looking for.
139 | *
140 | * Find the closest ancestor tag of a given node.
141 | *
142 | * Starts at node and goes up the DOM tree looking for a
143 | * matching nodeName, continuing until hitting document.body
144 | */
145 | closest = function(node, tagName){
146 | var curNode = node;
147 |
148 | while(curNode !== document.body) { // go up the dom until we find the tag we're after
149 | if(!curNode || curNode.nodeName === tagName) { return curNode; } // found
150 | curNode = curNode.parentNode; // not found, so keep going up
151 | }
152 |
153 | return null; // not found
154 | };
155 |
156 | /**
157 | * Add all delegated event listeners
158 | *
159 | * All the events we care about bubble up to document,
160 | * so we can take advantage of event delegation.
161 | *
162 | * Note: no need to wait for DOMContentLoaded here
163 | */
164 | document.addEventListener('touchstart', touchstart, false);
165 | document.addEventListener('touchmove', touchmove, false);
166 | document.addEventListener('touchend', touchend, false);
167 | document.addEventListener('click', click, true); // TODO: why does this use capture?
168 |
169 | })();
--------------------------------------------------------------------------------
/docs/slate/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Slate helps you create beautiful, intelligent, responsive API documentation.
8 |
9 | 
10 |
11 | The example above was created with Slate. Check it out at lord.github.io/slate.
12 |
13 | Features
14 | ------------
15 |
16 | * **Clean, intuitive design** — With Slate, the description of your API is on the left side of your documentation, and all the code examples are on the right side. Inspired by [Stripe's](https://stripe.com/docs/api) and [Paypal's](https://developer.paypal.com/webapps/developer/docs/api/) API docs. Slate is responsive, so it looks great on tablets, phones, and even in print.
17 |
18 | * **Everything on a single page** — Gone are the days when your users had to search through a million pages to find what they wanted. Slate puts the entire documentation on a single page. We haven't sacrificed linkability, though. As you scroll, your browser's hash will update to the nearest header, so linking to a particular point in the documentation is still natural and easy.
19 |
20 | * **Slate is just Markdown** — When you write docs with Slate, you're just writing Markdown, which makes it simple to edit and understand. Everything is written in Markdown — even the code samples are just Markdown code blocks.
21 |
22 | * **Write code samples in multiple languages** — If your API has bindings in multiple programming languages, you can easily put in tabs to switch between them. In your document, you'll distinguish different languages by specifying the language name at the top of each code block, just like with Github Flavored Markdown.
23 |
24 | * **Out-of-the-box syntax highlighting** for [almost 100 languages](http://rouge.jneen.net/), no configuration required.
25 |
26 | * **Automatic, smoothly scrolling table of contents** on the far left of the page. As you scroll, it displays your current position in the document. It's fast, too. We're using Slate at TripIt to build documentation for our new API, where our table of contents has over 180 entries. We've made sure that the performance remains excellent, even for larger documents.
27 |
28 | * **Let your users update your documentation for you** — By default, your Slate-generated documentation is hosted in a public Github repository. Not only does this mean you get free hosting for your docs with Github Pages, but it also makes it simple for other developers to make pull requests to your docs if they find typos or other problems. Of course, if you don't want to use GitHub, you're also welcome to host your docs elsewhere.
29 |
30 | Getting started with Slate is super easy! Simply fork this repository and follow the instructions below. Or, if you'd like to check out what Slate is capable of, take a look at the [sample docs](http://lord.github.io/slate).
31 |
32 | Getting Started with Slate
33 | ------------------------------
34 |
35 | ### Prerequisites
36 |
37 | You're going to need:
38 |
39 | - **Linux or OS X** — Windows may work, but is unsupported.
40 | - **Ruby, version 2.0 or newer**
41 | - **Bundler** — If Ruby is already installed, but the `bundle` command doesn't work, just run `gem install bundler` in a terminal.
42 |
43 | ### Getting Set Up
44 |
45 | 1. Fork this repository on Github.
46 | 2. Clone *your forked repository* (not our original one) to your hard drive with `git clone https://github.com/YOURUSERNAME/slate.git`
47 | 3. `cd slate`
48 | 4. Initialize and start Slate. You can either do this locally, or with Vagrant:
49 |
50 | ```shell
51 | # either run this to run locally
52 | bundle install
53 | bundle exec middleman server
54 |
55 | # OR run this to run with vagrant
56 | vagrant up
57 | ```
58 |
59 | You can now see the docs at http://localhost:4567. Whoa! That was fast!
60 |
61 | Now that Slate is all set up your machine, you'll probably want to learn more about [editing Slate markdown](https://github.com/lord/slate/wiki/Markdown-Syntax), or [how to publish your docs](https://github.com/lord/slate/wiki/Deploying-Slate).
62 |
63 | If you'd prefer to use Docker, instructions are available [in the wiki](https://github.com/lord/slate/wiki/Docker).
64 |
65 | Companies Using Slate
66 | ---------------------------------
67 |
68 | * [NASA](https://api.nasa.gov)
69 | * [IBM Cloudant](https://docs.cloudant.com/api.html)
70 | * [Travis-CI](https://docs.travis-ci.com/api/)
71 | * [Mozilla](http://mozilla.github.io/localForage/)
72 | * [Appium](http://appium.io/slate/en/master)
73 | * [Dwolla](https://docs.dwolla.com/)
74 | * [Clearbit](https://clearbit.com/docs)
75 | * [Coinbase](https://developers.coinbase.com/api)
76 | * [Parrot Drones](http://developer.parrot.com/docs/bebop/)
77 | * [Fidor Bank](http://docs.fidor.de/)
78 |
79 | You can view more in [the list on the wiki](https://github.com/lord/slate/wiki/Slate-in-the-Wild).
80 |
81 | Need Help? Found a bug?
82 | --------------------
83 |
84 | [Submit an issue](https://github.com/lord/slate/issues) to the Slate Github if you need any help. And, of course, feel free to submit pull requests with bug fixes or changes.
85 |
86 | Contributors
87 | --------------------
88 |
89 | Slate was built by [Robert Lord](https://lord.io) while interning at [TripIt](https://www.tripit.com/).
90 |
91 | Thanks to the following people who have submitted major pull requests:
92 |
93 | - [@chrissrogers](https://github.com/chrissrogers)
94 | - [@bootstraponline](https://github.com/bootstraponline)
95 | - [@realityking](https://github.com/realityking)
96 | - [@cvkef](https://github.com/cvkef)
97 |
98 | Also, thanks to [Sauce Labs](http://saucelabs.com) for helping sponsor the project.
99 |
100 | Special Thanks
101 | --------------------
102 | - [Middleman](https://github.com/middleman/middleman)
103 | - [jquery.tocify.js](https://github.com/gfranko/jquery.tocify.js)
104 | - [middleman-syntax](https://github.com/middleman/middleman-syntax)
105 | - [middleman-gh-pages](https://github.com/edgecase/middleman-gh-pages)
106 | - [Font Awesome](http://fortawesome.github.io/Font-Awesome/)
107 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/StatusCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ Status Command for RDMC """
8 |
9 | import sys
10 |
11 | from optparse import OptionParser
12 | from rdmc_helper import ReturnCodes, \
13 | InvalidCommandLineErrorOPTS
14 |
15 | from rdmc_base_classes import RdmcCommandBase
16 | from rdmc_helper import NoCurrentSessionEstablished
17 |
18 | class StatusCommand(RdmcCommandBase):
19 | """ Constructor """
20 | def __init__(self, rdmcObj):
21 | RdmcCommandBase.__init__(self,\
22 | name='status',\
23 | usage='status\n\n\tRun to display all pending changes within'\
24 | ' the currently\n\tselected type and that need to be' \
25 | ' committed\n\texample: status',\
26 | summary='Displays all pending changes within a selected type'\
27 | ' that need to be committed.',\
28 | aliases=[],\
29 | optparser=OptionParser())
30 | self.definearguments(self.parser)
31 | self._rdmc = rdmcObj
32 | self.selobj = rdmcObj.commandsDict["SelectCommand"](rdmcObj)
33 |
34 | def run(self, line):
35 | """ Main status worker function
36 |
37 | :param line: command line input
38 | :type line: string.
39 | """
40 | try:
41 | (_, _) = self._parse_arglist(line)
42 | except:
43 | if ("-h" in line) or ("--help" in line):
44 | return ReturnCodes.SUCCESS
45 | else:
46 | raise InvalidCommandLineErrorOPTS("")
47 |
48 | self.statusvalidation()
49 | contents = self._rdmc.app.status()
50 | selector = self._rdmc.app.get_selector()
51 |
52 | if contents:
53 | self.outputpatches(contents, selector)
54 | else:
55 | sys.stdout.write("No changes found\n")
56 |
57 | #Return code
58 | return ReturnCodes.SUCCESS
59 |
60 | def outputpatches(self, contents, selector):
61 | """ Helper function for status for use in patches
62 |
63 | :param contents: contents for the selection
64 | :type contents: string.
65 | :param selector: type selected
66 | :type selector: string.
67 | """
68 | sys.stdout.write("Current changes found:\n")
69 | for item in contents:
70 | for key, value in item.items():
71 | if selector and key.lower().startswith(selector.lower()):
72 | sys.stdout.write("%s (Currently selected)\n" % key)
73 | else:
74 | sys.stdout.write("%s\n" % key)
75 | for content in value:
76 | try:
77 | if isinstance(content[0]["value"], int):
78 | sys.stdout.write('\t%s=%s' % \
79 | (content[0]["path"][1:], content[0]["value"]))
80 | elif not isinstance(content[0]["value"], bool) and \
81 | not len(content[0]["value"]) == 0:
82 | if content[0]["value"][0] == '"' and \
83 | content[0]["value"][-1] == '"':
84 | sys.stdout.write('\t%s=%s' % \
85 | (content[0]["path"][1:], \
86 | content[0]["value"][1:-1]))
87 | else:
88 | sys.stdout.write('\t%s=%s' % \
89 | (content[0]["path"][1:], \
90 | content[0]["value"]))
91 | else:
92 | output = content[0]["value"]
93 |
94 | if not isinstance(output, bool):
95 | if len(output) == 0:
96 | output = '""'
97 |
98 | sys.stdout.write('\t%s=%s' % \
99 | (content[0]["path"][1:], output))
100 | except:
101 | if isinstance(content["value"], int):
102 | sys.stdout.write('\t%s=%s' % \
103 | (content["path"][1:], content["value"]))
104 | elif not isinstance(content["value"], bool) and \
105 | not len(content["value"]) == 0:
106 | if content["value"][0] == '"' and \
107 | content["value"][-1] == '"':
108 | sys.stdout.write('\t%s=%s' % \
109 | (content["path"][1:], \
110 | content["value"]))
111 | else:
112 | sys.stdout.write('\t%s=%s' % \
113 | (content["path"][1:], \
114 | content["value"]))
115 | else:
116 | output = content["value"]
117 |
118 | if not isinstance(output, bool):
119 | if len(output) == 0:
120 | output = '""'
121 |
122 | sys.stdout.write('\t%s=%s' % \
123 | (content["path"][1:], output))
124 | sys.stdout.write('\n')
125 |
126 |
127 | def statusvalidation(self):
128 | """ Status method validation function """
129 | try:
130 | self._rdmc.app.get_current_client()
131 | except:
132 | raise NoCurrentSessionEstablished("Please login and make setting" \
133 | " changes before using status command.")
134 |
135 | def definearguments(self, customparser):
136 | """ Wrapper function for new command main function
137 |
138 | :param customparser: command line input
139 | :type customparser: parser.
140 | """
141 | if not customparser:
142 | return
143 |
144 |
--------------------------------------------------------------------------------
/docs/slate/source/javascripts/lib/_imagesloaded.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * imagesLoaded PACKAGED v3.1.8
3 | * JavaScript is all like "You images are done yet or what?"
4 | * MIT License
5 | */
6 |
7 | (function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("wolfy87-eventemitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(window,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function f(e){this.img=e}function c(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var f=r[o];this.addImage(f)}}},s.prototype.addImage=function(e){var t=new f(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),f.prototype=new t,f.prototype.check=function(){var e=v[this.img.src]||new c(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},f.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return c.prototype=new t,c.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},c.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},c.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},c.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},c.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},c.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
--------------------------------------------------------------------------------
/docs/slate/source/includes/_usage.md:
--------------------------------------------------------------------------------
1 | # Using the Redfish Utility
2 |
3 | ## Redfish Utility Modes of operation
4 |
5 | The Redfish Utility has three modes of operation. By default, the interactive mode is utilized when you start the Redfish Utility. With Scriptable Mode, you can use a script that gives commands to the Redfish Utility. File-Based mode allows you to use a script that gives commands to the Redfish Utility and use a file to load and save settings.
6 |
7 | ### Interactive mode
8 |
9 | Interactive mode is started when you run the Redfish Utility without any command line parameters. The `redfish>` prompt is displayed and you can enter commands one at a time. You can exit the interactive mode by entering the `exit` command at the prompt. On Windows systems, double-click `redfish.exe` to start an interactive session. You must be an administrator to run `redfish.exe`.
10 |
11 | 
12 |
13 | ### Scriptable mode
14 |
15 | > The following script can be called to retrieve information regarding the **ComputerSystem** type:
16 |
17 | ```
18 | :: This is a batch file that logs into a remote server,
19 | :: selects the ComputerSystem type, and gets the AssetTag value
20 |
21 | :: Usage ::
22 | :: selectget.bat [URI] [USERNAME] [PASSWORD]
23 | @echo off
24 |
25 | set argC=0
26 | for %%x in (%*) do Set /A argC+=1
27 | if %argC% LSS 3 goto :failCondition
28 | goto :main
29 |
30 | :failCondition
31 | @echo Usage:
32 | @echo selectget.bat [URI] [USERNAME] [PASSWORD]
33 | goto :EOF
34 |
35 | :main
36 | @echo *****************************************
37 | @echo ************* Logging in... *************
38 | @echo *****************************************
39 | redfish.exe login %1 -u %2 -p %3
40 | @echo *****************************************
41 | @echo *** selecting ComputerSystem type... ****
42 | @echo *****************************************
43 | redfish.exe select ComputerSystem.
44 | @echo *****************************************
45 | @echo ********** getting AssetTag... **********
46 | @echo *****************************************
47 | redfish.exe get AssetTag
48 | pause
49 | ```
50 |
51 | Scriptable mode is used if you want to script all the commands with the use of an external input file. The script contains a list of the Redfish Utility command lines that let users get and set properties of server objects.
52 |
53 | In our example, first the `ComputerSystem` type is selected, and then the **get** command is used to retrieve information about the `AssetTag` property of `ComputerSystem`
54 |
55 | ### File-based mode
56 |
57 | > The following script allows you to save, edit, and load a file to the server.
58 |
59 | ```
60 | :: This a file-based edit mode helper for the Redfish Utility
61 | :: 1. Run to download selected type to a file called redfish.json
62 | :: 2. Edit the redfish.json file to make changes.
63 | :: 3. Press any key running batch program to continue with program,
64 | :: uploading the newly edited program to the server.
65 |
66 | :: Usage ::
67 | :: saveload.bat [SELECTOR] [FILENAME]
68 | :: Specify a type with the SELECTOR tag, and
69 | :: save to a file called FILENAME
70 | @echo off
71 | set argC=0
72 | for %%x in (%*) do Set /A argC+=1
73 | if %argC% LSS 2 goto :failCondition
74 | goto :main
75 |
76 | :failCondition
77 | @echo Usage:
78 | @echo saveload.bat [SELECTOR] [FILENAME]
79 | @echo specify a type with the SELECTOR tag, and
80 | @echo save to a file called FILENAME
81 | goto :EOF
82 |
83 | :main
84 | redfish.exe login
85 | redfish.exe save --selector=%1 --json -f %2
86 | @echo Edit the file, then:
87 | pause
88 | redfish.exe load -f %2
89 |
90 | ```
91 |
92 | File-based mode allows you to save and load settings from a file. File-based mode supports the JSON format.
93 |
94 | When the example script is run, the following result is produced:
95 |
96 | 
97 |
98 | Here, the `ComputerSystem` type is saved to a file called `redfish1.json`. Then, after you modify any properties, the **load** command is used to make these changes on the server.
99 |
100 | The properties of `ComputerSystem` can be edited here, and then loaded on the server. When the file is loaded on the server, the Redfish Utility will attempt to patch all values in the file.
101 |
102 | > After saving this configuration, the **redfish1.json** file looks like this:
103 |
104 | ```
105 | {
106 | "#ComputerSystem.v1_2_0.ComputerSystem": {
107 | "/redfish/v1/Systems/1/": {
108 | "AssetTag": "newassettag"
109 | }
110 | }
111 | }
112 | ```
113 |
114 | ## Configuration file (redfish.conf)
115 |
116 | > default configuration file
117 |
118 | ```
119 | [redfish]
120 | #The Redfish Utility reads the following environment variables, and applies them at runtime.
121 | #Note that they can be overridden by command line switches.
122 |
123 | ##### Cache Settings #####
124 | ##########################################
125 | # option to disable caching of all data
126 | #cache = False
127 |
128 | ##### Credential Settings #####
129 | ##########################################
130 | # option to use the provided url to login
131 | #url = https://127.0.0.1
132 |
133 | # option to use the provided username to login
134 | #username = admin
135 |
136 | # option to use the provided password to login
137 | #password = password
138 |
139 | ##### Commit Settings #####
140 | ##########################################
141 | # flag to commit in all places where applicable
142 | #commit = True
143 |
144 | ##### Output Default Settings #####
145 | ##########################################
146 | # flag to change output format in all places where applicable
147 | #format = json
148 |
149 | ##### Default Save/Load Settings #####
150 | ##########################################
151 | # option to set default save output file
152 | #savefile = redfish.json
153 |
154 | # option to set default load input file
155 | #loadfile = redfish.json
156 |
157 | ```
158 |
159 | The configuration file contains the default settings for the utility. You can use a text editor to change the behavior of the utility such as adding a server IP address, username, and password so you do not need to type this each time when you use the utility.
160 |
161 | Configuration file locations:
162 |
163 | - Windows OS: The same location as the executable file that starts the utility.
164 | - Linux OS: `/etc/redfish/redfish.conf`
165 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/TypesCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- coding: utf-8 -*-
8 | """ Types Command for RDMC """
9 |
10 | import sys
11 | import redfish.ris
12 |
13 | from optparse import OptionParser
14 | from rdmc_base_classes import RdmcCommandBase
15 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
16 | InvalidCommandLineErrorOPTS
17 |
18 | class TypesCommand(RdmcCommandBase):
19 | """ Constructor """
20 | def __init__(self, rdmcObj):
21 | RdmcCommandBase.__init__(self,\
22 | name='types',\
23 | usage='types [TYPE] [OPTIONS]\n\n\tRun to display currently ' \
24 | 'available selectable types\n\texample: types',\
25 | summary='Displays all selectable types within the currently'\
26 | ' logged in server.',\
27 | aliases=['types'],\
28 | optparser=OptionParser())
29 | self.definearguments(self.parser)
30 | self._rdmc = rdmcObj
31 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
32 |
33 | def typesfunction(self, line, returntypes=False):
34 | """ Main types worker function
35 |
36 | :param line: command line input
37 | :type line: string.
38 | :param returntypes: flag to determine if types should be printed
39 | :type returntypes: boolean.
40 | """
41 | try:
42 | (options, args) = self._parse_arglist(line)
43 | except:
44 | if ("-h" in line) or ("--help" in line):
45 | return ReturnCodes.SUCCESS
46 | else:
47 | raise InvalidCommandLineErrorOPTS("")
48 |
49 | self.typesvalidation(options)
50 |
51 | try:
52 | if len(args) == 0:
53 | typeslist = list()
54 | typeslist = sorted(set(self._rdmc.app.types()))
55 |
56 | if not returntypes:
57 | sys.stdout.write("Type options:")
58 | sys.stdout.write('\n')
59 |
60 | for item in typeslist:
61 | sys.stdout.write(item)
62 | sys.stdout.write('\n')
63 | else:
64 | return typeslist
65 | else:
66 | raise InvalidCommandLineError("The 'types' command does not "\
67 | "take any arguments.")
68 |
69 | except redfish.ris.InstanceNotFoundError as infe:
70 | raise redfish.ris.InstanceNotFoundError(infe)
71 |
72 | def run(self, line):
73 | """ Wrapper function for types main function
74 |
75 | :param line: command line input
76 | :type line: string.
77 | """
78 | self.typesfunction(line)
79 |
80 | #Return code
81 | return ReturnCodes.SUCCESS
82 |
83 | def typesvalidation(self, options):
84 | """ types method validation function
85 |
86 | :param options: command line options
87 | :type options: list.
88 | """
89 | client = None
90 | inputline = list()
91 | runlogin = False
92 |
93 | try:
94 | client = self._rdmc.app.get_current_client()
95 | except:
96 | if options.user or options.password or options.url:
97 | if options.url:
98 | inputline.extend([options.url])
99 | if options.user:
100 | inputline.extend(["-u", options.user])
101 | if options.password:
102 | inputline.extend(["-p", options.password])
103 | else:
104 | if self._rdmc.app.config.get_url():
105 | inputline.extend([self._rdmc.app.config.get_url()])
106 | if self._rdmc.app.config.get_username():
107 | inputline.extend(["-u", \
108 | self._rdmc.app.config.get_username()])
109 | if self._rdmc.app.config.get_password():
110 | inputline.extend(["-p", \
111 | self._rdmc.app.config.get_password()])
112 |
113 | if len(inputline) or not client:
114 | runlogin = True
115 | if options.includelogs:
116 | inputline.extend(["--includelogs"])
117 | if options.path:
118 | inputline.extend(["--path", options.path])
119 |
120 | if runlogin:
121 | self.lobobj.loginfunction(inputline)
122 |
123 | def definearguments(self, customparser):
124 | """ Wrapper function for new command main function
125 |
126 | :param customparser: command line input
127 | :type customparser: parser.
128 | """
129 | if not customparser:
130 | return
131 |
132 | customparser.add_option(
133 | '--url',
134 | dest='url',
135 | help="Use the provided URL to login.",
136 | default=None,
137 | )
138 | customparser.add_option(
139 | '-u',
140 | '--user',
141 | dest='user',
142 | help="If you are not logged in yet, including this flag along"\
143 | " with the password and URL flags can be used to log into a"\
144 | " server in the same command.""",
145 | default=None,
146 | )
147 | customparser.add_option(
148 | '-p',
149 | '--password',
150 | dest='password',
151 | help="""Use the provided password to log in.""",
152 | default=None,
153 | )
154 | customparser.add_option(
155 | '--includelogs',
156 | dest='includelogs',
157 | action="store_true",
158 | help="Optionally include logs in the data retrieval process.",
159 | default=False,
160 | )
161 | customparser.add_option(
162 | '--path',
163 | dest='path',
164 | help="Optionally set a starting point for data collection."\
165 | " If you do not specify a starting point, the default path"\
166 | " will be /redfish/v1/. Note: The path flag can only be specified"\
167 | " at the time of login, so if you are already logged into the"\
168 | " server, the path flag will not change the path. If you are"\
169 | " entering a command that isn't the login command, but include"\
170 | " your login information, you can still specify the path flag"\
171 | " there. ",
172 | default=None,
173 | )
174 |
--------------------------------------------------------------------------------
/docs/slate/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -o errexit #abort if any command fails
3 | me=$(basename "$0")
4 |
5 | help_message="\
6 | Usage: $me [-c FILE] []
7 | Deploy generated files to a git branch.
8 |
9 | Options:
10 |
11 | -h, --help Show this help information.
12 | -v, --verbose Increase verbosity. Useful for debugging.
13 | -e, --allow-empty Allow deployment of an empty directory.
14 | -m, --message MESSAGE Specify the message used when committing on the
15 | deploy branch.
16 | -n, --no-hash Don't append the source commit's hash to the deploy
17 | commit's message.
18 | -c, --config-file PATH Override default & environment variables' values
19 | with those in set in the file at 'PATH'. Must be the
20 | first option specified.
21 |
22 | Variables:
23 |
24 | GIT_DEPLOY_DIR Folder path containing the files to deploy.
25 | GIT_DEPLOY_BRANCH Commit deployable files to this branch.
26 | GIT_DEPLOY_REPO Push the deploy branch to this repository.
27 |
28 | These variables have default values defined in the script. The defaults can be
29 | overridden by environment variables. Any environment variables are overridden
30 | by values set in a '.env' file (if it exists), and in turn by those set in a
31 | file specified by the '--config-file' option."
32 |
33 | bundle exec middleman build --clean
34 |
35 | parse_args() {
36 | # Set args from a local environment file.
37 | if [ -e ".env" ]; then
38 | source .env
39 | fi
40 |
41 | # Set args from file specified on the command-line.
42 | if [[ $1 = "-c" || $1 = "--config-file" ]]; then
43 | source "$2"
44 | shift 2
45 | fi
46 |
47 | # Parse arg flags
48 | # If something is exposed as an environment variable, set/overwrite it
49 | # here. Otherwise, set/overwrite the internal variable instead.
50 | while : ; do
51 | if [[ $1 = "-h" || $1 = "--help" ]]; then
52 | echo "$help_message"
53 | return 0
54 | elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
55 | verbose=true
56 | shift
57 | elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then
58 | allow_empty=true
59 | shift
60 | elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then
61 | commit_message=$2
62 | shift 2
63 | elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then
64 | GIT_DEPLOY_APPEND_HASH=false
65 | shift
66 | else
67 | break
68 | fi
69 | done
70 |
71 | # Set internal option vars from the environment and arg flags. All internal
72 | # vars should be declared here, with sane defaults if applicable.
73 |
74 | # Source directory & target branch.
75 | deploy_directory=build
76 | deploy_branch=gh-pages
77 |
78 | #if no user identity is already set in the current git environment, use this:
79 | default_username=${GIT_DEPLOY_USERNAME:-deploy.sh}
80 | default_email=${GIT_DEPLOY_EMAIL:-}
81 |
82 | #repository to deploy to. must be readable and writable.
83 | repo=origin
84 |
85 | #append commit hash to the end of message by default
86 | append_hash=${GIT_DEPLOY_APPEND_HASH:-true}
87 | }
88 |
89 | main() {
90 | parse_args "$@"
91 |
92 | enable_expanded_output
93 |
94 | if ! git diff --exit-code --quiet --cached; then
95 | echo Aborting due to uncommitted changes in the index >&2
96 | return 1
97 | fi
98 |
99 | commit_title=`git log -n 1 --format="%s" HEAD`
100 | commit_hash=` git log -n 1 --format="%H" HEAD`
101 |
102 | #default commit message uses last title if a custom one is not supplied
103 | if [[ -z $commit_message ]]; then
104 | commit_message="publish: $commit_title"
105 | fi
106 |
107 | #append hash to commit message unless no hash flag was found
108 | if [ $append_hash = true ]; then
109 | commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash"
110 | fi
111 |
112 | previous_branch=`git rev-parse --abbrev-ref HEAD`
113 |
114 | if [ ! -d "$deploy_directory" ]; then
115 | echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2
116 | return 1
117 | fi
118 |
119 | # must use short form of flag in ls for compatibility with OS X and BSD
120 | if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then
121 | echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2
122 | return 1
123 | fi
124 |
125 | if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then
126 | # deploy_branch exists in $repo; make sure we have the latest version
127 |
128 | disable_expanded_output
129 | git fetch --force $repo $deploy_branch:$deploy_branch
130 | enable_expanded_output
131 | fi
132 |
133 | # check if deploy_branch exists locally
134 | if git show-ref --verify --quiet "refs/heads/$deploy_branch"
135 | then incremental_deploy
136 | else initial_deploy
137 | fi
138 |
139 | restore_head
140 | }
141 |
142 | initial_deploy() {
143 | git --work-tree "$deploy_directory" checkout --orphan $deploy_branch
144 | git --work-tree "$deploy_directory" add --all
145 | commit+push
146 | }
147 |
148 | incremental_deploy() {
149 | #make deploy_branch the current branch
150 | git symbolic-ref HEAD refs/heads/$deploy_branch
151 | #put the previously committed contents of deploy_branch into the index
152 | git --work-tree "$deploy_directory" reset --mixed --quiet
153 | git --work-tree "$deploy_directory" add --all
154 |
155 | set +o errexit
156 | diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$?
157 | set -o errexit
158 | case $diff in
159 | 0) echo No changes to files in $deploy_directory. Skipping commit.;;
160 | 1) commit+push;;
161 | *)
162 | echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to main, use: git symbolic-ref HEAD refs/heads/main && git reset --mixed >&2
163 | return $diff
164 | ;;
165 | esac
166 | }
167 |
168 | commit+push() {
169 | set_user_id
170 | git --work-tree "$deploy_directory" commit -m "$commit_message"
171 |
172 | disable_expanded_output
173 | #--quiet is important here to avoid outputting the repo URL, which may contain a secret token
174 | git push --quiet $repo $deploy_branch
175 | enable_expanded_output
176 | }
177 |
178 | #echo expanded commands as they are executed (for debugging)
179 | enable_expanded_output() {
180 | if [ $verbose ]; then
181 | set -o xtrace
182 | set +o verbose
183 | fi
184 | }
185 |
186 | #this is used to avoid outputting the repo URL, which may contain a secret token
187 | disable_expanded_output() {
188 | if [ $verbose ]; then
189 | set +o xtrace
190 | set -o verbose
191 | fi
192 | }
193 |
194 | set_user_id() {
195 | if [[ -z `git config user.name` ]]; then
196 | git config user.name "$default_username"
197 | fi
198 | if [[ -z `git config user.email` ]]; then
199 | git config user.email "$default_email"
200 | fi
201 | }
202 |
203 | restore_head() {
204 | if [[ $previous_branch = "HEAD" ]]; then
205 | #we weren't on any branch before, so just set HEAD back to the commit it was on
206 | git update-ref --no-deref HEAD $commit_hash $deploy_branch
207 | else
208 | git symbolic-ref HEAD refs/heads/$previous_branch
209 | fi
210 |
211 | git reset --mixed
212 | }
213 |
214 | filter() {
215 | sed -e "s|$repo|\$repo|g"
216 | }
217 |
218 | sanitize() {
219 | "$@" 2> >(filter 1>&2) | filter
220 | }
221 |
222 | [[ $1 = --source-only ]] || main "$@"
223 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/RawHeadCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ RawHead Command for rdmc """
8 |
9 | import sys
10 | import json
11 |
12 | import redfish
13 |
14 | from optparse import OptionParser
15 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
16 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
17 | InvalidCommandLineErrorOPTS, UI
18 |
19 | class RawHeadCommand(RdmcCommandBase):
20 | """ Raw form of the head command """
21 | def __init__(self, rdmcObj):
22 | RdmcCommandBase.__init__(self,\
23 | name='rawhead',\
24 | usage='rawhead [PATH]\n\n\tRun to to retrieve data from the ' \
25 | 'passed in path\n\texample: rawhead "/redfish/v1/systems/'\
26 | '(system ID)"',\
27 | summary='This is the raw form of the HEAD command.',\
28 | aliases=['rawhead'],\
29 | optparser=OptionParser())
30 | self.definearguments(self.parser)
31 | self._rdmc = rdmcObj
32 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
33 |
34 | def run(self, line):
35 | """ Main raw head worker function
36 |
37 | :param line: command line input
38 | :type line: string.
39 | """
40 | try:
41 | (options, args) = self._parse_arglist(line)
42 | except:
43 | if ("-h" in line) or ("--help" in line):
44 | return ReturnCodes.SUCCESS
45 | else:
46 | raise InvalidCommandLineErrorOPTS("")
47 | url = None
48 |
49 | if options.sessionid:
50 | url = self.sessionvalidation(options)
51 | else:
52 | self.headvalidation(options)
53 |
54 | if len(args) > 1:
55 | raise InvalidCommandLineError("Raw head only takes 1 argument.\n")
56 | elif len(args) == 0:
57 | raise InvalidCommandLineError("Missing raw head input path.\n")
58 |
59 | if args[0].startswith('"') and args[0].endswith('"'):
60 | args[0] = args[0][1:-1]
61 |
62 | results = self._rdmc.app.head_handler(args[0], \
63 | verbose=self._rdmc.opts.verbose, \
64 | sessionid=options.sessionid, \
65 | url=url, silent=options.silent)
66 |
67 | content = None
68 | tempdict = dict()
69 |
70 | if results and results.status == 200:
71 | if results._http_response:
72 | content = results._http_response.msg.headers
73 | else:
74 | content = results._headers
75 |
76 | for item in content:
77 | if isinstance(item, dict):
78 | for key, value in item.items():
79 | tempdict[key] = value
80 | else:
81 | item = item.replace(": ", ":").replace("\r\n", "").\
82 | split(":", 1)
83 | tempdict[item[0]] = item[1]
84 |
85 | if options.filename:
86 | output = json.dumps(tempdict, indent=2, \
87 | cls=redfish.ris.JSONEncoder)
88 | filehndl = open(options.filename[0], "w")
89 | filehndl.write(output)
90 | filehndl.close()
91 |
92 | sys.stdout.write("Results written out to '%s'.\n" % \
93 | options.filename[0])
94 | else:
95 | UI().print_out_json(tempdict)
96 | else:
97 | return ReturnCodes.NO_CONTENTS_FOUND_FOR_OPERATION
98 |
99 | #Return code
100 | return ReturnCodes.SUCCESS
101 |
102 | def headvalidation(self, options):
103 | """ Raw head validation function
104 |
105 | :param options: command line options
106 | :type options: list.
107 | """
108 | inputline = list()
109 |
110 | try:
111 | self._rdmc.app.get_current_client()
112 | except:
113 | if options.user or options.password or options.url:
114 | if options.url:
115 | inputline.extend([options.url])
116 | if options.user:
117 | inputline.extend(["-u", options.user])
118 | if options.password:
119 | inputline.extend(["-p", options.password])
120 | else:
121 | if self._rdmc.app.config.get_url():
122 | inputline.extend([self._rdmc.app.config.get_url()])
123 | if self._rdmc.app.config.get_username():
124 | inputline.extend(["-u", \
125 | self._rdmc.app.config.get_username()])
126 | if self._rdmc.app.config.get_password():
127 | inputline.extend(["-p", \
128 | self._rdmc.app.config.get_password()])
129 |
130 | self.lobobj.loginfunction(inputline, skipbuild=True)
131 |
132 | def sessionvalidation(self, options):
133 | """ Raw head session validation function
134 |
135 | :param options: command line options
136 | :type options: list.
137 | """
138 |
139 | url = None
140 | if options.user or options.password or options.url:
141 | if options.url:
142 | url = options.url
143 | else:
144 | if self._rdmc.app.config.get_url():
145 | url = self._rdmc.app.config.get_url()
146 | if url and not "https://" in url:
147 | url = "https://" + url
148 |
149 | return url
150 |
151 | def definearguments(self, customparser):
152 | """ Wrapper function for new command main function
153 |
154 | :param customparser: command line input
155 | :type customparser: parser.
156 | """
157 | if not customparser:
158 | return
159 |
160 | customparser.add_option(
161 | '--url',
162 | dest='url',
163 | help="Use the provided URL to login.",
164 | default=None,
165 | )
166 | customparser.add_option(
167 | '-u',
168 | '--user',
169 | dest='user',
170 | help="If you are not logged in yet, including this flag along"\
171 | " with the password and URL flags can be used to log into a"\
172 | " server in the same command.""",
173 | default=None,
174 | )
175 | customparser.add_option(
176 | '-p',
177 | '--password',
178 | dest='password',
179 | help="""Use the provided password to log in.""",
180 | default=None,
181 | )
182 | customparser.add_option(
183 | '--silent',
184 | dest='silent',
185 | action="store_true",
186 | help="""Use this flag to silence responses""",
187 | default=None,
188 | )
189 | customparser.add_option(
190 | '--sessionid',
191 | dest='sessionid',
192 | help="Optionally include this flag if you would prefer to "\
193 | "connect using a session id instead of a normal login.",
194 | default=None
195 | )
196 | customparser.add_option(
197 | '-f',
198 | '--filename',
199 | dest='filename',
200 | help="""Use the provided filename to perform operations.""",
201 | action="append",
202 | default=None,
203 | )
204 |
--------------------------------------------------------------------------------
/src/rdmc_base_classes.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- coding: utf-8 -*-
8 | """This is the helper module for RDMC"""
9 |
10 | #---------Imports---------
11 |
12 | import os
13 | import six
14 | import glob
15 | import shlex
16 |
17 | import versioning
18 | from optparse import OptionParser, OptionGroup
19 |
20 | import cliutils
21 |
22 | #---------End of imports---------
23 |
24 | #Using hard coded list until better solution is found
25 | HARDCODEDLIST = ["name", "description", "status", "links", "members", "id",
26 | "relateditem", "actions", "oem"]
27 |
28 | class CommandBase(object):
29 | """Abstract base class for all Command objects.
30 |
31 | This class is used to build complex command line programs
32 | """
33 | def __init__(self, name, usage, summary, aliases=None, optparser=None):
34 | self.name = name
35 | self.summary = summary
36 | self.aliases = aliases
37 | self.config_required = True # does the command access config data
38 |
39 | if optparser is None:
40 | self.parser = cliutils.CustomOptionParser()
41 | else:
42 | self.parser = optparser
43 |
44 | self.parser.usage = usage
45 | self._cli = cliutils.CLI()
46 |
47 | def run(self, line, rmdcopts):
48 | """Called to actually perform the work.
49 |
50 | Override this method in your derived class. This is where your program
51 | actually does work.
52 | """
53 | pass
54 |
55 | def ismatch(self, cmdname):
56 | """Compare cmdname against possible aliases.
57 |
58 | Commands can have aliases for syntactic sugar. This method searches
59 | aliases for a match.
60 |
61 | :param cmdname: name or alias to search for
62 | :type cmdname: str.
63 | :returns: boolean -- True if it matches, otherwise False
64 | """
65 | if cmdname is None or len(cmdname) == 0:
66 | return False
67 |
68 | cmdname_lower = cmdname.lower()
69 | if self.name.lower() == cmdname_lower:
70 | return True
71 |
72 | if self.aliases:
73 | for alias in self.aliases:
74 | if alias.lower() == cmdname_lower:
75 | return True
76 |
77 | return False
78 |
79 | def print_help(self):
80 | """Automated help printer.
81 | """
82 | self.parser.print_help()
83 |
84 | def print_summary(self):
85 | """Automated summary printer.
86 | """
87 | maxsum = 45
88 | smry = self.summary
89 |
90 | if not smry:
91 | smry = ''
92 |
93 | sumwords = smry.split(' ')
94 | lines = []
95 | line = []
96 | linelength = 0
97 |
98 | for sword in sumwords:
99 | if linelength + len(sword) > maxsum:
100 | lines.append(' '.join(line))
101 | line = []
102 | linelength = 0
103 |
104 | line.append(sword)
105 | linelength += len(sword) + 1
106 |
107 | lines.append(' '.join(line))
108 |
109 | sep = '\n' + (' ' * 34)
110 | print((" %-28s - %s" % (self.name, sep.join(lines))))
111 |
112 | def _parse_arglist(self, line=None):
113 | """parses line into an options and args taking
114 | special consideration of quote characters into account
115 |
116 | :param line: string of arguments passed in
117 | :type line: str.
118 | :returns: args list
119 | """
120 | if line is None:
121 | return self.parser.parse_args(line)
122 |
123 | arglist = []
124 | if isinstance(line, six.string_types):
125 | arglist = shlex.split(line, posix=False)
126 | for ind, val in enumerate(arglist):
127 | arglist[ind] = val.strip('"\'')
128 | elif isinstance(line, list):
129 | arglist = line
130 |
131 | exarglist = []
132 | if os.name == 'nt':
133 | # need to glob for windows
134 | for arg in arglist:
135 | gob = glob.glob(arg)
136 |
137 | if gob and len(gob) > 0:
138 | exarglist.extend(gob)
139 | else:
140 | exarglist.append(arg)
141 |
142 | else:
143 | for arg in arglist:
144 | exarglist.append(arg)
145 |
146 | return self.parser.parse_args(exarglist)
147 |
148 | class RdmcCommandBase(CommandBase):
149 | """Base class for rdmc commands which includes some common helper
150 | methods.
151 | """
152 |
153 | def __init__(self, name, usage, summary, aliases, optparser=None):
154 | """ Constructor """
155 | CommandBase.__init__(self,\
156 | name=name,\
157 | usage=usage,\
158 | summary=summary,\
159 | aliases=aliases,\
160 | optparser=optparser)
161 | self.json = False
162 | self.cache = False
163 | self.nologo = False
164 |
165 | def is_enabled(self):
166 | """ If reachable return true for command """
167 | return True
168 |
169 | def enablement_hint(self):
170 | """
171 | Override to define a error message displayed to the user
172 | when command is not enabled.
173 | """
174 | return ""
175 |
176 | class RdmcOptionParser(OptionParser):
177 | """ Constructor """
178 | def __init__(self):
179 | OptionParser.__init__(self,\
180 | usage="Usage: %s [GLOBAL OPTIONS] [COMMAND] [ARGUMENTS]"\
181 | " [COMMAND OPTIONS]" % versioning.__shortname__)
182 |
183 | globalgroup = OptionGroup(self, "GLOBAL OPTIONS")
184 |
185 | #to correct the capitalization on help text:
186 | self.option_list[0].help = 'Show this help message and exit.'
187 |
188 | self.add_option(
189 | '-c',
190 | '--config',
191 | dest='config',
192 | help="Use the provided configuration file instead of the default"\
193 | " one.",
194 | metavar='FILE'
195 | )
196 |
197 | config_dir_default = os.path.join(cliutils.get_user_config_dir(),\
198 | '.%s' % versioning.__shortname__)
199 | self.add_option(
200 | '--cache-dir',
201 | dest='config_dir',
202 | default=config_dir_default,
203 | help="Use the provided directory as the location to cache data"\
204 | " (default location: %s)" % config_dir_default,
205 | metavar='PATH'
206 | )
207 |
208 | globalgroup.add_option(
209 | '-v',
210 | '--verbose',
211 | dest='verbose',
212 | action="store_true",
213 | help="""Display verbose information.""",
214 | default=False
215 | )
216 |
217 | globalgroup.add_option(
218 | '-d',
219 | '--debug',
220 | dest='debug',
221 | action="store_true",
222 | help="""Display debug information.""",
223 | default=False
224 | )
225 |
226 | globalgroup.add_option(
227 | '--nocache',
228 | dest='nocache',
229 | action="store_true",
230 | help="During execution the application will temporarily store"\
231 | " data only in memory.",
232 | default=False
233 | )
234 |
235 | globalgroup.add_option(
236 | '--nologo',
237 | dest='nologo',
238 | action="store_true",
239 | help="""Include to block logo.""",
240 | default=False
241 | )
242 |
243 | self.add_option_group(globalgroup)
244 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/RawPutCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ RawPut Command for rdmc """
8 |
9 | import sys
10 | import json
11 |
12 | from optparse import OptionParser
13 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
14 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
15 | InvalidCommandLineErrorOPTS, UI, InvalidFileInputError, \
16 | InvalidFileFormattingError
17 |
18 | class RawPutCommand(RdmcCommandBase):
19 | """ Raw form of the put command """
20 | def __init__(self, rdmcObj):
21 | RdmcCommandBase.__init__(self,\
22 | name='rawput',\
23 | usage='rawput [FILENAME] [OPTIONS]\n\n\tRun to send a post from ' \
24 | 'the data in the input file.\n\texample: rawput rawput.' \
25 | 'txt\n\n\tExample input file:\n\t{\n\t "path": "/redfish/' \
26 | 'v1/(put path)",\n\t "body":{\n\t ' \
27 | ' "PutProperty": "PutValue"\n\t }\n\t}',
28 | summary='This is the raw form of the PUT command.',\
29 | aliases=['rawput'],\
30 | optparser=OptionParser())
31 | self.definearguments(self.parser)
32 | self._rdmc = rdmcObj
33 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
34 |
35 | def run(self, line):
36 | """ Main raw put worker function
37 |
38 | :param line: command line input
39 | :type line: string.
40 | """
41 | try:
42 | (options, args) = self._parse_arglist(line)
43 | except:
44 | if ("-h" in line) or ("--help" in line):
45 | return ReturnCodes.SUCCESS
46 | else:
47 | raise InvalidCommandLineErrorOPTS("")
48 |
49 | url = None
50 | headers = {}
51 | results = None
52 |
53 | if options.sessionid:
54 | url = self.sessionvalidation(options)
55 | else:
56 | self.putvalidation(options)
57 |
58 | contentsholder = None
59 |
60 | if len(args) == 1:
61 | try:
62 | inputfile = open(args[0], 'r')
63 | contentsholder = json.loads(inputfile.read())
64 | except Exception as excp:
65 | raise InvalidFileInputError("%s" % excp)
66 | elif len(args) > 1:
67 | raise InvalidCommandLineError("Raw put only takes 1 argument.\n")
68 | else:
69 | raise InvalidCommandLineError("Missing raw put file input "\
70 | "argument.\n")
71 |
72 | if options.headers:
73 | extraheaders = options.headers.split(',')
74 |
75 | for item in extraheaders:
76 | header = item.split(':')
77 |
78 | try:
79 | headers[header[0]] = header[1]
80 | except:
81 | raise InvalidCommandLineError("Invalid format for " \
82 | "--headers option.")
83 |
84 | if "path" in contentsholder and "body" in contentsholder:
85 | returnresponse = False
86 |
87 | if options.response or options.getheaders:
88 | returnresponse = True
89 |
90 | results = self._rdmc.app.put_handler(contentsholder["path"], \
91 | contentsholder["body"], verbose=self._rdmc.opts.verbose, \
92 | sessionid=options.sessionid, url=url, headers=headers, \
93 | response=returnresponse, silent=options.silent)
94 | else:
95 | raise InvalidFileFormattingError("Input file '%s' was not "\
96 | "formatted properly." % args[0])
97 |
98 | if results and returnresponse:
99 | if options.getheaders:
100 | sys.stdout.write(json.dumps(dict(\
101 | results._http_response.getheaders())) + "\n")
102 |
103 | if options.response:
104 | sys.stdout.write(results.text)
105 |
106 | #Return code
107 | return ReturnCodes.SUCCESS
108 |
109 | def putvalidation(self, options):
110 | """ Raw put validation function
111 |
112 | :param options: command line options
113 | :type options: list.
114 | """
115 | inputline = list()
116 |
117 | try:
118 | self._rdmc.app.get_current_client()
119 |
120 | except:
121 | if options.user or options.password or options.url:
122 | if options.url:
123 | inputline.extend([options.url])
124 | if options.user:
125 | inputline.extend(["-u", options.user])
126 | if options.password:
127 | inputline.extend(["-p", options.password])
128 | else:
129 | if self._rdmc.app.config.get_url():
130 | inputline.extend([self._rdmc.app.config.get_url()])
131 | if self._rdmc.app.config.get_username():
132 | inputline.extend(["-u", \
133 | self._rdmc.app.config.get_username()])
134 | if self._rdmc.app.config.get_password():
135 | inputline.extend(["-p", \
136 | self._rdmc.app.config.get_password()])
137 | self.lobobj.loginfunction(inputline, skipbuild=True)
138 |
139 | def sessionvalidation(self, options):
140 | """ Raw put session validation function
141 |
142 | :param options: command line options
143 | :type options: list.
144 | """
145 |
146 | url = None
147 | if options.user or options.password or options.url:
148 | if options.url:
149 | url = options.url
150 | else:
151 | if self._rdmc.app.config.get_url():
152 | url = self._rdmc.app.config.get_url()
153 | if url and not "https://" in url:
154 | url = "https://" + url
155 |
156 | return url
157 |
158 | def definearguments(self, customparser):
159 | """ Wrapper function for new command main function
160 |
161 | :param customparser: command line input
162 | :type customparser: parser.
163 | """
164 | if not customparser:
165 | return
166 |
167 | customparser.add_option(
168 | '--url',
169 | dest='url',
170 | help="Use the provided URL to login.",
171 | default=None,
172 | )
173 | customparser.add_option(
174 | '-u',
175 | '--user',
176 | dest='user',
177 | help="If you are not logged in yet, including this flag along"\
178 | " with the password and URL flags can be used to log into a"\
179 | " server in the same command.""",
180 | default=None,
181 | )
182 | customparser.add_option(
183 | '-p',
184 | '--password',
185 | dest='password',
186 | help="""Use the provided password to log in.""",
187 | default=None,
188 | )
189 | customparser.add_option(
190 | '--response',
191 | dest='response',
192 | action="store_true",
193 | help="Use this flag to return the response body.",
194 | default=False
195 | )
196 | customparser.add_option(
197 | '--getheaders',
198 | dest='getheaders',
199 | action="store_true",
200 | help="Use this flag to return the response headers.",
201 | default=False
202 | )
203 | customparser.add_option(
204 | '--headers',
205 | dest='headers',
206 | help="Use this flag to add extra headers to the request."\
207 | "\t\t\t\t\t Usage: --headers=HEADER:VALUE,HEADER:VALUE",
208 | default=None,
209 | )
210 | customparser.add_option(
211 | '--silent',
212 | dest='silent',
213 | action="store_true",
214 | help="""Use this flag to silence responses""",
215 | default=False,
216 | )
217 | customparser.add_option(
218 | '--sessionid',
219 | dest='sessionid',
220 | help="Optionally include this flag if you would prefer to "\
221 | "connect using a session id instead of a normal login.",
222 | default=None
223 | )
224 |
225 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/RawDeleteCommand.py:
--------------------------------------------------------------------------------
1 | """ RawDelete Command for RDMC """
2 |
3 | import sys
4 | import json
5 |
6 | from optparse import OptionParser
7 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
8 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
9 | InvalidCommandLineErrorOPTS, UI
10 |
11 | class RawDeleteCommand(RdmcCommandBase):
12 | """ Raw form of the delete command """
13 | def __init__(self, rdmcObj):
14 | RdmcCommandBase.__init__(self,\
15 | name='rawdelete',\
16 | usage='rawdelete [PATH] [OPTIONS]\n\n\tRun to to delete data from' \
17 | ' the passed in path.\n\texample: rawdelete "/redfish/v1/' \
18 | 'Sessions/(session ID)"',
19 | summary='This is the raw form of the DELETE command.',\
20 | aliases=['rawdelete'],\
21 | optparser=OptionParser())
22 | self.definearguments(self.parser)
23 | self._rdmc = rdmcObj
24 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
25 |
26 | def run(self, line):
27 | """ Main raw delete worker function
28 |
29 | :param line: command line input
30 | :type line: string.
31 | """
32 | try:
33 | (options, args) = self._parse_arglist(line)
34 | except:
35 | if ("-h" in line) or ("--help" in line):
36 | return ReturnCodes.SUCCESS
37 | else:
38 | raise InvalidCommandLineErrorOPTS("")
39 |
40 | url = None
41 | headers = {}
42 |
43 | if options.sessionid:
44 | url = self.sessionvalidation(options)
45 | else:
46 | self.deletevalidation(options)
47 |
48 | if len(args) > 1:
49 | raise InvalidCommandLineError("Raw delete only takes 1 argument.\n")
50 | elif len(args) == 0:
51 | raise InvalidCommandLineError("Missing raw delete input path.\n")
52 |
53 | if args[0].startswith('"') and args[0].endswith('"'):
54 | args[0] = args[0][1:-1]
55 |
56 | if options.expand:
57 | args[0] = args[0] + '?$expand=.'
58 |
59 | try:
60 | currentsess = self._rdmc.app.current_client._rest_client.\
61 | _RestClientBase__session_location
62 | except:
63 | currentsess=None
64 |
65 | if options.headers:
66 | extraheaders = options.headers.split(',')
67 |
68 | for item in extraheaders:
69 | header = item.split(':')
70 |
71 | try:
72 | headers[header[0]] = header[1]
73 | except:
74 | InvalidCommandLineError("Invalid format for --headers " \
75 | "option.")
76 |
77 | if currentsess and (args[0] in currentsess):
78 | self._rdmc.app.logout()
79 | sys.stdout.write("Your session has been deleted.\nPlease log "\
80 | "back in if you wish to continue.\n")
81 | else:
82 | returnresponse = False
83 |
84 | if options.response or options.getheaders:
85 | returnresponse = True
86 |
87 | results = self._rdmc.app.delete_handler(args[0], \
88 | verbose=self._rdmc.opts.verbose, sessionid=options.sessionid, \
89 | url=url, headers=headers, silent=options.silent)
90 |
91 | if returnresponse and results:
92 | if options.getheaders:
93 | sys.stdout.write(json.dumps(dict(\
94 | results._http_response.getheaders())) + "\n")
95 |
96 | if options.response:
97 | sys.stdout.write(results.text)
98 | elif results.status == 404:
99 | return ReturnCodes.NO_CONTENTS_FOUND_FOR_OPERATION
100 | elif results.status != 200:
101 | return ReturnCodes.UI_CLI_USAGE_EXCEPTION
102 |
103 | #Return code
104 | return ReturnCodes.SUCCESS
105 |
106 | def deletevalidation(self, options):
107 | """ Raw delete validation function
108 |
109 | :param options: command line options
110 | :type options: list.
111 | """
112 | inputline = list()
113 |
114 | try:
115 | self._rdmc.app.get_current_client()
116 | except:
117 | if options.user or options.password or options.url:
118 | if options.url:
119 | inputline.extend([options.url])
120 | if options.user:
121 | inputline.extend(["-u", options.user])
122 | if options.password:
123 | inputline.extend(["-p", options.password])
124 | else:
125 | if self._rdmc.app.config.get_url():
126 | inputline.extend([self._rdmc.app.config.get_url()])
127 | if self._rdmc.app.config.get_username():
128 | inputline.extend(["-u", \
129 | self._rdmc.app.config.get_username()])
130 | if self._rdmc.app.config.get_password():
131 | inputline.extend(["-p", \
132 | self._rdmc.app.config.get_password()])
133 |
134 | self.lobobj.loginfunction(inputline, skipbuild=True)
135 |
136 | def sessionvalidation(self, options):
137 | """ Raw delete session validation function
138 |
139 | :param options: command line options
140 | :type options: list.
141 | """
142 |
143 | if options.user or options.password or options.url:
144 | if options.url:
145 | url = options.url
146 | else:
147 | if self._rdmc.app.config.get_url():
148 | url = self._rdmc.app.config.get_url()
149 | if not "https://" in url:
150 | url = "https://" + url
151 |
152 | return url
153 |
154 | def definearguments(self, customparser):
155 | """ Wrapper function for new command main function
156 |
157 | :param customparser: command line input
158 | :type customparser: parser.
159 | """
160 | if not customparser:
161 | return
162 |
163 | customparser.add_option(
164 | '--url',
165 | dest='url',
166 | help="Use the provided URL to login.",
167 | default=None,
168 | )
169 | customparser.add_option(
170 | '-u',
171 | '--user',
172 | dest='user',
173 | help="If you are not logged in yet, including this flag along"\
174 | " with the password and URL flags can be used to log into a"\
175 | " server in the same command.""",
176 | default=None,
177 | )
178 | customparser.add_option(
179 | '-p',
180 | '--password',
181 | dest='password',
182 | help="""Use the provided password to log in.""",
183 | default=None,
184 | )
185 | customparser.add_option(
186 | '--response',
187 | dest='response',
188 | action="store_true",
189 | help="Use this flag to return the response body.",
190 | default=False
191 | )
192 | customparser.add_option(
193 | '--getheaders',
194 | dest='getheaders',
195 | action="store_true",
196 | help="Use this flag to return the response headers.",
197 | default=False
198 | )
199 | customparser.add_option(
200 | '--headers',
201 | dest='headers',
202 | help="Use this flag to add extra headers to the request."\
203 | "\t\t\t\t\t Usage: --headers=HEADER:VALUE,HEADER:VALUE",
204 | default=None,
205 | )
206 | customparser.add_option(
207 | '--silent',
208 | dest='silent',
209 | action="store_true",
210 | help="""Use this flag to silence responses""",
211 | default=False,
212 | )
213 | customparser.add_option(
214 | '--sessionid',
215 | dest='sessionid',
216 | help="Optionally include this flag if you would prefer to "\
217 | "connect using a session id instead of a normal login.",
218 | default=None
219 | )
220 | customparser.add_option(
221 | '--expand',
222 | dest='expand',
223 | action="store_true",
224 | help="""Use this flag to expand the path specified using the """\
225 | """expand notation '?$expand=.'""",
226 | default=False,
227 | )
228 |
229 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/RawPostCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ RawPost Command for rdmc """
8 |
9 | import sys
10 | import json
11 |
12 | from optparse import OptionParser
13 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
14 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
15 | InvalidCommandLineErrorOPTS, UI, InvalidFileInputError, \
16 | InvalidFileFormattingError
17 |
18 | class RawPostCommand(RdmcCommandBase):
19 | """ Raw form of the post command """
20 | def __init__(self, rdmcObj):
21 | RdmcCommandBase.__init__(self,\
22 | name='rawpost',\
23 | usage='rawpost [FILENAME] [OPTIONS]\n\n\tRun to send a post from ' \
24 | 'the data in the input file.\n\texample: rawpost rawpost.' \
25 | 'txt\n\n\tExample input file:\n\t{\n\t "path": "/' \
26 | 'redfish/v1/systems/(system ID)/Actions/ComputerSystem.'
27 | 'Reset",\n\t "body": {\n\t "ResetType": '\
28 | '"ForceRestart"\n\t }\n\t}',\
29 | summary='This is the raw form of the POST command.',\
30 | aliases=['rawpost'],\
31 | optparser=OptionParser())
32 | self.definearguments(self.parser)
33 | self._rdmc = rdmcObj
34 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
35 |
36 | def run(self, line):
37 | """ Main raw patch worker function
38 |
39 | :param line: command line input
40 | :type line: string.
41 | """
42 | try:
43 | (options, args) = self._parse_arglist(line)
44 | except:
45 | if ("-h" in line) or ("--help" in line):
46 | return ReturnCodes.SUCCESS
47 | else:
48 | raise InvalidCommandLineErrorOPTS("")
49 |
50 | url = None
51 | headers = {}
52 | results = None
53 |
54 | if options.sessionid:
55 | url = self.sessionvalidation(options)
56 | else:
57 | self.postvalidation(options)
58 |
59 | contentsholder = None
60 |
61 | if len(args) == 1:
62 | try:
63 | inputfile = open(args[0], 'r')
64 | contentsholder = json.loads(inputfile.read())
65 | except Exception as excp:
66 | raise InvalidFileInputError("%s" % excp)
67 | elif len(args) > 1:
68 | raise InvalidCommandLineError("Raw post only takes 1 argument.\n")
69 | else:
70 | raise InvalidCommandLineError("Missing raw post file input "\
71 | "argument.\n")
72 |
73 | if options.headers:
74 | extraheaders = options.headers.split(',')
75 | for item in extraheaders:
76 | header = item.split(':')
77 | try:
78 | headers[header[0]] = header[1]
79 | except:
80 | raise InvalidCommandLineError("Invalid format for " \
81 | "--headers option.")
82 |
83 | if "path" in contentsholder and "body" in contentsholder:
84 | returnresponse = False
85 |
86 | if options.response or options.getheaders:
87 | returnresponse = True
88 |
89 | results = self._rdmc.app.post_handler(contentsholder["path"], \
90 | contentsholder["body"], verbose=self._rdmc.opts.verbose, \
91 | sessionid=options.sessionid, url=url, headers=headers, \
92 | response=returnresponse, silent=options.silent)
93 | else:
94 | raise InvalidFileFormattingError("Input file '%s' was not "\
95 | "formatted properly." % args[0])
96 |
97 | if results and returnresponse:
98 | if options.getheaders:
99 | sys.stdout.write(json.dumps(dict(\
100 | results._http_response.getheaders())) + "\n")
101 |
102 | if options.response:
103 | sys.stdout.write(results.text)
104 |
105 | #Return code
106 | return ReturnCodes.SUCCESS
107 |
108 | def postvalidation(self, options):
109 | """ Raw post validation function
110 |
111 | :param options: command line options
112 | :type options: list.
113 | """
114 | inputline = list()
115 |
116 | try:
117 | self._rdmc.app.get_current_client()
118 | except:
119 | if options.user or options.password or options.url:
120 | if options.url:
121 | inputline.extend([options.url])
122 | if options.user:
123 | inputline.extend(["-u", options.user])
124 | if options.password:
125 | inputline.extend(["-p", options.password])
126 | else:
127 | if self._rdmc.app.config.get_url():
128 | inputline.extend([self._rdmc.app.config.get_url()])
129 | if self._rdmc.app.config.get_username():
130 | inputline.extend(["-u", \
131 | self._rdmc.app.config.get_username()])
132 | if self._rdmc.app.config.get_password():
133 | inputline.extend(["-p", \
134 | self._rdmc.app.config.get_password()])
135 |
136 | self.lobobj.loginfunction(inputline, skipbuild=True)
137 |
138 | def sessionvalidation(self, options):
139 | """ Raw post session validation function
140 |
141 | :param options: command line options
142 | :type options: list.
143 | """
144 |
145 | url = None
146 | if options.user or options.password or options.url:
147 | if options.url:
148 | url = options.url
149 | else:
150 | if self._rdmc.app.config.get_url():
151 | url = self._rdmc.app.config.get_url()
152 | if url and not "https://" in url:
153 | url = "https://" + url
154 |
155 | return url
156 |
157 | def definearguments(self, customparser):
158 | """ Wrapper function for new command main function
159 |
160 | :param customparser: command line input
161 | :type customparser: parser.
162 | """
163 | if not customparser:
164 | return
165 |
166 | customparser.add_option(
167 | '--url',
168 | dest='url',
169 | help="Use the provided URL to login.",
170 | default=None,
171 | )
172 | customparser.add_option(
173 | '-u',
174 | '--user',
175 | dest='user',
176 | help="If you are not logged in yet, including this flag along"\
177 | " with the password and URL flags can be used to log into a"\
178 | " server in the same command.""",
179 | default=None,
180 | )
181 | customparser.add_option(
182 | '-p',
183 | '--password',
184 | dest='password',
185 | help="""Use the provided password to log in.""",
186 | default=None,
187 | )
188 | customparser.add_option(
189 | '--response',
190 | dest='response',
191 | action="store_true",
192 | help="Use this flag to return the response body.",
193 | default=False
194 | )
195 | customparser.add_option(
196 | '--getheaders',
197 | dest='getheaders',
198 | action="store_true",
199 | help="Use this flag to return the response headers.",
200 | default=False
201 | )
202 | customparser.add_option(
203 | '--headers',
204 | dest='headers',
205 | help="Use this flag to add extra headers to the request."\
206 | "\t\t\t\t\t Usage: --headers=HEADER:VALUE,HEADER:VALUE",
207 | default=None,
208 | )
209 | customparser.add_option(
210 | '--silent',
211 | dest='silent',
212 | action="store_true",
213 | help="""Use this flag to silence responses""",
214 | default=False,
215 | )
216 | customparser.add_option(
217 | '--sessionid',
218 | dest='sessionid',
219 | help="Optionally include this flag if you would prefer to "\
220 | "connect using a session id instead of a normal login.",
221 | default=None
222 | )
223 |
224 |
--------------------------------------------------------------------------------
/src/extensions/COMMANDS/SelectCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | # -*- coding: utf-8 -*-
8 | """ Select Command for RDMC """
9 |
10 | import sys
11 | import redfish.ris
12 |
13 | from optparse import OptionParser
14 | from rdmc_base_classes import RdmcCommandBase
15 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
16 | InvalidCommandLineErrorOPTS
17 |
18 | class SelectCommand(RdmcCommandBase):
19 | """ Constructor """
20 | def __init__(self, rdmcObj):
21 | RdmcCommandBase.__init__(self,\
22 | name='select',\
23 | usage='select [TYPE] [OPTIONS]\n\n\tRun without a type to display' \
24 | ' currently selected type\n\texample: select\n\n\tIn order to ' \
25 | 'remove the need of including the version\n\twhile ' \
26 | 'selecting you can simply enter the type name\n\tuntil ' \
27 | 'the first period\n\texample: select ComputerSystem.',\
28 | summary='Selects the object type to be used.',\
29 | aliases=['sel'],\
30 | optparser=OptionParser())
31 | self.definearguments(self.parser)
32 | self._rdmc = rdmcObj
33 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
34 |
35 | def selectfunction(self, line):
36 | """ Main select worker function
37 |
38 | :param line: command line input
39 | :type line: string.
40 | """
41 | try:
42 | (options, args) = self._parse_arglist(line)
43 | except:
44 | if ("-h" in line) or ("--help" in line):
45 | return ReturnCodes.SUCCESS
46 | else:
47 | raise InvalidCommandLineErrorOPTS("")
48 |
49 | self.selectvalidation(options)
50 |
51 | try:
52 | if len(args) > 0:
53 | sel = None
54 | val = None
55 |
56 | if options.filter:
57 | try:
58 | if (str(options.filter)[0] == str(options.filter)[-1])\
59 | and str(options.filter).startswith(("'", '"')):
60 | options.filter = options.filter[1:-1]
61 |
62 | (sel, val) = options.filter.split('=')
63 | sel = sel.strip()
64 | val = val.strip()
65 |
66 | if val.lower() == "true" or val.lower() == "false":
67 | val = val.lower() in ("yes", "true", "t", "1")
68 | except:
69 | raise InvalidCommandLineError("Invalid filter" \
70 | " parameter format [filter_attribute]=[filter_value]")
71 | else:
72 | self._rdmc.app.erase_filter_settings()
73 |
74 | selections = self._rdmc.app.select(query=args, sel=sel, val=val)
75 |
76 | if self._rdmc.opts.verbose and selections:
77 | templist = list()
78 | sys.stdout.write("Selected option(s): ")
79 |
80 | for item in selections:
81 | if item.type not in templist:
82 | templist.append(item.type)
83 |
84 | sys.stdout.write('%s' % ', '.join(map(str, templist)))
85 | sys.stdout.write('\n')
86 | else:
87 | selector = self._rdmc.app.get_selector()
88 |
89 | if selector:
90 | sys.stdout.write("Current selection: '%s'" % selector)
91 | sys.stdout.write('\n')
92 | else:
93 | raise InvalidCommandLineError("No type currently selected."\
94 | " Please use the 'types' command to\nget a" \
95 | " list of types, or pass your type by using" \
96 | " the '--selector' flag.")
97 |
98 | except redfish.ris.InstanceNotFoundError as infe:
99 | raise redfish.ris.InstanceNotFoundError(infe)
100 |
101 | def selectvalidation(self, options):
102 | """ Select data validation function
103 |
104 | :param options: command line options
105 | :type options: list.
106 | """
107 | client = None
108 | runlogin = False
109 | inputline = list()
110 |
111 | try:
112 | client = self._rdmc.app.get_current_client()
113 | except:
114 | if options.user or options.password or options.url:
115 | if options.url:
116 | inputline.extend([options.url])
117 | if options.user:
118 | inputline.extend(["-u", options.user])
119 | if options.password:
120 | inputline.extend(["-p", options.password])
121 | else:
122 | if self._rdmc.app.config.get_url():
123 | inputline.extend([self._rdmc.app.config.get_url()])
124 | if self._rdmc.app.config.get_username():
125 | inputline.extend(["-u", \
126 | self._rdmc.app.config.get_username()])
127 | if self._rdmc.app.config.get_password():
128 | inputline.extend(["-p", \
129 | self._rdmc.app.config.get_password()])
130 |
131 | if len(inputline):
132 | runlogin = True
133 | if options.includelogs:
134 | inputline.extend(["--includelogs"])
135 | if options.path:
136 | inputline.extend(["--path", options.path])
137 | if not client or runlogin:
138 | self.lobobj.loginfunction(inputline)
139 |
140 | def run(self, line):
141 | """ Wrapper function for main select function
142 |
143 | :param line: entered command line
144 | :type line: list.
145 | """
146 | self.selectfunction(line)
147 |
148 | #Return code
149 | return ReturnCodes.SUCCESS
150 |
151 | def definearguments(self, customparser):
152 | """ Wrapper function for new command main function
153 |
154 | :param customparser: command line input
155 | :type customparser: parser.
156 | """
157 | if not customparser:
158 | return
159 |
160 | customparser.add_option(
161 | '--url',
162 | dest='url',
163 | help="Use the provided URL to login.",
164 | default=None,
165 | )
166 | customparser.add_option(
167 | '-u',
168 | '--user',
169 | dest='user',
170 | help="If you are not logged in yet, including this flag along"\
171 | " with the password and URL flags can be used to log into a"\
172 | " server in the same command.""",
173 | default=None,
174 | )
175 | customparser.add_option(
176 | '-p',
177 | '--password',
178 | dest='password',
179 | help="""Use the provided password to log in.""",
180 | default=None,
181 | )
182 | customparser.add_option(
183 | '--includelogs',
184 | dest='includelogs',
185 | action="store_true",
186 | help="Optionally include logs in the data retrieval process.",
187 | default=False,
188 | )
189 | customparser.add_option(
190 | '--filter',
191 | dest='filter',
192 | help="Optionally set a filter value for a filter attribute."\
193 | " This uses the provided filter for the currently selected"\
194 | " type. Note: Use this flag to narrow down your results. For"\
195 | " example, selecting a common type might return multiple"\
196 | " objects that are all of that type. If you want to modify"\
197 | " the properties of only one of those objects, use the filter"\
198 | " flag to narrow down results based on properties."\
199 | "\t\t\t\t\t Usage: --filter [ATTRIBUTE]=[VALUE]",
200 | default=None,
201 | )
202 | customparser.add_option(
203 | '--path',
204 | dest='path',
205 | help="Optionally set a starting point for data collection."\
206 | " If you do not specify a starting point, the default path"\
207 | " will be /redfish/v1/. Note: The path flag can only be specified"\
208 | " at the time of login, so if you are already logged into the"\
209 | " server, the path flag will not change the path. If you are"\
210 | " entering a command that isn't the login command, but include"\
211 | " your login information, you can still specify the path flag"\
212 | " there. ",
213 | default=None,
214 | )
215 |
216 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/RawPatchCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ RawPatch Command for rdmc """
8 |
9 | import os
10 | import sys
11 | import json
12 |
13 | from optparse import OptionParser
14 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
15 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
16 | InvalidCommandLineErrorOPTS, UI, InvalidFileInputError, \
17 | InvalidFileFormattingError
18 |
19 | class RawPatchCommand(RdmcCommandBase):
20 | """ Raw form of the patch command """
21 | def __init__(self, rdmcObj):
22 | RdmcCommandBase.__init__(self,\
23 | name='rawpatch',\
24 | usage='rawpatch [FILENAME]\n\n\tRun to send a patch from the data' \
25 | ' in the input file.\n\texample: rawpatch rawpatch.txt' \
26 | '\n\n\tExample input file:\n\t{\n\t "path": "/redfish/' \
27 | 'v1/systems/(system ID)",\n\t "body": {\n\t ' \
28 | '"AssetTag": "NewAssetTag"\n\t }\n\t}',
29 | summary='This is the raw form of the PATCH command.',\
30 | aliases=['rawpatch'],\
31 | optparser=OptionParser())
32 | self.definearguments(self.parser)
33 | self._rdmc = rdmcObj
34 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
35 |
36 | def run(self, line):
37 | """ Main raw patch worker function
38 |
39 | :param line: command line input
40 | :type line: string.
41 | """
42 | try:
43 | (options, args) = self._parse_arglist(line)
44 | except:
45 | if ("-h" in line) or ("--help" in line):
46 | return ReturnCodes.SUCCESS
47 | else:
48 | raise InvalidCommandLineErrorOPTS("")
49 |
50 | url=None
51 | headers = {}
52 | results = None
53 |
54 | if options.sessionid:
55 | url = self.sessionvalidation(options)
56 | else:
57 | self.patchvalidation(options)
58 |
59 | contentsholder = None
60 | if len(args) == 1:
61 | if not os.path.isfile(args[0]):
62 | raise InvalidFileInputError("File '%s' doesn't exist. " \
63 | "Please create file by running 'save' command." % args[0])
64 |
65 | try:
66 | inputfile = open(args[0], 'r')
67 | contentsholder = json.loads(inputfile.read())
68 | except:
69 | raise InvalidFileFormattingError("Input file '%s' was not " \
70 | "format properly." % args[0])
71 | elif len(args) > 1:
72 | raise InvalidCommandLineError("Raw patch only takes 1 argument.\n")
73 | else:
74 | raise InvalidCommandLineError("Missing raw patch file input "\
75 | "argument.\n")
76 |
77 | if options.headers:
78 | extraheaders = options.headers.split(',')
79 |
80 | for item in extraheaders:
81 | header = item.split(':')
82 |
83 | try:
84 | headers[header[0]] = header[1]
85 | except:
86 | raise InvalidCommandLineError("Invalid format for " \
87 | "--headers option.")
88 |
89 | if "path" in contentsholder and "body" in contentsholder:
90 | returnresponse = False
91 |
92 | if options.response or options.getheaders:
93 | returnresponse = True
94 |
95 | results = self._rdmc.app.patch_handler(contentsholder["path"], \
96 | contentsholder["body"], verbose=self._rdmc.opts.verbose, \
97 | url=url, sessionid=options.sessionid, headers=headers, \
98 | response=returnresponse, silent=options.silent)
99 | else:
100 | raise InvalidFileFormattingError("Input file '%s' was not format" \
101 | " properly." % args[0])
102 |
103 | if results and returnresponse:
104 | if options.getheaders:
105 | sys.stdout.write(json.dumps(dict(\
106 | results._http_response.getheaders())) + "\n")
107 |
108 | if options.response:
109 | sys.stdout.write(results.text)
110 |
111 | #Return code
112 | return ReturnCodes.SUCCESS
113 |
114 | def patchvalidation(self, options):
115 | """ Raw patch validation function
116 |
117 | :param options: command line options
118 | :type options: list.
119 | """
120 | inputline = list()
121 |
122 | try:
123 | self._rdmc.app.get_current_client()
124 | except:
125 | if options.user or options.password or options.url:
126 | if options.url:
127 | inputline.extend([options.url])
128 | if options.user:
129 | inputline.extend(["-u", options.user])
130 | if options.password:
131 | inputline.extend(["-p", options.password])
132 | else:
133 | if self._rdmc.app.config.get_url():
134 | inputline.extend([self._rdmc.app.config.get_url()])
135 | if self._rdmc.app.config.get_username():
136 | inputline.extend(["-u", \
137 | self._rdmc.app.config.get_username()])
138 | if self._rdmc.app.config.get_password():
139 | inputline.extend(["-p", \
140 | self._rdmc.app.config.get_password()])
141 |
142 | self.lobobj.loginfunction(inputline, skipbuild=True)
143 |
144 | def sessionvalidation(self, options):
145 | """ Raw patch session validation function
146 |
147 | :param options: command line options
148 | :type options: list.
149 | """
150 |
151 | url = None
152 | if options.user or options.password or options.url:
153 | if options.url:
154 | url = options.url
155 | else:
156 | if self._rdmc.app.config.get_url():
157 | url = self._rdmc.app.config.get_url()
158 | if url and not "https://" in url:
159 | url = "https://" + url
160 |
161 | return url
162 |
163 | def definearguments(self, customparser):
164 | """ Wrapper function for new command main function
165 |
166 | :param customparser: command line input
167 | :type customparser: parser.
168 | """
169 | if not customparser:
170 | return
171 |
172 | customparser.add_option(
173 | '--url',
174 | dest='url',
175 | help="Use the provided URL to login.",
176 | default=None,
177 | )
178 | customparser.add_option(
179 | '-u',
180 | '--user',
181 | dest='user',
182 | help="If you are not logged in yet, including this flag along"\
183 | " with the password and URL flags can be used to log into a"\
184 | " server in the same command.""",
185 | default=None,
186 | )
187 | customparser.add_option(
188 | '-p',
189 | '--password',
190 | dest='password',
191 | help="""Use the provided password to log in.""",
192 | default=None,
193 | )
194 | customparser.add_option(
195 | '--sessionid',
196 | dest='sessionid',
197 | help="Optionally include this flag if you would prefer to "\
198 | "connect using a session id instead of a normal login.",
199 | default=None
200 | )
201 | customparser.add_option(
202 | '--silent',
203 | dest='silent',
204 | action="store_true",
205 | help="""Use this flag to silence responses""",
206 | default=False,
207 | )
208 | customparser.add_option(
209 | '--response',
210 | dest='response',
211 | action="store_true",
212 | help="Use this flag to return the response body.",
213 | default=False
214 | )
215 | customparser.add_option(
216 | '--getheaders',
217 | dest='getheaders',
218 | action="store_true",
219 | help="Use this flag to return the response headers.",
220 | default=False
221 | )
222 | customparser.add_option(
223 | '--headers',
224 | dest='headers',
225 | help="Use this flag to add extra headers to the request."\
226 | "\t\t\t\t\t Usage: --headers=HEADER:VALUE,HEADER:VALUE",
227 | default=None,
228 | )
229 |
230 |
--------------------------------------------------------------------------------
/docs/slate/source/stylesheets/_normalize.scss:
--------------------------------------------------------------------------------
1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2 |
3 | /**
4 | * 1. Set default font family to sans-serif.
5 | * 2. Prevent iOS text size adjust after orientation change, without disabling
6 | * user zoom.
7 | */
8 |
9 | html {
10 | font-family: sans-serif; /* 1 */
11 | -ms-text-size-adjust: 100%; /* 2 */
12 | -webkit-text-size-adjust: 100%; /* 2 */
13 | }
14 |
15 | /**
16 | * Remove default margin.
17 | */
18 |
19 | body {
20 | margin: 0;
21 | }
22 |
23 | /* HTML5 display definitions
24 | ========================================================================== */
25 |
26 | /**
27 | * Correct `block` display not defined for any HTML5 element in IE 8/9.
28 | * Correct `block` display not defined for `details` or `summary` in IE 10/11
29 | * and Firefox.
30 | * Correct `block` display not defined for `main` in IE 11.
31 | */
32 |
33 | article,
34 | aside,
35 | details,
36 | figcaption,
37 | figure,
38 | footer,
39 | header,
40 | hgroup,
41 | main,
42 | menu,
43 | nav,
44 | section,
45 | summary {
46 | display: block;
47 | }
48 |
49 | /**
50 | * 1. Correct `inline-block` display not defined in IE 8/9.
51 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
52 | */
53 |
54 | audio,
55 | canvas,
56 | progress,
57 | video {
58 | display: inline-block; /* 1 */
59 | vertical-align: baseline; /* 2 */
60 | }
61 |
62 | /**
63 | * Prevent modern browsers from displaying `audio` without controls.
64 | * Remove excess height in iOS 5 devices.
65 | */
66 |
67 | audio:not([controls]) {
68 | display: none;
69 | height: 0;
70 | }
71 |
72 | /**
73 | * Address `[hidden]` styling not present in IE 8/9/10.
74 | * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
75 | */
76 |
77 | [hidden],
78 | template {
79 | display: none;
80 | }
81 |
82 | /* Links
83 | ========================================================================== */
84 |
85 | /**
86 | * Remove the gray background color from active links in IE 10.
87 | */
88 |
89 | a {
90 | background-color: transparent;
91 | }
92 |
93 | /**
94 | * Improve readability when focused and also mouse hovered in all browsers.
95 | */
96 |
97 | a:active,
98 | a:hover {
99 | outline: 0;
100 | }
101 |
102 | /* Text-level semantics
103 | ========================================================================== */
104 |
105 | /**
106 | * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
107 | */
108 |
109 | abbr[title] {
110 | border-bottom: 1px dotted;
111 | }
112 |
113 | /**
114 | * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
115 | */
116 |
117 | b,
118 | strong {
119 | font-weight: bold;
120 | }
121 |
122 | /**
123 | * Address styling not present in Safari and Chrome.
124 | */
125 |
126 | dfn {
127 | font-style: italic;
128 | }
129 |
130 | /**
131 | * Address variable `h1` font-size and margin within `section` and `article`
132 | * contexts in Firefox 4+, Safari, and Chrome.
133 | */
134 |
135 | h1 {
136 | font-size: 2em;
137 | margin: 0.67em 0;
138 | }
139 |
140 | /**
141 | * Address styling not present in IE 8/9.
142 | */
143 |
144 | mark {
145 | background: #ff0;
146 | color: #000;
147 | }
148 |
149 | /**
150 | * Address inconsistent and variable font size in all browsers.
151 | */
152 |
153 | small {
154 | font-size: 80%;
155 | }
156 |
157 | /**
158 | * Prevent `sub` and `sup` affecting `line-height` in all browsers.
159 | */
160 |
161 | sub,
162 | sup {
163 | font-size: 75%;
164 | line-height: 0;
165 | position: relative;
166 | vertical-align: baseline;
167 | }
168 |
169 | sup {
170 | top: -0.5em;
171 | }
172 |
173 | sub {
174 | bottom: -0.25em;
175 | }
176 |
177 | /* Embedded content
178 | ========================================================================== */
179 |
180 | /**
181 | * Remove border when inside `a` element in IE 8/9/10.
182 | */
183 |
184 | img {
185 | border: 0;
186 | }
187 |
188 | /**
189 | * Correct overflow not hidden in IE 9/10/11.
190 | */
191 |
192 | svg:not(:root) {
193 | overflow: hidden;
194 | }
195 |
196 | /* Grouping content
197 | ========================================================================== */
198 |
199 | /**
200 | * Address margin not present in IE 8/9 and Safari.
201 | */
202 |
203 | figure {
204 | margin: 1em 40px;
205 | }
206 |
207 | /**
208 | * Address differences between Firefox and other browsers.
209 | */
210 |
211 | hr {
212 | -moz-box-sizing: content-box;
213 | box-sizing: content-box;
214 | height: 0;
215 | }
216 |
217 | /**
218 | * Contain overflow in all browsers.
219 | */
220 |
221 | pre {
222 | overflow: auto;
223 | }
224 |
225 | /**
226 | * Address odd `em`-unit font size rendering in all browsers.
227 | */
228 |
229 | code,
230 | kbd,
231 | pre,
232 | samp {
233 | font-family: monospace, monospace;
234 | font-size: 1em;
235 | }
236 |
237 | /* Forms
238 | ========================================================================== */
239 |
240 | /**
241 | * Known limitation: by default, Chrome and Safari on OS X allow very limited
242 | * styling of `select`, unless a `border` property is set.
243 | */
244 |
245 | /**
246 | * 1. Correct color not being inherited.
247 | * Known issue: affects color of disabled elements.
248 | * 2. Correct font properties not being inherited.
249 | * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
250 | */
251 |
252 | button,
253 | input,
254 | optgroup,
255 | select,
256 | textarea {
257 | color: inherit; /* 1 */
258 | font: inherit; /* 2 */
259 | margin: 0; /* 3 */
260 | }
261 |
262 | /**
263 | * Address `overflow` set to `hidden` in IE 8/9/10/11.
264 | */
265 |
266 | button {
267 | overflow: visible;
268 | }
269 |
270 | /**
271 | * Address inconsistent `text-transform` inheritance for `button` and `select`.
272 | * All other form control elements do not inherit `text-transform` values.
273 | * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
274 | * Correct `select` style inheritance in Firefox.
275 | */
276 |
277 | button,
278 | select {
279 | text-transform: none;
280 | }
281 |
282 | /**
283 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
284 | * and `video` controls.
285 | * 2. Correct inability to style clickable `input` types in iOS.
286 | * 3. Improve usability and consistency of cursor style between image-type
287 | * `input` and others.
288 | */
289 |
290 | button,
291 | html input[type="button"], /* 1 */
292 | input[type="reset"],
293 | input[type="submit"] {
294 | -webkit-appearance: button; /* 2 */
295 | cursor: pointer; /* 3 */
296 | }
297 |
298 | /**
299 | * Re-set default cursor for disabled elements.
300 | */
301 |
302 | button[disabled],
303 | html input[disabled] {
304 | cursor: default;
305 | }
306 |
307 | /**
308 | * Remove inner padding and border in Firefox 4+.
309 | */
310 |
311 | button::-moz-focus-inner,
312 | input::-moz-focus-inner {
313 | border: 0;
314 | padding: 0;
315 | }
316 |
317 | /**
318 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in
319 | * the UA stylesheet.
320 | */
321 |
322 | input {
323 | line-height: normal;
324 | }
325 |
326 | /**
327 | * It's recommended that you don't attempt to style these elements.
328 | * Firefox's implementation doesn't respect box-sizing, padding, or width.
329 | *
330 | * 1. Address box sizing set to `content-box` in IE 8/9/10.
331 | * 2. Remove excess padding in IE 8/9/10.
332 | */
333 |
334 | input[type="checkbox"],
335 | input[type="radio"] {
336 | box-sizing: border-box; /* 1 */
337 | padding: 0; /* 2 */
338 | }
339 |
340 | /**
341 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain
342 | * `font-size` values of the `input`, it causes the cursor style of the
343 | * decrement button to change from `default` to `text`.
344 | */
345 |
346 | input[type="number"]::-webkit-inner-spin-button,
347 | input[type="number"]::-webkit-outer-spin-button {
348 | height: auto;
349 | }
350 |
351 | /**
352 | * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
353 | * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
354 | * (include `-moz` to future-proof).
355 | */
356 |
357 | input[type="search"] {
358 | -webkit-appearance: textfield; /* 1 */
359 | -moz-box-sizing: content-box;
360 | -webkit-box-sizing: content-box; /* 2 */
361 | box-sizing: content-box;
362 | }
363 |
364 | /**
365 | * Remove inner padding and search cancel button in Safari and Chrome on OS X.
366 | * Safari (but not Chrome) clips the cancel button when the search input has
367 | * padding (and `textfield` appearance).
368 | */
369 |
370 | input[type="search"]::-webkit-search-cancel-button,
371 | input[type="search"]::-webkit-search-decoration {
372 | -webkit-appearance: none;
373 | }
374 |
375 | /**
376 | * Define consistent border, margin, and padding.
377 | */
378 |
379 | fieldset {
380 | border: 1px solid #c0c0c0;
381 | margin: 0 2px;
382 | padding: 0.35em 0.625em 0.75em;
383 | }
384 |
385 | /**
386 | * 1. Correct `color` not being inherited in IE 8/9/10/11.
387 | * 2. Remove padding so people aren't caught out if they zero out fieldsets.
388 | */
389 |
390 | legend {
391 | border: 0; /* 1 */
392 | padding: 0; /* 2 */
393 | }
394 |
395 | /**
396 | * Remove default vertical scrollbar in IE 8/9/10/11.
397 | */
398 |
399 | textarea {
400 | overflow: auto;
401 | }
402 |
403 | /**
404 | * Don't inherit the `font-weight` (applied by a rule above).
405 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
406 | */
407 |
408 | optgroup {
409 | font-weight: bold;
410 | }
411 |
412 | /* Tables
413 | ========================================================================== */
414 |
415 | /**
416 | * Remove most spacing between table cells.
417 | */
418 |
419 | table {
420 | border-collapse: collapse;
421 | border-spacing: 0;
422 | }
423 |
424 | td,
425 | th {
426 | padding: 0;
427 | }
428 |
--------------------------------------------------------------------------------
/src/extensions/RAW COMMANDS/RawGetCommand.py:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright Notice:
3 | # Copyright 2016 Distributed Management Task Force, Inc. All rights reserved.
4 | # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-utility/blob/main/LICENSE.md
5 | ###
6 |
7 | """ RawGet Command for rdmc """
8 |
9 | import sys
10 | import json
11 | import redfish
12 |
13 | from optparse import OptionParser
14 | from rdmc_base_classes import RdmcCommandBase, RdmcOptionParser
15 | from rdmc_helper import ReturnCodes, InvalidCommandLineError, \
16 | InvalidCommandLineErrorOPTS, UI
17 |
18 | class RawGetCommand(RdmcCommandBase):
19 | """ Raw form of the get command """
20 | def __init__(self, rdmcObj):
21 | RdmcCommandBase.__init__(self,\
22 | name='rawget',\
23 | usage='rawget [PATH] [OPTIONS]\n\n\tRun to to retrieve data from ' \
24 | 'the passed in path.\n\texample: rawget "/redfish/v1/' \
25 | 'systems/(system ID)"',\
26 | summary='This is the raw form of the GET command.',\
27 | aliases=['rawget'],\
28 | optparser=OptionParser())
29 | self.definearguments(self.parser)
30 | self._rdmc = rdmcObj
31 | self.lobobj = rdmcObj.commandsDict["LoginCommand"](rdmcObj)
32 |
33 | def run(self, line):
34 | """ Main raw get worker function
35 |
36 | :param line: command line input
37 | :type line: string.
38 | """
39 | try:
40 | (options, args) = self._parse_arglist(line)
41 | except:
42 | if ("-h" in line) or ("--help" in line):
43 | return ReturnCodes.SUCCESS
44 | else:
45 | raise InvalidCommandLineErrorOPTS("")
46 |
47 | url = None
48 | headers = {}
49 |
50 | if options.sessionid:
51 | url = self.sessionvalidation(options)
52 | else:
53 | self.getvalidation(options)
54 |
55 | if len(args) > 1:
56 | raise InvalidCommandLineError("Raw get only takes 1 argument.\n")
57 | elif len(args) == 0:
58 | raise InvalidCommandLineError("Missing raw get input path.\n")
59 |
60 | if args[0].startswith('"') and args[0].endswith('"'):
61 | args[0] = args[0][1:-1]
62 |
63 | if options.expand:
64 | args[0] = args[0] + '?$expand=.'
65 |
66 | if options.headers:
67 | extraheaders = options.headers.split(',')
68 | for item in extraheaders:
69 | header = item.split(':')
70 |
71 | try:
72 | headers[header[0]] = header[1]
73 | except:
74 | InvalidCommandLineError("Invalid format for --headers " \
75 | "option.")
76 |
77 | returnresponse = False
78 | if options.response or options.getheaders:
79 | returnresponse = True
80 |
81 | results = self._rdmc.app.get_handler(args[0], \
82 | verbose=self._rdmc.opts.verbose, sessionid=options.sessionid, \
83 | url=url, headers=headers, response=returnresponse, \
84 | silent=options.silent)
85 | if results and options.binfile:
86 | output = results.read
87 |
88 | filehndl = open(options.binfile[0], "wb")
89 | filehndl.write(output)
90 | filehndl.close()
91 |
92 | elif results and returnresponse:
93 | if options.getheaders:
94 | sys.stdout.write(json.dumps(dict(\
95 | results._http_response.getheaders())) + "\n")
96 |
97 | if options.response:
98 | sys.stdout.write(results.text)
99 | elif results and results.status == 200:
100 | if results.dict:
101 | if options.filename:
102 | output = json.dumps(results.dict, indent=2, \
103 | cls=redfish.ris.JSONEncoder)
104 |
105 | filehndl = open(options.filename[0], "w")
106 | filehndl.write(output)
107 | filehndl.close()
108 |
109 | sys.stdout.write("Results written out to '%s'.\n" % \
110 | options.filename[0])
111 | else:
112 | UI().print_out_json(results.dict)
113 | else:
114 | return ReturnCodes.NO_CONTENTS_FOUND_FOR_OPERATION
115 |
116 | #Return code
117 | return ReturnCodes.SUCCESS
118 |
119 | def getvalidation(self, options):
120 | """ Raw get validation function
121 |
122 | :param options: command line options
123 | :type options: list.
124 | """
125 | inputline = list()
126 |
127 | try:
128 | self._rdmc.app.get_current_client()
129 | except:
130 | if options.user or options.password or options.url:
131 | if options.url:
132 | inputline.extend([options.url])
133 | if options.user:
134 | inputline.extend(["-u", options.user])
135 | if options.password:
136 | inputline.extend(["-p", options.password])
137 | else:
138 | if self._rdmc.app.config.get_url():
139 | inputline.extend([self._rdmc.app.config.get_url()])
140 | if self._rdmc.app.config.get_username():
141 | inputline.extend(["-u", \
142 | self._rdmc.app.config.get_username()])
143 | if self._rdmc.app.config.get_password():
144 | inputline.extend(["-p", \
145 | self._rdmc.app.config.get_password()])
146 |
147 | self.lobobj.loginfunction(inputline, skipbuild=True)
148 |
149 | def sessionvalidation(self, options):
150 | """ Raw get validation function
151 |
152 | :param options: command line options
153 | :type options: list.
154 | """
155 |
156 | url = None
157 | if options.user or options.password or options.url:
158 | if options.url:
159 | url = options.url
160 | else:
161 | if self._rdmc.app.config.get_url():
162 | url = self._rdmc.app.config.get_url()
163 | if url and not "https://" in url:
164 | url = "https://" + url
165 |
166 | return url
167 |
168 | def definearguments(self, customparser):
169 | """ Wrapper function for new command main function
170 |
171 | :param customparser: command line input
172 | :type customparser: parser.
173 | """
174 | if not customparser:
175 | return
176 |
177 | customparser.add_option(
178 | '--url',
179 | dest='url',
180 | help="Use the provided URL to login.",
181 | default=None,
182 | )
183 | customparser.add_option(
184 | '-u',
185 | '--user',
186 | dest='user',
187 | help="If you are not logged in yet, including this flag along"\
188 | " with the password and URL flags can be used to log into a"\
189 | " server in the same command.""",
190 | default=None,
191 | )
192 | customparser.add_option(
193 | '-p',
194 | '--password',
195 | dest='password',
196 | help="""Use the provided password to log in.""",
197 | default=None,
198 | )
199 | customparser.add_option(
200 | '--response',
201 | dest='response',
202 | action="store_true",
203 | help="Use this flag to return the response body.",
204 | default=False
205 | )
206 | customparser.add_option(
207 | '--getheaders',
208 | dest='getheaders',
209 | action="store_true",
210 | help="Use this flag to return the response headers.",
211 | default=False
212 | )
213 | customparser.add_option(
214 | '--headers',
215 | dest='headers',
216 | help="Use this flag to add extra headers to the request."\
217 | "\t\t\t\t\t Usage: --headers=HEADER:VALUE,HEADER:VALUE",
218 | default=None,
219 | )
220 | customparser.add_option(
221 | '--silent',
222 | dest='silent',
223 | action="store_true",
224 | help="""Use this flag to silence responses""",
225 | default=False,
226 | )
227 | customparser.add_option(
228 | '--sessionid',
229 | dest='sessionid',
230 | help="Optionally include this flag if you would prefer to "\
231 | "connect using a session id instead of a normal login.",
232 | default=None
233 | )
234 | customparser.add_option(
235 | '-f',
236 | '--filename',
237 | dest='filename',
238 | help="""Write results to the specified file.""",
239 | action="append",
240 | default=None,
241 | )
242 | customparser.add_option(
243 | '-b',
244 | '--writebin',
245 | dest='binfile',
246 | help="""Write the results to the specified file in binary.""",
247 | action="append",
248 | default=None,
249 | )
250 | customparser.add_option(
251 | '--expand',
252 | dest='expand',
253 | action="store_true",
254 | help="""Use this flag to expand the path specified using the """\
255 | """expand notation '?$expand=.'""",
256 | default=False,
257 | )
258 |
--------------------------------------------------------------------------------