Giter VIP home page Giter VIP logo

hewlettpackard / oneview-chef Goto Github PK

View Code? Open in Web Editor NEW
17.0 14.0 15.0 2.25 MB

This project is no longer being developed and has limited support. In the near future this repository will be fully deprecated. Please consider using other OneView projects, such as Terraform and Ansible Collection

Home Page: https://supermarket.chef.io/cookbooks/oneview

License: Apache License 2.0

Ruby 99.86% Dockerfile 0.14%
hpe-oneview oneview-api chef-cookbook chef-resource provider devops cookbook oneview-ruby-sdk hpe-image-streamer bare-metal

oneview-chef's Introduction

HPE OneView SDK for Chef

Build Status

OV Version 6.20 6.10 6.00 5.60 5.50
SDK Version/Tag v6.2.0 v6.1.0 v6.0.0 v3.8.0 v3.7.0
Build Status Build status Build status Build status Build status Build status

Introduction

HPE OneView makes it simple to deploy and manage today’s complex hybrid cloud infrastructure. HPE OneView can help you transform your data center to software-defined, and it supports HPE’s broad portfolio of servers, storage, and networking solutions, ensuring the simple and automated management of your hybrid infrastructure. Software-defined intelligence enables a template-driven approach for deploying, provisioning, updating, and integrating compute, storage, and networking infrastructure.

The HPE OneView Chef SDK enables developers to easily build integrations and scalable solutions with HPE OneView and HPE Image Streamer. You can find the latest supported HPE OneView Chef SDK here

What's New

HPE OneView Chef library extends support of the SDK to OneView REST API version 3000 (OneView v6.20)

Please refer to notes for more information on the changes , features supported and issues fixed in this version

Getting Started

Requirements

  • Ruby >= 2.4.1 (We recommend using Ruby >= 2.4.1)
  • Chef >= 12.0 (We recommend using Chef >= 13.12 if possible)

Installation and Configuration

HPE OneView SDK for Chef can be installed from Source and Docker container installation methods. You can either use a docker container which will have the HPE OneView SDK for Chef installed or perform local installation manually.

Installation

Docker Setup for oneview-chef

The light weight containerized version of the HPE OneView SDK for Chef is available in the Docker Store. The Docker Store image tag consist of two sections: <sdk_version-OV_version>

# Download and store a local copy of oneview-chef and
# use it as a Docker image.
$ docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-chef:v6.2.0-OV6.2
# Run docker commands below given, which  will in turn create
# a sh session where you can create files, issue commands and execute the recipes.
$ docker run -it hewlettpackardenterprise/hpe-oneview-sdk-for-chef:v6.2.0-OV6.2 /bin/sh

Local Setup for oneview-chef

Chef SDK dependencies can be installed by bundler.

# Create a folder cookbooks and clone the chef repo
$ mkdir cookbooks
$ cd cookbooks
$ git clone https://github.com/chef-boneyard/compat_resource
# Clone Chef repo as oneview
$ git clone https://github.com/HewlettPackard/oneview-chef oneview
$ cd oneview

Local installation requires the gem in your Gemfile:

gem 'oneview-sdk', '~> 6.2.0'

Install Chef Sdk dependencies from Gemfile

$ bundle install

Usage

The cookbook 'metadata' is not intended to include any recipes instead specifies a dependency which is used by another cookbooks.

# my_cookbook/metadata.rb
depends 'oneview', '~> 6.2.0'

Credentials

In order to manage HPE OneView and HPE Synergy Image Streamer resources, you will need to provide authentication credentials. There are 2 ways to do this:

Environment variables:

  • For HPE OneView:

    $export ONEVIEWSDK_URL=<ov-endpoint>
    $export ONEVIEWSDK_USER=<ov-user>
    $export ONEVIEWSDK_PASSWORD=<ov-password>
    $export ONEVIEWSDK_SSL_EANBLED=false
  • For HPE Synergy Image Streamer:

    $export I3S_URL=<i3s-endpoint>

API version

When using the resources a API version will be selected to interact with the resources in each HPE OneView correct API versions. To select the desired one, you may use one of the following methods:

  1. Set the resource property api_version. See the Resource Properties section below.
  2. Set the client parameter api_version. If this parameter is set, it will select the required API version based on the client. Notice if you choose to pass the client as an OneviewSDK object, it will have, by default, the api_version set, even if you do not directly specify it.
  3. If none of the previous alternatives are set, it defaults to the node['oneview']['api_version']. See the Atributes.

Be aware of the precedence of these methods! The higher priority goes to setting the resource property, followed by the client parameter, and at last the node value as the default, i.e. Property > Client > Attribute. (e.g. If you set the resource property api_version to 200, and set the client parameter api_version to 300, it will use the module API200, since the resource property takes precedence over the client parameter)

Attributes

  • node['oneview']['ruby_sdk_version'] - Set which version of the SDK to install and use. Defaults to '~> 4.1'
  • node['oneview']['save_resource_info'] - Save resource info to a node attribute? Defaults to ['uri']. Possible values/types:
    • true - Save all info (Merged hash of OneView info and Chef resource properties). Warning: Resource credentials will be saved if specified.
    • false - Do not save any info.
    • Array - i.e. ['uri', 'status', 'created_at'] Save a subset of specified attributes.
  • node['oneview']['api_version'] - When looking for a matching Chef resource provider class, this version will be used as default. Defaults to 200.
  • node['oneview']['api_variant'] - When looking for a matching Chef resource provider class, this variant will be used as default. Defaults to C7000.

Client Property

Explicitly pass in the client property to each resource. This takes precedence over environment variables and allows you to set more client properties. This also allows you to get these credentials from other sources like encrypted databags, Vault, etc.

my_client = {
  url: 'https://example.com',
  user: 'username',
  password: 'password',
  api_version: 3000
}

HPE Synergy Image Streamer access token is the same as the HPE OneView associated appliance, so most of its credentials you may get from the HPE OneView.

Resources

Resource Properties

The following are the standard properties available for all resources. Some resources have additional properties or small differences.

oneview_ethernet_network 'Eth1' do
  client my_client
  api_version 3000
  api_variant 'Synergy'
  data(
    vlanId: 1001,
    purpose: 'General',
    smartLink: false,
    privateNetwork: false,
    bandwidth: {
      typicalBandwidth: 2000,
      maximumBandwidth: 9000
    }
  )
  action :create_if_missing
end

Examples

The examples provided here will help you to understand the detailed usage of each resource in Chef Sdk. It allows users to easily create, update, query and delete resources.

You can find the resource examples here. This document provides the list of attributes and the methods being used in each resource to perform CRUD operations on the oneview appliance.

  • attributes: client, data, scopes, etc.
  • methods: :create, :delete, :delete_bulk

Getting Help

Are you running into a road block? Have an issue with unexpected bahriov? Feel free to open a new issue on the issue tracker

For more information on how to open a new issue refer to How can I get help & support

License

This project is licensed under the Apache 2.0 license. Please see LICENSE for more info.

Contributing and feature requests

Contributing: You know the drill. Fork it, branch it, change it, commit it, and pull-request it. We are passionate about improving this project, and glad to accept help to make it better. However, keep the following in mind:

  • You must sign a Contributor License Agreement first. Contact one of the authors (from Hewlett Packard Enterprise) for details and the CLA.
  • We reserve the right to reject changes that we feel do not fit the scope of this project, so for feature additions, please open an issue to discuss your ideas before doing the work.

Feature Requests: If you have a need that is not met by the current implementation, please let us know (via a new issue). This feedback is crucial for us to deliver a useful product. Do not assume we have already thought of everything, because we assure you that is not the case.

Testing

  • Style (Rubocop & Foodcritic): $ rake style
  • Unit: $ rake unit
  • Run all tests: $ rake test
  • Optional: Start guard to run tests automatically on file changes: $ bundle exec guard

For more information please refer to the Testing guidelines.

Contributors

You can find the list of contributors here

Additional Resources

HPE OneView Documentation

HPE OneView Release Notes

HPE OneView Support Matrix

HPE OneView Installation Guide

HPE OneView User Guide

HPE OneView Online Help

HPE OneView REST API Reference

HPE OneView Firmware Management White Paper

HPE OneView Deployment and Management White Paper

HPE OneView Community

HPE OneView Community Forums

Learn more about HPE OneView at hpe.com/info/oneview

oneview-chef's People

Contributors

aalexmonteiro avatar anushay1916 avatar asisbagga avatar chebroluharika avatar fgbulsoni avatar harikachebrolu avatar jsmartt avatar jyothisgm avatar madhav-bharadwaj avatar nabhajit-ray avatar ricardogpsf avatar sijeesh avatar soodpr avatar tmiotto avatar venkateshravula avatar yuvirani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oneview-chef's Issues

oneview_ethernet_network :bulk_create action is not idempotent

Scenario/Intent

oneview_ethernet_network :bulk_create action is not idempotent

Environment Details

  • oneview Cookbook Version: master
  • OneView Version: 2.0

Steps to Reproduce

Create a recipe with a oneview_ethernet_network resource with the :bulk_create action, and run it twice.

Expected Result

Create the networks on the first run, and do nothing on the second.

Actual Result

It create the networks on the first run, but results in an error on the second. Error basics: 400: "CRM_DUPLICATE_BULK_NETWORK_NAME","message":"Some network names already exist."

Coverage for resource providers

Scenario/Intent

SimpleCov is complaining the resource providers aren't being tested by RSpec, but they are by the ChefSpec.

Should we remove them from the coverage report? Or should we migrate the tests to plain RSpec?

Environment Details

  • oneview Cookbook Version: New (Post 1.0.0)

Steps to Reproduce

rake test

Expected Result

Coverage report should not be bellow expected

Actual Result

Coverage report is failing due to low coverage

NetworkSet fails with indeterminate message if networks aren't found

Scenario/Intent

When adding a network set with a native_network or network_list containing networks that don't exist.

Environment Details

  • oneview Cookbook Version: 0.2.0
  • OneView Version: 2.0
  • chef-client Version: all
  • platform: all

Steps to Reproduce

Running this should do it:

oneview_network_set 'ChefNetworkSet_1' do
  client <my_client>
  native_network 'FakeNetworkThatDoesNotExist'
  ethernet_network_list ['FakeNetworkThatDoesNotExist2', 'FakeNetworkThatDoesNotExist3']
  action :create
end

Expected Result

Give a helpful message saying the network could not be found

Actual Result

NoMethodError
-------------
undefined method `[]' for nil:NilClass

API300 support to Fabrics

Scenario/Intent

Add support to the new Fabrics functionality :set_reserved_vlan_range

  • Create the resource Fabrics
  • Create action :set_reserved_vlan_range (API300::Synergy only)
  • Add tests for Fabrics

OneviewCookbook::Helper#get_diff with two no-diff hashes returns '\n'

Scenario/Intent

When trying to compare two hashes that has no-diff ( i.e. for each key 'k' in 'a', a[k] == b[k] ) with the OneviewCookbook::Helper#get_diff the result returned is '\n'.

Environment Details

  • oneview Cookbook Version: 1.1.0
  • OneView Version: N/A
  • chef-client Version: N/A
  • platform: N/A

Steps to Reproduce

Use get_diff method with two hashes with no-diff like:

a = { a: 'test', b: 'second' }
b = { a: 'test', c: 'other', b: 'second' }
get_diff(a, b)

Expected Result

get_diff should return ''

Actual Result

get_diff returns '\n'

Support multiple API versions

Scenario/Intent

Support more API versions and the new/updated resources associated with them

Environment Details

  • oneview Cookbook Version: 1.1.0
  • OneView Version: 200, 300, and beyond

Description

In order to support newer API versions and yet maintain compatibility with previous ones, we'll need to do a pretty big refactor. The work is already underway, but this issue can capture some of the ideas and thoughts behind it, and serve as a discussion forum. From what we've discussed already, this refactor will likely include:

  • Splitting most of the logic for resource actions into separate "provider" modules/classes.
  • Supporting only 1 API version and HW variant per chef-client run. Because of the differences in the resources for separate API versions and how the providers would have to be split out, we need to load the providers at compile time, not runtime.

Outstanding Questions

  1. How do we handle resources that have new/updated properties for newer API versions? For example, for oneview_server_profile, how do we add an os_deployment_image property to the API300 provider but make it clear that it isn't used in the API200 provider? Seems like there's a lot of room for confusion here.
  2. Similarly, how should completely new resources be handled that don't exist in API200 (e.g., all the I3S stuff)?
  3. Is there a good way to support multiple versions and variants in a chef-client run? I haven't found a good solution for it yet, but it may be possible.

API300 support to Enclosure group

Scenario/Intent

Add support to Enclosure Group on API300.

Environment Details

  • oneview Cookbook Version: 1.1.0
  • OneView Version: 300

Volume resource syntax bug

https://github.com/HewlettPackard/oneview-chef/blob/master/resources/volume.rb#L51 is missing an &. There's a single & that should be &&. Currently throws an error similar to:

    ================================================================================
    Error executing action `create` on resource 'oneview_volume[CHEF_VOL_01]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `&' for "ThreePAR7200-3167":String

    Cookbook Trace:
    ---------------
    /home/vagrant/chef-repo/.chef/local-mode-cache/cache/cookbooks/oneview/resources/volume.rb:51:in `load_storage_system'

Easy fix, but we'll want to add some tests too.

Volume doesn't support a volume_template (only)

Scenario/Intent

Create a volume using a volume_template.

Environment Details

  • oneview Cookbook Version: 1.0.0
  • OneView Version: Any
  • chef-client Version: Any
  • platform: Any

Steps to Reproduce

Run an example like this one in the examples, in which no storage_system property is specified (it's specified in the template, so I shouldn't have to).

I used this code:

oneview_volume 'VOL_1' do
  client my_client
  data(
    description: 'General',
    provisionedCapacity: 1024 * 1024 * 10
  )
  volume_template "VOL_TEMPLATE"
end

Expected Result

It should be able to create the volume.

Actual Result

It raises an error saying Unspecified property: 'storage_system'. Please set it before attempting this action.

Add implementation of action :none to oneview_interconnect

Scenario/Intent

Default action for interconnects is :none, but it is not implemented.

Environment Details

  • N/A

Steps to Reproduce

Run any oneview_interconnect resource with default action.

Expected Result

Nothing should happen.

Actual Result

it fails since the :none action was not implemented.

oneview_storage_system :update action shouldn't try to update name

Scenario/Intent

Re-running the same recipe that added a storage system (with the :add action) always results in an update, regardless of whether or not it's needed. (On the name and password)

Environment Details

  • oneview Cookbook Version: 1.1.0
  • OneView Version: 3.0

Steps to Reproduce

Run any simple recipe with a oneview_storage_system resource with the :add action. The example will do.

Expected Result

On subsequent runs, it shouldn't say it's going to update the name every time. From what I can tell, the name doesn't even appear to be configurable, right?
Also, it continues to try to update the password; I'm not sure if we can avoid that part, but what do you all think about only updating the password if the username has also changed or it's not in a good state (as defined by the state? status?)?

Actual Result

It tries to update the StorageSystem name and password:

INFO: Updating oneview_storage_system '172.18.11.12'

    - Update oneview_storage_system '172.18.11.12'

      credentials:
        password: nil -> myPassword123
      name: ThreePAR7200-6955 -> 172.18.11.12

Note that it doesn't break anything or cause any errors, but it does throw off the resources updated count, etc.

Add bandwidth and associated SAN to all network resources

Scenario/Intent

Uses should be able to set the bandwidth on the following resources:

  • oneview_fc_network
  • oneview_fcoe_network
  • oneview_network_set

Also, it would be nice to have a helper property: associated_san.

Environment Details

  • oneview Cookbook Version: 1.1.0
  • OneView Version: 3.0

Show diff of resource that needs updated

When updating resources, there is no log output that indicates what is changed; just that it needs updated. However, when trying to debug a resource that continually needs updated because it seems to never match the definition, it's impossible to tell why.

For instance, if you have:

oneview_ethernet_network 'Chef-Eth-Net' do
  client <my_client>
  data(
    vlanId: 51,
    purpose: 'General',
    smartLink: true,
    privateNetwork: false
  )
end

It will always get "updated". On further investigation, it's because "smartLink"=>false on OneView, and it can't be set to false. It's pretty easy to output a diff for single-level hashes like ethernet_network data. You could just output:

...
[2016-09-01T19:48:39+00:00] INFO: Update oneview_ethernet_network 'Chef-Eth-Net'

    - Update oneview_ethernet_network 'Chef-Eth-Net'

  key1: old_val -> new_val
  key2: old_val -> new_val
...

However, for nested hashes, this may prove a little more difficult. We could do a dot chain, which could look something like:

...
[2016-09-01T19:48:39+00:00] INFO: Update oneview_ethernet_network 'Chef-Eth-Net'

    - Update oneview_ethernet_network 'Chef-Eth-Net'

  key1: old_val -> new_val
  first_level.key2: old_val -> new_val
  first_level.second.third.key3: old_val -> new_val
...

The easiest option would just be to print a debug statement with both complete hashes (no diff), but I think it's worth handling cleaner than that. Thoughts?

Synergy Networks

Scenario/Intent

Add Synergy remaining networks support (FC, FCoE, Network Set)

They should be splitted into providers, the resources must be updated, but they haven't any new added features.

Add missing README examples

There are some resources implemented without usage in README file. We need to create all these resource examples in README.

Uplink Set

Scenario/Intent

Implementation of Uplink Set actions

Support Server Hardware in API300

Scenario/Intent

Add support to Server Hardware on API300.

Environment Details

  • oneview Cookbook Version: 1.1.0
  • OneView Version: 300

oneview_server_hardware updates not available

Scenario/Intent

oneview_server_hardware resources should not call the update method. Really, I think we need to remove the :add action, keeping only the :add_if_missing and :remove actions.

Environment Details

  • oneview Cookbook Version: master
  • OneView Version: 2.0

Steps to Reproduce

Add server-hardware, then update the resource with a different licensingIntent, for example.

Expected Result

Nothing. These resources cannot be updated. There's no API endpoint, and no SDK update method.

Actual Result

OneviewSDK::MethodUnavailable : The method #update is unavailable for this resource

Global client config

Scenario/Intent

I'd like to be able to set the client object once and then all resources that don't set the client property will use that as a default.

Environment Details

  • oneview Cookbook Version: 1.0.0

Steps to Reproduce

[If you are filing an issue, what are the things we need to do in order to reproduce your problem? How are you using this cookbook or any resources it includes?]

Expected Result

Set the client object once and everything that doesn't override it will use that as a default.

Actual Result

You have to pass in a client object for EVERY resource

Connection template implementation

As we know, OneView has a dedicated endpoint for Connection templates that are used by the Ethernet networks.

So, after some research I concluded that we could implement in Chef 2 actions for it, one is update and the other one is reset_to_default.

Although being that simple the names/URI for the Connection templates is not available to the end-user, it needs to be acquired through the Ethernet network name.

So my question is: It makes more sense to create a separate Chef resource for the Connection template or add these 2 actions in the Ethernet network resource?

Implementation of Server Hardware

Implement the Server Hardware resource with its actions and unit tests.

Actions:

  • add
  • add_if_missing
  • remove
  • refresh
  • set_power_state
  • update_ilo_firmware

Add default PR comment

In order to help ensure good code and ensure PRs include all the expected things, it would be helpful to create a default comment for new PRs. (We can also do this for issues.) I saw this on the rsyslog cookbook, and the docs for how to do it are here.

Let's use this issue to discuss whether or not this is worth doing, and what the default should be.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.