Giter VIP home page Giter VIP logo

rbvmomi2's Introduction

RbVmomi

gem-version Test Lint

This is a community-supported, open source project at ManageIQ. It is built and maintained by programmers like you!

Introduction

RbVmomi is a Ruby interface to the vSphere API. Like the Perl and Java SDKs, you can use it to manage ESX and vCenter servers. The current release supports the vSphere 7.0 API. RbVmomi specific documentation is online and is meant to be used alongside the official documentation.

Installation

gem install rbvmomi2

Usage

A simple example of turning on a VM:

require 'rbvmomi'

vim = RbVmomi::VIM.connect(host: 'foo', user: 'bar', password: 'baz')
dc = vim.serviceInstance.find_datacenter('my_datacenter') || fail('datacenter not found')
vm = dc.find_vm('my_vm') || fail('VM not found')
vm.PowerOnVM_Task.wait_for_completion

This code uses several RbVmomi extensions to the vSphere API for concision. The expanded snippet below uses only standard API calls and should be familiar to users of the Java SDK:

require 'rbvmomi'

vim = RbVmomi::VIM.connect(host: 'foo', user: 'bar', password: 'baz')
root_folder = vim.serviceInstance.content.rootFolder
dc = root_folder.childEntity.grep(RbVmomi::VIM::Datacenter).find { |x| x.name == 'mydatacenter' } || fail('datacenter not found')
vm = dc.vmFolder.childEntity.grep(RbVmomi::VIM::VirtualMachine).find { |x| x.name == 'my_vm' } || fail('VM not found')
task = vm.PowerOnVM_Task
filter = vim.propertyCollector.CreateFilter(
  spec: {
    propSet: [{ type: 'Task', all: false, pathSet: ['info.state']}],
    objectSet: [{ obj: task }]
  },
  partialUpdates: false
)
ver = ''
loop do
  result = vim.propertyCollector.WaitForUpdates(version: ver)
  ver = result.version
  break if ['success', 'error'].member?(task.info.state)
end
filter.DestroyPropertyFilter
raise(task.info.error) if task.info.state == 'error'

As you can see, the extensions RbVmomi adds can dramatically decrease the code needed to perform simple tasks while still letting you use the full power of the API when necessary. RbVmomi extensions are often more efficient than a naive implementation; for example, the find_vm method on VIM::Datacenter used in the first example uses the SearchIndex for fast lookups.

A few important points:

  • All class, method, parameter, and property names match the official documentation.
  • Properties are exposed as accessor methods.
  • Data object types can usually be inferred from context, so you may use a hash instead.
  • Enumeration values are simply strings.
  • Example code is included in the examples/ directory.
  • A set of helper methods for Optimist is included to speed up development of command line apps. See the included examples for usage.
  • If you don't have trusted SSL certificates installed on the host you're connecting to, you'll get an OpenSSL::SSL::SSLError "certificate verify failed". You can work around this by using the :insecure option to RbVmomi::VIM.connect.
  • This is a side project of a VMware employee and is entirely unsupported by VMware.

Built-in extensions are under lib/rbvmomi/vim/. You are encouraged to reopen VIM classes in your applications and add extensions of your own. If you write something generally useful please open a pull request so it can be merged back in

Development

Open an issue on the issues page or fork the project on GitHub and send a pull request.

Contributors

A huge thanks goes to all of the contributors on this project. To see the full list, use git shortlog -nes.

Support

You can chat on Gitter

rbvmomi2's People

Contributors

rlane avatar agrare avatar cdickmann avatar jrgarcia avatar fryguy avatar hartsock avatar dougm avatar dependabot[bot] avatar danielrife avatar tas50 avatar nanliu avatar dekz avatar domcleal avatar djberg96 avatar rmahique avatar scottjg avatar seandilda avatar tae8838 avatar bortels avatar tomgiordano avatar rebyn avatar dstefka avatar howels avatar kumabuchi avatar renovate[bot] avatar thanhngn avatar mend-bolt-for-github[bot] avatar puneetkatyal avatar darkarnium avatar chessbyte avatar

Stargazers

Mehmet Aydogdu avatar Neal avatar Bernhard Suttner avatar

Watchers

Mark Plaksin avatar  avatar James Cloos avatar Marc Siegfriedt avatar  avatar

rbvmomi2's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

bundler
Gemfile
github-actions
.github/workflows/lint.yml
  • actions/checkout v4
  • ruby/setup-ruby v1
.github/workflows/test.yml
  • actions/checkout v4
  • ruby/setup-ruby v1

  • Check this box to trigger a request for Renovate to run again on this repository

CVE-2023-22796 (High) detected in activesupport-7.0.2.3.gem

CVE-2023-22796 - High Severity Vulnerability

Vulnerable Library - activesupport-7.0.2.3.gem

A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing.

Library home page: https://rubygems.org/gems/activesupport-7.0.2.3.gem

Path to dependency file: /Gemfile.lock

Path to vulnerable library: /em/ruby/2.7.0/cache/activesupport-7.0.2.3.gem

Dependency Hierarchy:

  • โŒ activesupport-7.0.2.3.gem (Vulnerable Library)

Found in base branch: master

Vulnerability Details

There is a possible regular expression based DoS vulnerability in Active Support. A specially crafted string passed to the underscore method can cause the regular expression engine to enter a state of catastrophic backtracking. This can cause the process to use large amounts of CPU and memory, leading to a possible DoS vulnerability. The issue is patched in versions 6.1.7.1 and 7.0.4.1.

Publish Date: 2023-01-06

URL: CVE-2023-22796

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-j6gc-792m-qgm2

Release Date: 2023-01-06

Fix Resolution: activesupport - 6.1.7.1,7.0.4.1


Step up your Open Source Security Game with Mend here

Cannot parse "11030938062" as an int value during NIC attach parse_response

Describe the bug
When running a reconfigure to add another NIC to a virtual machine, the following error occurs. This happens in the OpenNebula vCenter driver paired with vCenter 8.0 U2.

Cannot attach NIC to VM: InvalidRequest:
Cannot parse "11030938062" as an int value
while parsing serialized value of type int
at line 1, column 405
while parsing property "key" of static type int
while parsing serialized DataObject of type vim.vm.device.VirtualVmxnet3
at line 1, column 371
while parsing property "device" of static type VirtualDevice
while parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec
at line 1, column 296
while parsing property "deviceChange" of static type ArrayOfVirtualDeviceConfigSpec
while parsing serialized DataObject of type vim.vm.ConfigSpec
at line 1, column 254
while parsing call information for method ReconfigVM_Task
at line 1, column 177
while parsing SOAP body
at line 1, column 167
while parsing SOAP envelope
at line 1, column 0
while parsing HTTP request for method reconfigure
on object of type vim.VirtualMachine
at line 1, column 0.

/usr/share/one/gems-dist/gems/rbvmomi2-3.7.0/lib/rbvmomi/connection.rb:64:in `parse_response'
/usr/share/one/gems-dist/gems/rbvmomi2-3.7.0/lib/rbvmomi/connection.rb:93:in `call'
/usr/share/one/gems-dist/gems/rbvmomi2-3.7.0/lib/rbvmomi/basic_types.rb:256:in `_call'
/usr/share/one/gems-dist/gems/rbvmomi2-3.7.0/lib/rbvmomi/basic_types.rb:77:in `block (2 levels) in init'
/usr/lib/one/ruby/vcenter_driver/virtual_machine.rb:2232:in `attach_nic'
/var/lib/one/remotes/vmm/vcenter/attach_nic:73:in `<main>'"

To Reproduce
Steps to reproduce the behavior:

  1. Import vCenter 8.0 U2 resources to OpenNebula
  2. Create/Import a Virtual Machine
  3. Try to attach a NIC to a virtual machine through OpenNebula

Expected behavior
A NIC should be attached without error

Platform:

  • OS: Any ( mainly testing with Ubuntu/Alma )
  • RbVmomi Version: rbvmomi2-3.7.0
  • Ruby Version: 3.0.2 ( also happens in 2.5.9 )

Additional context
For extra context, the function which builds and attaches the NIC can be found here in the OpenNebula project's vcenter library files: https://github.com/OpenNebula/one/blob/master/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb#L1902

I also work on the OpenNebula project so I can provide other information if necessary. This is a very similar error that we're seeing when trying to run the old rbvmomi

RbVmomi deserialization fails on managed object type ContentLibraryItem

Describe the bug
Similar to #28 but with another object

failing with:

/var/people/appuser/.rvm/gems/ruby-3.1.3/gems/rbvmomi2-3.6.0/lib/rbvmomi/type_loader.rb:104:in `make_type': unknown VMODL type ContentLibraryItem (RuntimeError)

To Reproduce
Steps to reproduce the behavior:

  1. delete object from content library
  2. vim.serviceContent.taskManager.recentTask.first.info
  3. ๐Ÿ’ฅ

CVE-2023-38037 (Medium) detected in activesupport-7.0.2.3.gem

CVE-2023-38037 - Medium Severity Vulnerability

Vulnerable Library - activesupport-7.0.2.3.gem

A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing.

Library home page: https://rubygems.org/gems/activesupport-7.0.2.3.gem

Path to dependency file: /Gemfile.lock

Path to vulnerable library: /em/ruby/2.7.0/cache/activesupport-7.0.2.3.gem

Dependency Hierarchy:

  • โŒ activesupport-7.0.2.3.gem (Vulnerable Library)

Found in base branch: master

Vulnerability Details

Active Support Possibly Discloses Locally Encrypted Files

Publish Date: 2023-07-12

URL: CVE-2023-38037

CVSS 3 Score Details (4.3)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: Low
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: None
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-cr5q-6q9f-rq6q

Release Date: 2023-07-12

Fix Resolution: activesupport - 6.1.7.5,7.0.7.1


Step up your Open Source Security Game with Mend here

rbvmomi2 version 3.4.0 is missing cluster.summaryEx object

Tried rbvmomi2 version 3.4.0 and still the cluster object is missing summaryEx object.
Need to get / set vCLS placement property which is part of summaryEx.

summary ComputeResourceSummary [summary](https://aer1-cvcsa80.asm.delllabs.net/mob/?moid=domain-c1033&doPath=summary) **summaryEx ClusterComputeResourceSummary** [summaryEx](https://aer1-cvcsa80.asm.delllabs.net/mob/?moid=domain-c1033&doPath=summaryEx)

CVE-2024-27285 (Medium) detected in yard-0.9.27.gem

CVE-2024-27285 - Medium Severity Vulnerability

Vulnerable Library - yard-0.9.27.gem

YARD is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions.

Library home page: https://rubygems.org/gems/yard-0.9.27.gem

Path to dependency file: /Gemfile.lock

Path to vulnerable library: /em/ruby/2.7.0/cache/yard-0.9.27.gem

Dependency Hierarchy:

  • โŒ yard-0.9.27.gem (Vulnerable Library)

Found in base branch: master

Vulnerability Details

YARD is a Ruby Documentation tool. The "frames.html" file within the Yard Doc's generated documentation is vulnerable to Cross-Site Scripting (XSS) attacks due to inadequate sanitization of user input within the JavaScript segment of the "frames.erb" template file. This vulnerability is fixed in 0.9.36.

Publish Date: 2024-02-28

URL: CVE-2024-27285

CVSS 3 Score Details (5.4)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-8mq4-9jjh-9xrc

Release Date: 2024-02-28

Fix Resolution: yard - 0.9.35


Step up your Open Source Security Game with Mend here

RbVmomi deserialization fails on managed object type ContentLibrary

Describe the bug
This is actually the same bug from vmware-archive#205, but it is now locked over there.

I ran into the same issue, but was looking to wait for the Content Library Sync to finish for some post-processing.

I know that it is not the correct way to fix this, so I didn't add a pull request, but for anyone looking to get around the issue until a proper fix is available, I was able to hack a ContentLibrary object in so I could view the task list and wait for the sync task. You can find it on this commit: mahcsig@46a708d

It doesn't actually work as a ManagedObject (it throws errors when trying to access attributes like name), but it works enough to allow the task to load.

Sorry this isn't in the proper format, but the above mentioned ticket is, and is still applicable.

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.