Skip to content

Commit

Permalink
group updates to public branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lj020326 committed Apr 1, 2024
1 parent 053ee3c commit a2e224e
Show file tree
Hide file tree
Showing 5 changed files with 602 additions and 209 deletions.
209 changes: 0 additions & 209 deletions files/scripts/python/api_keys.py

This file was deleted.

81 changes: 81 additions & 0 deletions files/scripts/python/cloudstack_api_keys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# Cookbook Name:: cloudstack
# Resource:: api_keys
# Author:: Pierre-Luc Dion (<pdion@cloudops.com>)
# Copyright 2018, CloudOps, Inc.
#
# 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.
#
default_action = 'create'
username = ''
url = 'http://localhost:8080/client/api'
password = 'password'
admin_apikey = ''
admin_secretkey = ''
ssl = False

def create():
wait_count = 0
while not cloudstack_api_is_running() and wait_count < 5:
cloudstack_api_is_running()
time.sleep(5)
wait_count += 1
if wait_count == 1:
print('Waiting CloudStack to start')
if cloudstack_api_is_running():
create_admin_apikeys()
else:
print('CloudStack not running, cannot generate API keys.')

def reset():
if cloudstack_is_running():
if username == 'admin':
admin_keys = generate_admin_keys(url, password)
print('admin api keys: Generate new')
admin_apikey = admin_keys['api_key']
admin_secretkey = admin_keys['secret_key']
else:
print('CloudStack not running, cannot generate API keys.')

def create_admin_apikeys():
if admin_apikey or admin_secretkey:
if admin_apikey and admin_secretkey:
admin_apikeys_from_cloudstack()
else:
if keys_valid():
print("api keys: found valid keys from {0} in the Chef environment: {1}.".format(other_nodes.first.name, node.chef_environment))
print('api keys: updating node attributes')
elif keys_valid():
new_resource.exists = True
print('api keys: are valid, nothing to do')

def cloudstack_api_is_running():
# implementation of cloudstack_api_is_running function
pass

def cloudstack_is_running():
# implementation of cloudstack_is_running function
pass

def generate_admin_keys(url, password):
# implementation of generate_admin_keys function
pass

def admin_apikeys_from_cloudstack():
# implementation of admin_apikeys_from_cloudstack function
pass

def keys_valid():
# implementation of keys_valid function
pass

35 changes: 35 additions & 0 deletions files/scripts/ruby/ruby2python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# ruby2python

ruby2python is a tool to convert Ruby code into Python. Useful for those pesky
programming exercises where you absolutely must turn in the code in python.

## Requirements

- Rubinius with Ruby 1.9 support

## Features

- Implicit `self` when accessing methods in current class
- but only in current class context
- must be defined in file prior to being referenced
- `each`, `map`, `sort_by`
- Some ruby standard library methods

## Unimplemented

- Implicit return
- Array range access
- A lot of other stuff

## Usage

- Edit `ruby2python` and change the shebang to point to your rbx installation
- `ruby2python hello.rb` produces a file in the same directory called `hello.py`.
Or probably crashes if you have anything remotely interesting code in your
input file.

## Reference

- https://github.com/cyndis/infl/tree/master
-
Loading

0 comments on commit a2e224e

Please sign in to comment.