Git Product home page Git Product logo

knife-vcair's Introduction

Knife vcair

This is the official Chef Knife plugin VMware's vCloud Hybrid Service (vcair). This plugin gives knife the ability to create, bootstrap and manage instances on vcair-based public and private clouds.

Please refer to the CHANGELOG for version history and known issues.

Installation

This plugin is distributed as a Ruby Gem. To install it, run:

$ gem install knife-vcair

If you are using the Chef Development Kit (Chef DK), to install it run:

$ chef gem install knife-vcair

Configuration

In order to communicate with an vcair API you will need to tell Knife your vcair API endpoint, username, password and organization. The easiest way to accomplish this is to create these entries in your knife.rb file:

knife[:vcair_api_host] = 'vcair.example.com'
knife[:vcair_username] = 'Your vcair username'
knife[:vcair_password] = 'Your vcair password'
knife[:vcair_org] = 'Your vcair organization'

If your knife.rb file will be checked into a SCM system (ie readable by others) you may want to read the values from environment variables.

knife[:vcair_api_host] = ENV['VCAIR_API_URL']
knife[:vcair_username] = ENV['VCAIR_USERNAME']
knife[:vcair_password] = ENV['VCAIR_PASSWORD']
knife[:vcair_org] = ENV['VCAIR_ORG']

VMware vCloud Air - Subscription

If you are using VMware's hosted vcair the API URL is found by logging into the https://vchs.vmware.com, and clicking on your Dashboard's Virtual Data Center. On the right under "Related Links" click on the "vCloud Director API URL" and copy that value. It should look something like https://p3v11-vcd.vchs.vmware.com:443/cloud/org/M511664989-4904/ From this we will take our base API URL p3v11-vcd.vchs.vmware.com and get our organization M511664989-4904 that is appended to our https://vchs.vmware.com login, giving us the values:

knife[:vcair_api_host] = 'p3v11-vcd.vchs.vmware.com'
knife[:vcair_username] = '[email protected]
knife[:vcair_password] = 'VCAIRSECRET'
knife[:vcair_org] = 'M511664989-4904'

VMware vCloud Air - OnDemand

Your Org ID is commonly a UUID-formatted string and can be found in the URL after you log in to vCloud Air OnDemand (for example: https://us-virginia-1-4....?orgName=SOME_UUID_HERE) or it will be displayed next to your name in the upper-left corner of the vCloud Director web UI. You can also ascertain your Org ID by following these instructions.

Additionally, you will need to override the API path as the API path between the subscription service and the OnDemand service are different. You will need to set the following entry in your knife.rb file:

knife[:vcair_api_path] = '/api/compute/api'

... or you may pass it in on the CLI using --vcair-api-path.

knife vcair subcommands

This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a --help option.

knife vcair server create OR knife vcair vm create

Instanciate a new VApp+VM from a Template from one of the available Catalogs.

NOTE: If --vcair-net NETWORK is not provided, the first non-isolated (i.e. natRouted or bridged) network is chosen

Windows example:

knife vcair server create \
  --winrm-password Password1 \
  --image W2K12-STD-64BIT \
  --bootstrap-protocol winrm \
  --customization-script ./install-winrm-vcair.bat \
  --cpus 4 \
  --memory 4096 \
  --node-name windows2012 \
  --vcair-net M511664989-4904-default-routed

The windows example requires a custom install script to setup winrm, and set/change the initial password without using the web console. A working example ./install-winrm-vcair-example.bat is included in this repo.

Linux example:

knife vcair server create \
  --ssh-password Password1 \
  --image "CentOS64-64bit" \
  --customization-script ./install-linux-vcair.sh \
  --cpus 4 \
  --memory 4096 \
  --node-name centos64 \
  --vcair-net M511664989-4904-default-routed

The Linux example requires a custom script to set DNS servers for obtaining chef-client via omnibus. This also includes a workaround for Ubuntu images to allow password authentication via SSH. The Linux images require you pass the ssh-password. Ssh public keys are not supported yet.

Assumptions:

  • each VApp will only contain one VM.
  • a routed network with a default SNAT rule allowing internet and DNS
  • a firewall rule allowing that network to reach internet

TODO

  • Allow specifying (possibly multiple) networks in server create
    • Rather than just searching for one that ends in 'routed'
  • Allow specifying nat setup / external IPs
  • Allow specifying catalog item by name OR id, public or private
  • Automatically image_os_type / bootstrap_protocol default basode on template default to linux/ssh
  • See if windows images can be updated to set password correctly when set via the vchs API
  • See if Linux images / API can be updated to use ssh keys
  • Add support for admin_auto_logon_* to fog, and get windows/linux images updated to respect
  • Support IP allocation modes other than DHCP, including manual

knife vcair server delete OR knife vcair vm delete

Delete a vcair vAPP. knife vcair vm delete is the same command if the term 'vm' is preferred over 'server'. PLEASE NOTE - this does not delete the associated node and client objects from the Chef server without using the -P option to purge the client.

knife vcair server list OR knife vcair vm list

List the currently deployed vcair servers by their vAPP. knife vcair vm list is the same command if the term 'vm' is preferred over 'server'.

knife vcair image list OR knife vcair template list

List the available vcair templates or images that may be used for deploying VMs.

knife vcair network list

Lists the networks available to the current vcair organization.

Notes

  • The 20140619 Ubuntu images seems to not use customizaton (script nor setting password) and default to not allowing ssh w/ password even if known.
template = public_catalog.catalog_items.get_by_name('Ubuntu Server 12.04 LTS (amd64 20140619)'

License

Author:: Matt Ray ([email protected])

Author:: Seth Thomas ([email protected])

Author:: Chris McClimans ([email protected])

Copyright:: Copyright (c) 2015 Chef Software, Inc.

License:: Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

knife-vcair's People

Contributors

adamleff avatar cheeseplus avatar mattray avatar taylor avatar thewolfpack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

knife-vcair's Issues

customization script: install-linux-vcair-example.sh

On Ubuntu, the name servers should be added to the /etc/network/interfaces file as dns-nameservers [IP address]. You can add name servers to the resolv.conf file, but they will be removed/forgotten when the server reboots. Also, the last line in the file says:
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" >> /etc/resolve.conf
There is an extra 'n' in the second nameserver reference.

Knife vcair Plugin Install

The error I am getting now is on Windows 7 with 0.4.0. When I look at the GEM folder for Knife-vcair 0.6.0 the directory has only the licence and help file. Nothing else. I assume this is due to the version of CHEFDK I am using.

PS C:\code\knife-vcair-master> gem build knife-vcair.gemspec
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
WARNING: licenses is empty, but is recommended. Use a license abbreviation from:
http://opensource.org/licenses/alphabetical
WARNING: description and summary are identical
WARNING: open-ended dependency on fog (>= 1.23) is not recommended
if fog is semantically versioned, use:
add_runtime_dependency 'fog', '> 1.23'
WARNING: pessimistic dependency on knife-cloud (
> 1.0.0) may be overly strict
if knife-cloud is semantically versioned, use:
add_runtime_dependency 'knife-cloud', '> 1.0', '>= 1.0.0'
WARNING: open-ended dependency on knife-windows (>= 0) is not recommended
if knife-windows is semantically versioned, use:
add_runtime_dependency 'knife-windows', '
> 0'
WARNING: open-ended dependency on rake (>= 0, development) is not recommended
if rake is semantically versioned, use:
add_development_dependency 'rake', '> 0'
WARNING: open-ended dependency on activesupport (>= 0, development) is not recommended
if activesupport is semantically versioned, use:
add_development_dependency 'activesupport', '
> 0'
WARNING: open-ended dependency on rspec-core (>= 0, development) is not recommended
if rspec-core is semantically versioned, use:
add_development_dependency 'rspec-core', '> 0'
WARNING: open-ended dependency on rspec-expectations (>= 0, development) is not recommended
if rspec-expectations is semantically versioned, use:
add_development_dependency 'rspec-expectations', '
> 0'
WARNING: open-ended dependency on rspec-mocks (>= 0, development) is not recommended
if rspec-mocks is semantically versioned, use:
add_development_dependency 'rspec-mocks', '> 0'
WARNING: open-ended dependency on rspec_junit_formatter (>= 0, development) is not recommended
if rspec_junit_formatter is semantically versioned, use:
add_development_dependency 'rspec_junit_formatter', '
> 0'
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: knife-vcair
Version: 0.6.0
File: knife-vcair-0.6.0.gem
PS C:\code\knife-vcair-master>

server create throws type Error "no implicit conversion of Symbol into Integer"

I am trying to create a vm from an template in VCD using the command
knife vcair server create --ssh-password Password1 --image
"image-name" --cpus 4 --memory 4096 --node-name centos64
--vcair-net network1.

The above returns with error message "ERROR: TypeError: no implicit conversion of Symbol into Integer". Vm is actually created which i could verify with UI. But its not powered on. I googled but none of the links are not helping though

image list doesn't list catalogs

When you go through the web UI, you have to choose the catalog before choosing the template, but image list doesn't show the catalog. The catalog is not present on the catalog_item object in fog, we probably should patch fog to add this data for more useful output.

create server error

i am also getting the same error while running command
knife vcair server create --ssh-password Password1 --image "CentOS64-64bit" --customization-script ./install-linux-vcair.sh --cpus 4 --memory 4096 --node-name centos64

below is the error

DL is deprecated, please use Fiddle
WARN: Unresolved specs during Gem::Specification.reset:
highline (>= 1.6.9, ~> 1.6)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
ERROR: knife encountered an unexpected error
This may be a bug in the 'vcair server create' knife command or plugin
Please collect the output of this command with the -VV option before filing a bug report.
Exception: NoMethodError: undefined method `id' for nil:NilClass

please help me

Test and document Linux bootstrapping procedure

From @jicowan

Assumption: you are using DHCP to assign IP addresses and name servers. Neither the CentOS template or the Ubuntu template have name servers defined. Bootstrapping the Chef client will fail after the VM is created because it cannot resolve www.opscode.com. Consider including instructions that explain how to modify and/or replace the resolv.conf file after the ssh session is established.

  • test current linux images
  • document

Remove and abstract network name hardcoding

root@chefdev2:/home/chefclient/chef-repo# knife vcair server create --ssh-password password --image UB# Base VM Routed --node-name UB4 --cpus 2 --memory 2048 --customization-script ./home/chefclient/chef-repo/config/install-linux-vcair.sh -VV
WARN: Unresolved specs during Gem::Specification.reset:
nokogiri (>= 1.4.0, >= 1.5.11, ~> 1.5)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
DEBUG: vcair_username [email protected]
DEBUG: vcair_org M222222222-2222
DEBUG: vcair_api_host p3v1-vcd.vchs.vmware.com
DEBUG: vcair_api_version
DEBUG: vcair_show_progress
DEBUG: Using fog version: 1.27.0
/root/.chefdk/gem/ruby/2.1.0/gems/knife-vcair-0.6.0/lib/chef/knife/vcair_server_create.rb:148:in instantiate': undefined methodid' for nil:NilClass (NoMethodError)
from /root/.chefdk/gem/ruby/2.1.0/gems/knife-vcair-0.6.0/lib/chef/knife/vcair_server_create.rb:37:in execute_command' from /root/.chefdk/gem/ruby/2.1.0/gems/knife-cloud-1.0.1/lib/chef/knife/cloud/command.rb:51:inrun'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:493:in run_with_pretty_exceptions' from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:174:inrun'
from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:139:in run' from /opt/chefdk/embedded/apps/chef/bin/knife:25:in<top (required)>'
from /opt/chefdk/bin/knife:38:in load' from /opt/chefdk/bin/knife:38:in

'
root@chefdev2:/home/chefclient/chef-repo#

knife vcair server list error

Running knife vcair server list with the follow options set in knife, and getting the below error:
Knife.rb
require 'Excon'
knife[:vcair_api_host] = 'lab.myco.com'
knife[:vcair_username] = 'me'
knife[:vcair_password] = 'myself'
knife[:vcair_org] = 'productdevelopment'
knife[:vcair_vdc] = 'my-vdc'
Excon.defaults[:ssl_verify_peer] = false

When trying to run the above command i am seeing the following error:

DEBUG: vcair_api_version
DEBUG: vcair_show_progress
DEBUG: Using fog version: 1.24.0
c:/Ruby193/lib/ruby/gems/1.9.1/gems/knife-vcair-0.6.0/lib/chef/knife/vcair_helpe
rs.rb:24:in vdc': undefined methodvdcs' for nil:NilClass (NoMethodError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/knife-vcair-0.6.0/lib/chef/knif
e/vcair_vm_list.rb:35:in query_resource' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/knife-cloud-1.0.1/lib/chef/knif e/cloud/list_resource_command.rb:35:inexecute_command'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/knife-cloud-1.0.1/lib/chef/knif
e/cloud/command.rb:51:in run' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-11.16.4-x86-mingw32/lib/ch ef/knife.rb:493:inrun_with_pretty_exceptions'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-11.16.4-x86-mingw32/lib/ch
ef/knife.rb:174:in run' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-11.16.4-x86-mingw32/lib/ch ef/application/knife.rb:139:inrun'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-11.16.4-x86-mingw32/bin/kn
ife:25:in <top (required)>' from c:/Ruby193/bin/knife:23:inload'
from c:/Ruby193/bin/knife:23:in `

'

Any ideas?

Thanks
Chris

Still receiving `instantiate`: undefined method `id` for nil:nilClass on 0.7.0

I went through a few other issues referencing this and have included a few notes from it. I am using VPC on-demand and have configured appropriately.

( ccorbett@cherenkov:~/development/cookbooks/sce-vcloud (feature) )$ bash test.sh 
INFO: Using configuration from /home/ccorbett/.chef/knife.rb
INFO: Started chef-zero at chefzero://localhost:8889 with repository at /home/ccorbett/development
  One version per cookbook

DEBUG: vcair_username OBFUSCATE
DEBUG: vcair_org OBFUSCATE
DEBUG: vcair_api_host OBFUSCATE
DEBUG: vcair_api_path /api/compute/api
DEBUG: vcair_api_version 
DEBUG: vcair_show_progress 
DEBUG: Using fog version: 1.34.0
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-vcair-0.7.0/lib/chef/knife/vcair_server_create.rb:148:in `instantiate': undefined method `id' for nil:NilClass (NoMethodError)
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-vcair-0.7.0/lib/chef/knife/vcair_server_create.rb:36:in `execute_command'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-cloud-1.2.0/lib/chef/knife/cloud/command.rb:51:in `run'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:425:in `block in run_with_pretty_exceptions'
        from /opt/chefdk/embedded/apps/chef/lib/chef/local_mode.rb:39:in `with_server_connectivity'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:424:in `run_with_pretty_exceptions'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:215:in `run'
        from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:142:in `run'
        from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
        from /usr/bin/knife:55:in `load'
        from /usr/bin/knife:55:in `<main>'

( ccorbett@cherenkov:~/development/cookbooks/sce-vcloud (feature) )$ knife vcair server create --help | grep vcair-net
        --vcair-net NETWORKNAME      Your VCAIR NETWORK

( ccorbett@cherenkov:~/development/cookbooks/sce-vcloud (feature) )$ gem list | grep vcair
knife-vcair (0.7.0)

--cpu and --memory options not working

Ex:

knife vcair server create --cpus 4 --memory 2048 --ssh-password 'randopass' --image "Ubuntu Server 12.04 LTS (i386 20140619)" --customization-script ./linux-customization.sh --node-name 1204-32bits

Yields:

vAPP Name IP CPU Memory OS Owner Status
1204-32bits Ubuntu Server 12.04 LTS (i386 20140619) 192.168.109.5 1 1024 Ubuntu Linux (32-bit) [email protected] on

Subscription or On-demand Service?

Does this plugin support a subscription based or on demand service with vCloud Air? I'm testing against an on-demand account and I'm having some issues.

rubocop cleanup

Rubocop results are a mess for this repo. Adding this issue to add this to the queue of work.

Revamp tests

The tests for knife-vcair need to be revamped and enhanced. There isn't a lot of coverage currently, and what does exist is done in the old RSpec syntax.

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.