-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
602 additions
and
209 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
- |
Oops, something went wrong.