cloudmesh.azure.compute.Provider
¶
Module Contents¶
Functions¶
|
|
|
-
cloudmesh.azure.compute.Provider.
_remove_mongo_id_obj
(dict_list)¶
-
cloudmesh.azure.compute.Provider.
_get_az_vm_status
(az_status)¶
-
class
cloudmesh.azure.compute.Provider.
Provider
(name='azure', credentials=None)¶ Bases:
cloudmesh.abstract.ComputeNodeABC.ComputeNodeABC
,cloudmesh.provider.ComputeProviderPlugin
verbosity
8 - prints major actions 9 - prints all images 10 - prints all update dicts
-
kind
= azure¶
-
sample
= cloudmesh: cloud: {name}: cm: active: true heading: {name} host: TBD label: {name} kind: azure version: latest service: compute default: image: Canonical:UbuntuServer:16.04.0-LTS:latest size: Basic_A0 resource_group: cloudmesh storage_account: cmdrive network: cmnetwork subnet: cmsubnet blob_container: vhds AZURE_VM_IP_CONFIG: cloudmesh-ip-config AZURE_VM_NIC: cloudmesh-nic AZURE_VM_DISK_NAME: cloudmesh-os-disk AZURE_VM_USER: TBD AZURE_VM_PASSWORD: TBD AZURE_VM_NAME: cloudmeshVM credentials: AZURE_TENANT_ID: {tenantid} AZURE_SUBSCRIPTION_ID: {subscriptionid} AZURE_APPLICATION_ID: {applicationid} AZURE_SECRET_KEY: {secretkey} AZURE_REGION: eastus¶
-
vm_state
= ['ACTIVE', 'BUILDING', 'DELETED', 'ERROR', 'HARD_REBOOT', 'PASSWORD', 'PAUSED', 'REBOOT', 'REBUILD', 'RESCUED', 'RESIZED', 'REVERT_RESIZE', 'SHUTOFF', 'SOFT_DELETED', 'STOPPED', 'SUSPENDED', 'UNKNOWN', 'VERIFY_RESIZE']¶
-
output
¶
-
Print
(self, data, output=None, kind=None)¶
-
keys
(self)¶ The keys command in Azure is not supported
- TODO: BUG: therefore it should just return the keys form the local db to
make it appear it is supported. So instead do get the output, see how it is implemented in key list
- Returns
-
key_upload
(self, key=None)¶ TODO: implement alternative
azure does not allow explicit key upload!
- Parameters
key –
- Returns
-
key_delete
(self, name=None)¶ TODO: implement alternative
azure does not allow explicit key upload!
- Parameters
name –
- Returns
-
_get_az_public_ip
(self, ip_name)¶
-
get_public_ip
(self, name=None)¶ returns public IP by vm name from the Az public IPs
- Parameters
name –
- Returns
-
list_public_ips
(self, ip=None, available=False)¶ lists public ips of the group
- Parameters
ip –
available –
- Returns
-
delete_public_ip
(self, ip=None)¶ deletes public ip by name
- Parameters
ip –
- Returns
-
create_public_ip
(self)¶ Creates public IP for the group using the ip name provided in the config as a prefix
- Returns
-
find_available_public_ip
(self)¶ Azure currently has no direct API to check if an IP is available or not! Hence create an IP everytime this method is called!
- Returns
-
attach_public_ip
(self, node=None, ip=None)¶ attaches a public ip to a node
- Parameters
node –
ip –
- Returns
-
detach_public_ip
(self, node=None, ip=None)¶ detaches public IP
- Parameters
node –
ip –
- Returns
-
_get_az_pub_ip_from_nic_id
(self, nic_id)¶ gets azure public ip using NIC ID
- Parameters
nic_id –
- Returns
-
_get_local_vm
(self, vm_name, quiet=False)¶ gets local vm from the db
- Parameters
vm_name –
quiet –
- Returns
-
_get_pub_ip_for_vm
(self, vm)¶
-
ssh
(self, vm=None, command=None)¶ runs ssh
- Parameters
vm –
command –
- Returns
-
_get_resource_group
(self)¶
-
set_server_metadata
(self, name, **metadata)¶ sets server metadata
- Parameters
name –
metadata –
- Returns
-
get_server_metadata
(self, name)¶ gets server metadata
- Parameters
name –
- Returns
-
delete_server_metadata
(self, name, key=None)¶ deletes server metadata
- Parameters
name –
key –
- Returns
-
list_secgroups
(self, name=None)¶ List the security group by name
- Parameters
name – The name of the group, if None all will be returned
- Returns
-
_get_az_sec_groups
(self, name=None)¶ gets azure sec groups
- Parameters
name –
- Returns
-
_get_local_sec_groups
(self, name=None)¶ gets local sec groups from db
- Parameters
name –
- Returns
-
_get_local_sec_rules
(self, group_name=None)¶ gets local sec rules from db
- Parameters
group_name –
- Returns
-
list_secgroup_rules
(self, name='default')¶ List the security group rules by for provided Network Security Group
- Parameters
name – The name of the group
- Returns
-
_sec_rules_local_to_az
(self, sec_rule_names)¶ translate local rules to aure sec rules
- Parameters
sec_rule_names –
- Returns
-
_add_local_sec_group
(self, name, description)¶ adds sec group locally to db
- Parameters
name –
description –
- Returns
-
_add_az_sec_group
(self, name)¶ adds sec group to azure
- Parameters
name –
- Returns
-
add_secgroup
(self, name=None, description=None)¶ Adds the sec group locally :param name: Name of the group :param description: The description :return:
-
add_secgroup_rule
(self, name=None, port=None, protocol=None, ip_range=None)¶ Adding sec rule to the local db as azure does not support explicit sec rules :param name: :param port: :param protocol: :param ip_range: :return:
-
remove_secgroup
(self, name=None)¶ Delete the names security group
- Parameters
name – The name of the Security Group to be deleted
- Returns
-
upload_secgroup
(self, name=None)¶ Takes the security group from the local db and push it to az :param name: :return:
-
_check_local_rules_available
(self, rules)¶ checks if local rules available
- Parameters
rules –
- Returns
-
add_rules_to_secgroup
(self, secgroupname=None, newrules=None)¶ Adds the rules to te local sec group only! it will update the az sec group once it is uploaded :param secgroupname: :param newrules: :return:
-
remove_rules_from_secgroup
(self, name=None, rules=None)¶ removes rules from a secgroup both locally and from azure group :param name: :param rules: :return:
-
create
(self, name=None, image=None, size=None, location=None, timeout=180, key=None, secgroup=None, ip=None, user=None, public=True, group=None, metadata=None, flavor=None, **kwargs)¶ creates a named node
- Parameters
name – the name of the node
image – the image used
size – the size of the image
timeout – a timeout in seconds that is invoked in case the image does not boot. The default is set to 3 minutes.
kwargs – additional arguments passed along at time of boot
location –
key –
secgroup –
ip –
user –
public –
group –
metadata –
flavor –
- Returns
-
_get_local_key_content
(self, key_name)¶ gets local key content from cb
- Parameters
key_name –
- Returns
-
_create_vm_parameters
(self, name, secgroup, ip, key, flavor)¶ Create the VM parameters structure. :param secgroup: sec group name :param ip: az PublicIP object as dict :param key: pub key content :return:
-
_create_az_sec_group_if_not_exists
(self, sec_group_name)¶ creates azure sec group if not exists (by name)
- Parameters
sec_group_name –
- Returns
-
_create_az_vnet_if_not_exists
(self)¶ creates azure virtual network
- Returns
-
_create_az_subnet_if_not_exits
(self, secgroup)¶ creates azure subnet
- Parameters
secgroup –
- Returns
-
_create_az_nic
(self, secgroup, ip)¶ Create a Network Interface for a Virtual Machine
- Parameters
secgroup –
ip –
- Returns
-
start
(self, group=None, name=None)¶ start a node
- Parameters
group – the unique Resource Group name
name – the unique Virtual Machine name
- Returns
The dict representing the node
-
reboot
(self, group=None, name=None)¶ restart/reboot a node
- Parameters
group – the unique Resource Group name
name – the unique Virtual Machine name
- Returns
The dict representing the node
-
stop
(self, group=None, name=None)¶ stops the node with the given name
- Parameters
group – the unique Resource Group name
name – the unique Virtual Machine name
- Returns
The dict representing the node including updated status
-
resume
(self, group=None, name=None)¶ resume the named node since Azure does not handle resume it uses start
- Parameters
group – the unique Resource Group name
name – the unique Virtual Machine name
- Returns
The dict representing the node including updated status
-
suspend
(self, group=None, name=None)¶ suspends the node with the given name since Azure does not handle suspend it uses stop
- Parameters
group – the unique Resource Group name
name – the unique Virtual Machine name
- Returns
The dict representing the node including updated status
-
info
(self, group=None, name=None, status=None)¶ gets the information of a node with a given name list VM in resource group
- Parameters
group – the unique Resource Group name
name – the unique Virtual Machine name
status – TODO
- Returns
dict representing the node including updated status
-
status
(self, name=None)¶ gets the status of a VM by name
- Parameters
name –
- Returns
-
list
(self)¶ List all Azure Virtual Machines from my Account
- Returns
dict
-
destroy
(self, name=None)¶ Destroys the node
- Parameters
name – the name of the node
- Returns
the dict of the node
-
images
(self, **kwargs)¶ Lists the images on the cloud
- Parameters
kwargs –
- Returns
dict
-
flavors
(self)¶ Lists the flavors on the cloud
- Returns
dict of flavors
-
flavor
(self, name=None)¶ Gets the flavor with a given name
- Parameters
name – The name of the flavor
- Returns
The dict of the flavor
-
find
(self, elements, name=None)¶ Finds an element in elements with the specified name.
- Parameters
elements – The elements
name – The name to be found
- Returns
-
image
(self, name=None, **kwargs)¶ Gets the image with a given nmae
- Parameters
name – The name of the image
kwargs –
- Returns
the dict of the image
-
get_list
(self, d, kind=None, debug=False, **kwargs)¶ Lists the dict d on the cloud
- Parameters
d –
kind –
debug –
kwargs –
- Returns
dict
-
rename
(self, name=None, destination=None)¶ rename a node
- Parameters
destination –
name – the current name
- Returns
the dict with the new name
-
update_dict
(self, elements, kind=None)¶ The cloud returns an object or list of objects With the dict method this object is converted to a cloudmesh dict. Typically this method is used internally.
- Parameters
elements – the elements
kind – Kind is image, flavor, or node, secgroup and key
- Returns
-
wait
(self, vm=None, interval=None, timeout=None)¶ waits for completion (all the methods are implemented synchronously! hence this just lists vms)
- Parameters
vm –
interval –
timeout –
- Returns
-