INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
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. | 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... |
Helper function to format the stdout from the get_coredump_network_config function. | 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... |
Helper function to format the stdout from the get_firewall_status function. | 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... |
Helper function to format the stdout from the get_syslog_config function. | 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'... |
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. | 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,... |
Helper function that returns a dictionary containing a list of SSD and Non - SSD disks. | 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:
... |
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 _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:
... |
Helper function for reset_syslog_config that resets the config and populates the return dictionary. | 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... |
Helper function for set_syslog_config that sets the config and populates the return dictionary. | 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 = ... |
Adds an ESXi host to a vSphere Distributed Virtual Switch and migrates the desired adapters to the DVS from the standard switch. | 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... |
Returns the target object of a proxy. | 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... |
Returns the running esxdatacenter s proxy details | 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'), \
... |
Returns the running esxcluster s proxy details | 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(... |
Returns the running esxi s proxy details | 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 ... |
Returns vm object properties. | 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... |
Queries the virtual machine config file and returns vim. host. DatastoreBrowser. SearchResults object on success None on failure | 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
... |
Specifies vm container version or schedules upgrade returns True on change and False if nothing have been changed. | 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... |
Sets CPU core count to the given value | 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... |
Sets memory size to the given value | 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'... |
Returns extra config parameters from a virtual machine advanced config list | 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... |
Sets configuration parameters for the vm | 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
'''
... |
Appends extra config parameters to a virtual machine advanced config list | 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
... |
Removes configuration parameters for the vm | 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... |
Removes extra config parameters from a virtual machine | 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... |
Returns key number of the SCSI controller keys | 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... |
Returns a vim. vm. device. VirtualDeviceSpec object specifying to add/ edit a virtual disk device | 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... |
Returns a vim. vm. device. VirtualEthernetCard object specifying a virtual ethernet card information | 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... |
Returns a vim. vm. device. VirtualDevice. BackingInfo object specifying a virtual ethernet card backing information | 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... |
Returns a vim. vm. device. VirtualDeviceSpec object specifying to add/ edit a network device | 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... |
Returns a vim. vm. device. VirtualDeviceSpec object specifying to add/ edit a SCSI controller | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec objects representing IDE controllers | 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... |
Returns a vim. vm. device. VirtualDeviceSpec object specifying to add/ edit an IDE controller | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec objects representing SATA controllers | 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'] ... |
Returns a vim. vm. device. VirtualDeviceSpec object specifying to add/ edit a SATA controller | 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
... |
Returns a vim. vm. device. VirtualDeviceSpec object specifying to add/ edit a CD/ DVD drive | 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... |
Returns a vim. vm. customization. AdapterMapping object containing the IP properties of a network adapter card | 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... |
Returns a vim. vm. device. VirtualSerialPort representing a serial port component | 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
.. ... |
Returns a list of disk specs representing the disks to be created for a virtual machine | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec objects representing SCSI controllers | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec objects representing the interfaces to be created for a virtual machine | 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
... |
Returns a list of vim. vm. device. VirtualDeviceSpec objects representing the serial ports to be created for a virtual machine | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec objects representing the CD/ DVD drives to be created for a virtual machine | 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)
... |
Returns the device with the given key raises error if the device is not found. | 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:
... |
Returns the device with the given label raises error if the device is not found. | 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... |
Updates the size and unit dictionary values with the new unit values | 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... |
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 and the values are differences objects: either list or recursive difference | 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... |
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. device. VirtualDevice this is necessary for deletion and update actions. | 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.... |
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. | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec specifying the scsi properties as input the old and new configs are defined in a dictionary. | 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 ... |
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. | 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... |
Returns a list of vim. vm. device. VirtualDeviceSpec specifying to edit a deployed serial port configuration to the new given config | 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 ... |
Returns a list of vim. vm. device. VirtualDeviceSpec specifying to edit a deployed cd drive configuration to the new given config | 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... |
Returns a vim. vm. device. VirtualDeviceSpec specifying to remove a virtual machine device | 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... |
Creates a virtual machine container. | 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... |
Updates the configuration of the virtual machine if the config differs | 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):
... |
Registers a virtual machine to the inventory with the given vmx file. Returns comments and change list | 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
... |
Powers on a virtual machine specified by it s name. | 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.
... |
Helper function to remove a virtual machine | 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... |
Deletes a virtual machine defined by name and placement | 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 ... |
Acquire Azure ARM Credentials | 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... |
Dynamically load the selected client and return a management client object | 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... |
Log an azurearm cloud error exception | 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... |
Extract all pages within a paged object as a list of dictionaries | 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... |
Assemble an object from incoming parameters. | 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_... |
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 the comparison. A list of parameter names can be passed in order to compare a bare obj... | 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... |
Warn if dependencies aren t met. | 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... |
Return a conn object for the passed VM data | 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',
... |
Convert the libcloud Node object into something more serializable. | 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'] = ... |
Convert the libcloud Volume object into something more serializable. | 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 |
Convert the libcloud GCEAddress object into something more serializable. | 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 |
Convert the libcloud load - balancer object into something more serializable. | 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... |
Show the details of the existing instance. | 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))
... |
Return a dict of available instances sizes ( a. k. a machine types ) and convert them to something more serializable. | 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... |
Return a dict of all available VM images on the cloud provider with relevant data. | 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... |
The get_image for GCE allows partial name matching and returns a libcloud object. | 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) |
Need to override libcloud to find the zone. | 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) |
Need to override libcloud to find the machine type in the proper zone. | def __get_size(conn, vm_):
'''
Need to override libcloud to find the machine type in the proper zone.
'''
size = config.get_cloud_config_value(
'size', vm_, __opts__, default='n1-standard-1', search_global=False)
return conn.ex_get_size(size, __get_location(conn, vm_)) |
Get configured tags. | def __get_tags(vm_):
'''
Get configured tags.
'''
t = config.get_cloud_config_value(
'tags', vm_, __opts__,
default='[]', search_global=False)
# Consider warning the user that the tags in the cloud profile
# could not be interpreted, bad formatting?
try:
tags = litera... |
Get configured metadata and add salt - cloud - profile. | def __get_metadata(vm_):
'''
Get configured metadata and add 'salt-cloud-profile'.
'''
md = config.get_cloud_config_value(
'metadata', vm_, __opts__,
default='{}', search_global=False)
# Consider warning the user that the metadata in the cloud profile
# could not be interpreted, ... |
Return public IP private IP or hostname for the libcloud node object | def __get_host(node, vm_):
'''
Return public IP, private IP, or hostname for the libcloud 'node' object
'''
if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None:
ip_address = node.private_ips[0]
log.info('Salt node data. Private_ip: %s', ip_address)
else:
... |
Return a GCE libcloud network object with matching name | def __get_network(conn, vm_):
'''
Return a GCE libcloud network object with matching name
'''
network = config.get_cloud_config_value(
'network', vm_, __opts__,
default='default', search_global=False)
return conn.ex_get_network(network) |
Get configured subnetwork. | def __get_subnetwork(vm_):
'''
Get configured subnetwork.
'''
ex_subnetwork = config.get_cloud_config_value(
'subnetwork', vm_, __opts__,
search_global=False)
return ex_subnetwork |
Return a GCE libcloud region object with matching name. | def __get_region(conn, vm_):
'''
Return a GCE libcloud region object with matching name.
'''
location = __get_location(conn, vm_)
region = '-'.join(location.name.split('-')[:2])
return conn.ex_get_region(region) |
Reuse or create a static IP address. Returns a native GCEAddress construct to use with libcloud. | def __create_orget_address(conn, name, region):
'''
Reuse or create a static IP address.
Returns a native GCEAddress construct to use with libcloud.
'''
try:
addy = conn.ex_get_address(name, region)
except ResourceNotFoundError: # pylint: disable=W0703
addr_kwargs = {
... |
Convert firewall rule allowed user - string to specified REST API format. | def _parse_allow(allow):
'''
Convert firewall rule allowed user-string to specified REST API format.
'''
# input=> tcp:53,tcp:80,tcp:443,icmp,tcp:4201,udp:53
# output<= [
# {"IPProtocol": "tcp", "ports": ["53","80","443","4201"]},
# {"IPProtocol": "icmp"},
# {"IPProtocol": "u... |
Get configured SSH credentials. | def __get_ssh_credentials(vm_):
'''
Get configured SSH credentials.
'''
ssh_user = config.get_cloud_config_value(
'ssh_username', vm_, __opts__, default=os.getenv('USER'))
ssh_key = config.get_cloud_config_value(
'ssh_keyfile', vm_, __opts__,
default=os.path.expanduser('~/.ss... |
... versionchanged:: 2017. 7. 0 Create a GCE network. Must specify name and cidr. | def create_network(kwargs=None, call=None):
'''
... versionchanged:: 2017.7.0
Create a GCE network. Must specify name and cidr.
CLI Example:
.. code-block:: bash
salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional
salt-cloud -f create_ne... |
Permanently delete a network. | def delete_network(kwargs=None, call=None):
'''
Permanently delete a network.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_network gce name=mynet
'''
if call != 'function':
raise SaltCloudSystemExit(
'The delete_network function must be called with -f or ... |
Show the details of an existing network. | def show_network(kwargs=None, call=None):
'''
Show the details of an existing network.
CLI Example:
.. code-block:: bash
salt-cloud -f show_network gce name=mynet
'''
if call != 'function':
raise SaltCloudSystemExit(
'The show_network function must be called with -... |
... versionadded:: 2017. 7. 0 Create a GCE Subnetwork. Must specify name cidr network and region. | def create_subnetwork(kwargs=None, call=None):
'''
... versionadded:: 2017.7.0
Create a GCE Subnetwork. Must specify name, cidr, network, and region.
CLI Example:
.. code-block:: bash
salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 descrip... |
... versionadded:: 2017. 7. 0 Delete a GCE Subnetwork. Must specify name and region. | def delete_subnetwork(kwargs=None, call=None):
'''
... versionadded:: 2017.7.0
Delete a GCE Subnetwork. Must specify name and region.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_subnetwork gce name=mysubnet network=mynet1 region=us-west1
'''
if call != 'function':
... |
... versionadded:: 2017. 7. 0 Show details of an existing GCE Subnetwork. Must specify name and region. | def show_subnetwork(kwargs=None, call=None):
'''
... versionadded:: 2017.7.0
Show details of an existing GCE Subnetwork. Must specify name and region.
CLI Example:
.. code-block:: bash
salt-cloud -f show_subnetwork gce name=mysubnet region=us-west1
'''
if call != 'function':
... |
Create a GCE firewall rule. The default network is used if not specified. | def create_fwrule(kwargs=None, call=None):
'''
Create a GCE firewall rule. The 'default' network is used if not specified.
CLI Example:
.. code-block:: bash
salt-cloud -f create_fwrule gce name=allow-http allow=tcp:80
'''
if call != 'function':
raise SaltCloudSystemExit(
... |
Permanently delete a firewall rule. | def delete_fwrule(kwargs=None, call=None):
'''
Permanently delete a firewall rule.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_fwrule gce name=allow-http
'''
if call != 'function':
raise SaltCloudSystemExit(
'The delete_fwrule function must be called wit... |
Show the details of an existing firewall rule. | def show_fwrule(kwargs=None, call=None):
'''
Show the details of an existing firewall rule.
CLI Example:
.. code-block:: bash
salt-cloud -f show_fwrule gce name=allow-http
'''
if call != 'function':
raise SaltCloudSystemExit(
'The show_fwrule function must be calle... |
Create an HTTP health check configuration. | def create_hc(kwargs=None, call=None):
'''
Create an HTTP health check configuration.
CLI Example:
.. code-block:: bash
salt-cloud -f create_hc gce name=hc path=/healthy port=80
'''
if call != 'function':
raise SaltCloudSystemExit(
'The create_hc function must be c... |
Permanently delete a health check. | def delete_hc(kwargs=None, call=None):
'''
Permanently delete a health check.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_hc gce name=hc
'''
if call != 'function':
raise SaltCloudSystemExit(
'The delete_hc function must be called with -f or --function.'
... |
Show the details of an existing health check. | def show_hc(kwargs=None, call=None):
'''
Show the details of an existing health check.
CLI Example:
.. code-block:: bash
salt-cloud -f show_hc gce name=hc
'''
if call != 'function':
raise SaltCloudSystemExit(
'The show_hc function must be called with -f or --functi... |
Create a static address in a region. | def create_address(kwargs=None, call=None):
'''
Create a static address in a region.
CLI Example:
.. code-block:: bash
salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP
'''
if call != 'function':
raise SaltCloudSystemExit(
'The create_addres... |
Permanently delete a static address. | def delete_address(kwargs=None, call=None):
'''
Permanently delete a static address.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_address gce name=my-ip
'''
if call != 'function':
raise SaltCloudSystemExit(
'The delete_address function must be called with... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.