Search is not available for this dataset
text stringlengths 75 104k |
|---|
def _get_cluster_dict(cluster_name, cluster_ref):
'''
Returns a cluster dict representation from
a vim.ClusterComputeResource object.
cluster_name
Name of the cluster
cluster_ref
Reference to the cluster
'''
log.trace('Building a dictionary representation of cluster \'%s\'... |
def list_cluster(datacenter=None, cluster=None, service_instance=None):
'''
Returns a dict representation of an ESX cluster.
datacenter
Name of datacenter containing the cluster.
Ignored if already contained by proxy details.
Default value is None.
cluster
Name of clust... |
def _apply_cluster_dict(cluster_spec, cluster_dict, vsan_spec=None,
vsan_61=True):
'''
Applies the values of cluster_dict dictionary to a cluster spec
(vim.ClusterConfigSpecEx).
All vsan values (cluster_dict['vsan']) will be applied to
vsan_spec (vim.vsan.cluster.ConfigInfoE... |
def create_cluster(cluster_dict, datacenter=None, cluster=None,
service_instance=None):
'''
Creates a cluster.
Note: cluster_dict['name'] will be overridden by the cluster param value
config_dict
Dictionary with the config values of the new cluster.
datacenter
N... |
def update_cluster(cluster_dict, datacenter=None, cluster=None,
service_instance=None):
'''
Updates a cluster.
config_dict
Dictionary with the config values of the new cluster.
datacenter
Name of datacenter containing the cluster.
Ignored if already contained... |
def list_datastores_via_proxy(datastore_names=None, backing_disk_ids=None,
backing_disk_scsi_addresses=None,
service_instance=None):
'''
Returns a list of dict representations of the datastores visible to the
proxy object. The list of datastores ca... |
def create_vmfs_datastore(datastore_name, disk_id, vmfs_major_version,
safety_checks=True, service_instance=None):
'''
Creates a ESXi host disk group with the specified cache and capacity disks.
datastore_name
The name of the datastore to be created.
disk_id
T... |
def rename_datastore(datastore_name, new_datastore_name,
service_instance=None):
'''
Renames a datastore. The datastore needs to be visible to the proxy.
datastore_name
Current datastore name.
new_datastore_name
New datastore name.
service_instance
Ser... |
def remove_datastore(datastore, service_instance=None):
'''
Removes a datastore. If multiple datastores an error is raised.
datastore
Datastore name
service_instance
Service instance (vim.ServiceInstance) of the vCenter/ESXi host.
Default is None.
.. code-block:: bash
... |
def list_licenses(service_instance=None):
'''
Lists all licenses on a vCenter.
service_instance
Service instance (vim.ServiceInstance) of the vCenter/ESXi host.
Default is None.
.. code-block:: bash
salt '*' vsphere.list_licenses
'''
log.trace('Retrieving all licenses'... |
def add_license(key, description, safety_checks=True,
service_instance=None):
'''
Adds a license to the vCenter or ESXi host
key
License key.
description
License description added in as a label.
safety_checks
Specify whether to perform safety check or to sk... |
def _get_entity(service_instance, entity):
'''
Returns the entity associated with the entity dict representation
Supported entities: cluster, vcenter
Expected entity format:
.. code-block:: python
cluster:
{'type': 'cluster',
'datacenter': <datacenter_name>,
... |
def _validate_entity(entity):
'''
Validates the entity dict representation
entity
Dictionary representation of an entity.
See ``_get_entity`` docstrings for format.
'''
#Validate entity:
if entity['type'] == 'cluster':
schema = ESXClusterEntitySchema.serialize()
eli... |
def list_assigned_licenses(entity, entity_display_name, license_keys=None,
service_instance=None):
'''
Lists the licenses assigned to an entity
entity
Dictionary representation of an entity.
See ``_get_entity`` docstrings for format.
entity_display_name
... |
def assign_license(license_key, license_name, entity, entity_display_name,
safety_checks=True, service_instance=None):
'''
Assigns a license to an entity
license_key
Key of the license to assign
See ``_get_entity`` docstrings for format.
license_name
Display ... |
def list_hosts_via_proxy(hostnames=None, datacenter=None,
cluster=None, service_instance=None):
'''
Returns a list of hosts for the the specified VMware environment. The list
of hosts can be filtered by datacenter name and/or cluster name
hostnames
Hostnames to filter o... |
def list_disks(disk_ids=None, scsi_addresses=None, service_instance=None):
'''
Returns a list of dict representations of the disks in an ESXi host.
The list of disks can be filtered by disk canonical names or
scsi addresses.
disk_ids:
List of disk canonical names to be retrieved. Default is... |
def erase_disk_partitions(disk_id=None, scsi_address=None,
service_instance=None):
'''
Erases the partitions on a disk.
The disk can be specified either by the canonical name, or by the
scsi_address.
disk_id
Canonical name of the disk.
Either ``disk_id`` or... |
def list_disk_partitions(disk_id=None, scsi_address=None,
service_instance=None):
'''
Lists the partitions on a disk.
The disk can be specified either by the canonical name, or by the
scsi_address.
disk_id
Canonical name of the disk.
Either ``disk_id`` or `... |
def list_diskgroups(cache_disk_ids=None, service_instance=None):
'''
Returns a list of disk group dict representation on an ESXi host.
The list of disk groups can be filtered by the cache disks
canonical names. If no filtering is applied, all disk groups are returned.
cache_disk_ids:
List o... |
def create_diskgroup(cache_disk_id, capacity_disk_ids, safety_checks=True,
service_instance=None):
'''
Creates disk group on an ESXi host with the specified cache and
capacity disks.
cache_disk_id
The canonical name of the disk to be used as a cache. The disk must be
... |
def remove_diskgroup(cache_disk_id, data_accessibility=True,
service_instance=None):
'''
Remove the diskgroup with the specified cache disk.
cache_disk_id
The canonical name of the cache disk.
data_accessibility
Specifies whether to ensure data accessibility. Defau... |
def get_host_cache(service_instance=None):
'''
Returns the host cache configuration on the proxy host.
service_instance
Service instance (vim.ServiceInstance) of the vCenter/ESXi host.
Default is None.
.. code-block:: bash
salt '*' vsphere.get_host_cache
'''
# Default ... |
def configure_host_cache(enabled, datastore=None, swap_size_MiB=None,
service_instance=None):
'''
Configures the host cache on the selected host.
enabled
Boolean flag specifying whether the host cache is enabled.
datastore
Name of the datastore that contains th... |
def _check_hosts(service_instance, host, host_names):
'''
Helper function that checks to see if the host provided is a vCenter Server or
an ESXi host. If it's an ESXi host, returns a list of a single host_name.
If a host reference isn't found, we're trying to find a host object for a vCenter
server... |
def _format_coredump_stdout(cmd_ret):
'''
Helper function to format the stdout from the get_coredump_network_config function.
cmd_ret
The return dictionary that comes from a cmd.run_all call.
'''
ret_dict = {}
for line in cmd_ret['stdout'].splitlines():
line = line.strip().lower... |
def _format_firewall_stdout(cmd_ret):
'''
Helper function to format the stdout from the get_firewall_status function.
cmd_ret
The return dictionary that comes from a cmd.run_all call.
'''
ret_dict = {'success': True,
'rulesets': {}}
for line in cmd_ret['stdout'].splitlin... |
def _format_syslog_config(cmd_ret):
'''
Helper function to format the stdout from the get_syslog_config function.
cmd_ret
The return dictionary that comes from a cmd.run_all call.
'''
ret_dict = {'success': cmd_ret['retcode'] == 0}
if cmd_ret['retcode'] != 0:
ret_dict['message'... |
def _get_host_ref(service_instance, host, host_name=None):
'''
Helper function that returns a host object either from the host location or the host_name.
If host_name is provided, that is the host_object that will be returned.
The function will first search for hosts by DNS Name. If no hosts are found,... |
def _get_host_disks(host_reference):
'''
Helper function that returns a dictionary containing a list of SSD and Non-SSD disks.
'''
storage_system = host_reference.configManager.storageSystem
disks = storage_system.storageDeviceInfo.scsiLun
ssds = []
non_ssds = []
for disk in disks:
... |
def _get_vsan_eligible_disks(service_instance, host, host_names):
'''
Helper function that returns a dictionary of host_name keys with either a list of eligible
disks that can be added to VSAN or either an 'Error' message or a message saying no
eligible disks were found. Possible keys/values look like:
... |
def _reset_syslog_config_params(host, username, password, cmd, resets, valid_resets,
protocol=None, port=None, esxi_host=None, credstore=None):
'''
Helper function for reset_syslog_config that resets the config and populates the return dictionary.
'''
ret_dict = {}
al... |
def _set_syslog_config_helper(host, username, password, syslog_config, config_value,
protocol=None, port=None, reset_service=None, esxi_host=None, credstore=None):
'''
Helper function for set_syslog_config that sets the config and populates the return dictionary.
'''
cmd = ... |
def add_host_to_dvs(host, username, password, vmknic_name, vmnic_name,
dvs_name, target_portgroup_name, uplink_portgroup_name,
protocol=None, port=None, host_names=None):
'''
Adds an ESXi host to a vSphere Distributed Virtual Switch and migrates
the desired adapters t... |
def _get_proxy_target(service_instance):
'''
Returns the target object of a proxy.
If the object doesn't exist a VMwareObjectRetrievalError is raised
service_instance
Service instance (vim.ServiceInstance) of the vCenter/ESXi host.
'''
proxy_type = get_proxy_type()
if not salt.util... |
def _get_esxdatacenter_proxy_details():
'''
Returns the running esxdatacenter's proxy details
'''
det = __salt__['esxdatacenter.get_details']()
return det.get('vcenter'), det.get('username'), det.get('password'), \
det.get('protocol'), det.get('port'), det.get('mechanism'), \
... |
def _get_esxcluster_proxy_details():
'''
Returns the running esxcluster's proxy details
'''
det = __salt__['esxcluster.get_details']()
return det.get('vcenter'), det.get('username'), det.get('password'), \
det.get('protocol'), det.get('port'), det.get('mechanism'), \
det.get(... |
def _get_esxi_proxy_details():
'''
Returns the running esxi's proxy details
'''
det = __proxy__['esxi.get_details']()
host = det.get('host')
if det.get('vcenter'):
host = det['vcenter']
esxi_hosts = None
if det.get('esxi_host'):
esxi_hosts = [det['esxi_host']]
return ... |
def get_vm(name, datacenter=None, vm_properties=None, traversal_spec=None,
parent_ref=None, service_instance=None):
'''
Returns vm object properties.
name
Name of the virtual machine.
datacenter
Datacenter name
vm_properties
List of vm properties.
traversal... |
def get_vm_config_file(name, datacenter, placement, datastore,
service_instance=None):
'''
Queries the virtual machine config file and returns
vim.host.DatastoreBrowser.SearchResults object on success None on failure
name
Name of the virtual machine
datacenter
... |
def _apply_hardware_version(hardware_version, config_spec, operation='add'):
'''
Specifies vm container version or schedules upgrade,
returns True on change and False if nothing have been changed.
hardware_version
Hardware version string eg. vmx-08
config_spec
Configuration spec ob... |
def _apply_cpu_config(config_spec, cpu_props):
'''
Sets CPU core count to the given value
config_spec
vm.ConfigSpec object
cpu_props
CPU properties dict
'''
log.trace('Configuring virtual machine CPU '
'settings cpu_props=%s', cpu_props)
if 'count' in cpu_prop... |
def _apply_memory_config(config_spec, memory):
'''
Sets memory size to the given value
config_spec
vm.ConfigSpec object
memory
Memory size and unit
'''
log.trace('Configuring virtual machine memory '
'settings memory=%s', memory)
if 'size' in memory and 'unit'... |
def get_advanced_configs(vm_name, datacenter, service_instance=None):
'''
Returns extra config parameters from a virtual machine advanced config list
vm_name
Virtual machine name
datacenter
Datacenter name where the virtual machine is available
service_instance
vCenter ser... |
def _apply_advanced_config(config_spec, advanced_config, vm_extra_config=None):
'''
Sets configuration parameters for the vm
config_spec
vm.ConfigSpec object
advanced_config
config key value pairs
vm_extra_config
Virtual machine vm_ref.config.extraConfig object
'''
... |
def set_advanced_configs(vm_name, datacenter, advanced_configs,
service_instance=None):
'''
Appends extra config parameters to a virtual machine advanced config list
vm_name
Virtual machine name
datacenter
Datacenter name where the virtual machine is available
... |
def _delete_advanced_config(config_spec, advanced_config, vm_extra_config):
'''
Removes configuration parameters for the vm
config_spec
vm.ConfigSpec object
advanced_config
List of advanced config keys to be deleted
vm_extra_config
Virtual machine vm_ref.config.extraConfig... |
def delete_advanced_configs(vm_name, datacenter, advanced_configs,
service_instance=None):
'''
Removes extra config parameters from a virtual machine
vm_name
Virtual machine name
datacenter
Datacenter name where the virtual machine is available
advanced... |
def _get_scsi_controller_key(bus_number, scsi_ctrls):
'''
Returns key number of the SCSI controller keys
bus_number
Controller bus number from the adapter
scsi_ctrls
List of SCSI Controller objects (old+newly created)
'''
# list of new/old VirtualSCSIController objects, both ne... |
def _apply_hard_disk(unit_number, key, operation, disk_label=None, size=None,
unit='GB', controller_key=None, thin_provision=None,
eagerly_scrub=None, datastore=None, filename=None):
'''
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit
a virtu... |
def _create_adapter_type(network_adapter, adapter_type,
network_adapter_label=''):
'''
Returns a vim.vm.device.VirtualEthernetCard object specifying a virtual
ethernet card information
network_adapter
None or VirtualEthernet object
adapter_type
String, type... |
def _create_network_backing(network_name, switch_type, parent_ref):
'''
Returns a vim.vm.device.VirtualDevice.BackingInfo object specifying a
virtual ethernet card backing information
network_name
string, network name
switch_type
string, type of switch
parent_ref
Paren... |
def _apply_network_adapter_config(key, network_name, adapter_type, switch_type,
network_adapter_label=None, operation='add',
connectable=None, mac=None, parent=None):
'''
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a... |
def _apply_scsi_controller(adapter, adapter_type, bus_sharing, key,
bus_number, operation):
'''
Returns a vim.vm.device.VirtualDeviceSpec object specifying to
add/edit a SCSI controller
adapter
SCSI controller adapter name
adapter_type
SCSI controller ada... |
def _create_ide_controllers(ide_controllers):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing
IDE controllers
ide_controllers
IDE properties
'''
ide_ctrls = []
keys = range(-200, -250, -1)
if ide_controllers:
devs = [ide['adapter'] for ide in i... |
def _apply_ide_controller_config(ide_controller_label, operation,
key, bus_number=0):
'''
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit an
IDE controller
ide_controller_label
Controller label of the IDE adapter
operation
Ty... |
def _create_sata_controllers(sata_controllers):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing
SATA controllers
sata_controllers
SATA properties
'''
sata_ctrls = []
keys = range(-15000, -15050, -1)
if sata_controllers:
devs = [sata['adapter'] ... |
def _apply_sata_controller_config(sata_controller_label, operation,
key, bus_number=0):
'''
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a
SATA controller
sata_controller_label
Controller label of the SATA adapter
operation
... |
def _apply_cd_drive(drive_label, key, device_type, operation,
client_device=None, datastore_iso_file=None,
connectable=None, controller_key=200, parent_ref=None):
'''
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a
CD/DVD drive
drive_lab... |
def _set_network_adapter_mapping(domain, gateway, ip_addr, subnet_mask, mac):
'''
Returns a vim.vm.customization.AdapterMapping object containing the IP
properties of a network adapter card
domain
Domain of the host
gateway
Gateway address
ip_addr
IP address
subne... |
def _apply_serial_port(serial_device_spec, key, operation='add'):
'''
Returns a vim.vm.device.VirtualSerialPort representing a serial port
component
serial_device_spec
Serial device properties
key
Unique key of the device
operation
Add or edit the given device
.. ... |
def _create_disks(service_instance, disks, scsi_controllers=None, parent=None):
'''
Returns a list of disk specs representing the disks to be created for a
virtual machine
service_instance
Service instance (vim.ServiceInstance) of the vCenter.
Default is None.
disks
List of... |
def _create_scsi_devices(scsi_devices):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing
SCSI controllers
scsi_devices:
List of SCSI device properties
'''
keys = range(-1000, -1050, -1)
scsi_specs = []
if scsi_devices:
devs = [scsi['adapter'] fo... |
def _create_network_adapters(network_interfaces, parent=None):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing
the interfaces to be created for a virtual machine
network_interfaces
List of network interfaces and properties
parent
Parent object reference
... |
def _create_serial_ports(serial_ports):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing the
serial ports to be created for a virtual machine
serial_ports
Serial port properties
'''
ports = []
keys = range(-9000, -9050, -1)
if serial_ports:
devs... |
def _create_cd_drives(cd_drives, controllers=None, parent_ref=None):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing the
CD/DVD drives to be created for a virtual machine
cd_drives
CD/DVD drive properties
controllers
CD/DVD drive controllers (IDE, SATA)
... |
def _get_device_by_key(devices, key):
'''
Returns the device with the given key, raises error if the device is
not found.
devices
list of vim.vm.device.VirtualDevice objects
key
Unique key of device
'''
device_keys = [d for d in devices if d.key == key]
if device_keys:
... |
def _get_device_by_label(devices, label):
'''
Returns the device with the given label, raises error if the device is
not found.
devices
list of vim.vm.device.VirtualDevice objects
key
Unique key of device
'''
device_labels = [d for d in devices if d.deviceInfo.label == labe... |
def _convert_units(devices):
'''
Updates the size and unit dictionary values with the new unit values
devices
List of device data objects
'''
if devices:
for device in devices:
if 'unit' in device and 'size' in device:
device.update(
s... |
def compare_vm_configs(new_config, current_config):
'''
Compares virtual machine current and new configuration, the current is the
one which is deployed now, and the new is the target config. Returns the
differences between the objects in a dictionary, the keys are the
configuration parameter keys a... |
def get_vm_config(name, datacenter=None, objects=True, service_instance=None):
'''
Queries and converts the virtual machine properties to the available format
from the schema. If the objects attribute is True the config objects will
have extra properties, like 'object' which will include the
vim.vm.... |
def _update_disks(disks_old_new):
'''
Changes the disk size and returns the config spec objects in a list.
The controller property cannot be updated, because controller address
identifies the disk by the unit and bus number properties.
disks_diffs
List of old and new disk properties, the pr... |
def _update_scsi_devices(scsis_old_new, current_disks):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec specifying the scsi
properties as input the old and new configs are defined in a dictionary.
scsi_diffs
List of old and new scsi properties
'''
device_config_specs = []
if ... |
def _update_network_adapters(interface_old_new, parent):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec specifying
configuration(s) for changed network adapters, the adapter type cannot
be changed, as input the old and new configs are defined in a dictionary.
interface_old_new
Dictio... |
def _update_serial_ports(serial_old_new):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec specifying to edit a
deployed serial port configuration to the new given config
serial_old_new
Dictionary with old and new keys which contains the current and the
next config for a serial ... |
def _update_cd_drives(drives_old_new, controllers=None, parent=None):
'''
Returns a list of vim.vm.device.VirtualDeviceSpec specifying to edit a
deployed cd drive configuration to the new given config
drives_old_new
Dictionary with old and new keys which contains the current and the
nex... |
def _delete_device(device):
'''
Returns a vim.vm.device.VirtualDeviceSpec specifying to remove a virtual
machine device
device
Device data type object
'''
log.trace('Deleting device with type %s', type(device))
device_spec = vim.vm.device.VirtualDeviceSpec()
device_spec.operatio... |
def create_vm(vm_name, cpu, memory, image, version, datacenter, datastore,
placement, interfaces, disks, scsi_devices, serial_ports=None,
ide_controllers=None, sata_controllers=None, cd_drives=None,
advanced_configs=None, service_instance=None):
'''
Creates a virtual ma... |
def update_vm(vm_name, cpu=None, memory=None, image=None, version=None,
interfaces=None, disks=None, scsi_devices=None,
serial_ports=None, datacenter=None, datastore=None,
cd_dvd_drives=None, sata_controllers=None, advanced_configs=None,
service_instance=None):
... |
def register_vm(name, datacenter, placement, vmx_path, service_instance=None):
'''
Registers a virtual machine to the inventory with the given vmx file.
Returns comments and change list
name
Name of the virtual machine
datacenter
Datacenter of the virtual machine
placement
... |
def power_on_vm(name, datacenter=None, service_instance=None):
'''
Powers on a virtual machine specified by it's name.
name
Name of the virtual machine
datacenter
Datacenter of the virtual machine
service_instance
Service instance (vim.ServiceInstance) of the vCenter.
... |
def _remove_vm(name, datacenter, service_instance, placement=None,
power_off=None):
'''
Helper function to remove a virtual machine
name
Name of the virtual machine
service_instance
vCenter service instance for connection and configuration
datacenter
Datacen... |
def delete_vm(name, datacenter, placement=None, power_off=False,
service_instance=None):
'''
Deletes a virtual machine defined by name and placement
name
Name of the virtual machine
datacenter
Datacenter of the virtual machine
placement
Placement information ... |
def _determine_auth(**kwargs):
'''
Acquire Azure ARM Credentials
'''
if 'profile' in kwargs:
azure_credentials = __salt__['config.option'](kwargs['profile'])
kwargs.update(azure_credentials)
service_principal_creds_kwargs = ['client_id', 'secret', 'tenant']
user_pass_creds_kwarg... |
def get_client(client_type, **kwargs):
'''
Dynamically load the selected client and return a management client object
'''
client_map = {'compute': 'ComputeManagement',
'authorization': 'AuthorizationManagement',
'dns': 'DnsManagement',
'storage': 'St... |
def log_cloud_error(client, message, **kwargs):
'''
Log an azurearm cloud error exception
'''
try:
cloud_logger = getattr(log, kwargs.get('azurearm_log_level'))
except (AttributeError, TypeError):
cloud_logger = getattr(log, 'error')
cloud_logger(
'An AzureARM %s CloudE... |
def paged_object_to_list(paged_object):
'''
Extract all pages within a paged object as a list of dictionaries
'''
paged_return = []
while True:
try:
page = next(paged_object)
paged_return.append(page.as_dict())
except CloudError:
raise
exce... |
def create_object_model(module_name, object_name, **kwargs):
'''
Assemble an object from incoming parameters.
'''
object_kwargs = {}
try:
model_module = importlib.import_module('azure.mgmt.{0}.models'.format(module_name))
# pylint: disable=invalid-name
Model = getattr(model_... |
def compare_list_of_dicts(old, new, convert_id_to_name=None):
'''
Compare lists of dictionaries representing Azure objects. Only keys found in the "new" dictionaries are compared to
the "old" dictionaries, since getting Azure objects from the API returns some read-only data which should not be
used in t... |
def get_dependencies():
'''
Warn if dependencies aren't met.
'''
if LIBCLOUD_IMPORT_ERROR:
log.error("Failure when importing LibCloud: ", exc_info=LIBCLOUD_IMPORT_ERROR)
log.error("Note: The libcloud dependency is called 'apache-libcloud' on PyPi/pip.")
return config.check_driver_dep... |
def get_conn():
'''
Return a conn object for the passed VM data
'''
driver = get_driver(Provider.GCE)
provider = get_configured_provider()
project = config.get_cloud_config_value('project', provider, __opts__)
email = config.get_cloud_config_value(
'service_account_email_address',
... |
def _expand_node(node):
'''
Convert the libcloud Node object into something more serializable.
'''
ret = {}
ret.update(node.__dict__)
try:
del ret['extra']['boot_disk']
except Exception: # pylint: disable=W0703
pass
zone = ret['extra']['zone']
ret['extra']['zone'] = ... |
def _expand_disk(disk):
'''
Convert the libcloud Volume object into something more serializable.
'''
ret = {}
ret.update(disk.__dict__)
zone = ret['extra']['zone']
ret['extra']['zone'] = {}
ret['extra']['zone'].update(zone.__dict__)
return ret |
def _expand_address(addy):
'''
Convert the libcloud GCEAddress object into something more serializable.
'''
ret = {}
ret.update(addy.__dict__)
ret['extra']['zone'] = addy.region.name
return ret |
def _expand_balancer(lb):
'''
Convert the libcloud load-balancer object into something more serializable.
'''
ret = {}
ret.update(lb.__dict__)
hc = ret['extra']['healthchecks']
ret['extra']['healthchecks'] = []
for item in hc:
ret['extra']['healthchecks'].append(_expand_item(item... |
def show_instance(vm_name, call=None):
'''
Show the details of the existing instance.
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_instance action must be called with -a or --action.'
)
conn = get_conn()
node = _expand_node(conn.ex_get_node(vm_name))
... |
def avail_sizes(conn=None):
'''
Return a dict of available instances sizes (a.k.a machine types) and
convert them to something more serializable.
'''
if not conn:
conn = get_conn()
raw_sizes = conn.list_sizes('all') # get *all* the machine types!
sizes = []
for size in raw_sizes... |
def avail_images(conn=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data.
Note that for GCE, there are custom images within the project, but the
generic images are in other projects. This returns a dict of images in
the project plus images in well-know... |
def __get_image(conn, vm_):
'''
The get_image for GCE allows partial name matching and returns a
libcloud object.
'''
img = config.get_cloud_config_value(
'image', vm_, __opts__, default='debian-7', search_global=False)
return conn.ex_get_image(img) |
def __get_location(conn, vm_):
'''
Need to override libcloud to find the zone.
'''
location = config.get_cloud_config_value(
'location', vm_, __opts__)
return conn.ex_get_zone(location) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.