/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers
NameSizeModeActions
__pycache__/-0755rm
abiquo.py315290644editdlrm
auroracompute.py20400644editdlrm
azure.py1132270644editdlrm
azure_arm.py831320644editdlrm
bluebox.py74260644editdlrm
brightbox.py108590644editdlrm
bsnl.py19580644editdlrm
cloudscale.py88440644editdlrm
cloudsigma.py687690644editdlrm
cloudstack.py1638340644editdlrm
cloudwatt.py50940644editdlrm
digitalocean.py270640644editdlrm
dimensiondata.py1895570644editdlrm
dummy.py110740644editdlrm
ec2.py2193860644editdlrm
ecp.py117230644editdlrm
ecs.py638180644editdlrm
elastichosts.py74410644editdlrm
elasticstack.py163480644editdlrm
exoscale.py11590644editdlrm
gandi.py263050644editdlrm
gce.py3890860644editdlrm
gig_g8.py220130644editdlrm
gogrid.py152500644editdlrm
gridscale.py353810644editdlrm
gridspot.py42430644editdlrm
hostvirtual.py144270644editdlrm
ikoula.py11720644editdlrm
indosat.py19970644editdlrm
internetsolutions.py20500644editdlrm
joyent.py82130644editdlrm
kamatera.py234810644editdlrm
kili.py31990644editdlrm
ktucloud.py35950644editdlrm
kubevirt.py406780644editdlrm
libvirt_driver.py146710644editdlrm
linode.py266460644editdlrm
maxihost.py84190644editdlrm
medone.py19840644editdlrm
nephoscale.py176900644editdlrm
ntta.py20110644editdlrm
nttcis.py2229330644editdlrm
onapp.py165030644editdlrm
oneandone.py577580644editdlrm
opennebula.py433430644editdlrm
openstack.py1440080644editdlrm
ovh.py188450644editdlrm
packet.py336840644editdlrm
profitbricks.py1208060644editdlrm
rackspace.py94420644editdlrm
rimuhosting.py122920644editdlrm
scaleway.py242310644editdlrm
serverlove.py29340644editdlrm
skalicloud.py29170644editdlrm
softlayer.py179210644editdlrm
upcloud.py111560644editdlrm
vcl.py88430644editdlrm
vcloud.py947220644editdlrm
voxel.py109270644editdlrm
vpsnet.py67210644editdlrm
vsphere.py184070644editdlrm
vultr.py133280644editdlrm
__init__.py12070644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/gridspot.py (4243B)
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. from libcloud.compute.base import NodeDriver, Node from libcloud.compute.base import NodeState from libcloud.common.base import ConnectionKey, JsonResponse from libcloud.compute.types import Provider from libcloud.common.types import InvalidCredsError class GridspotAPIException(Exception): def __str__(self): # pylint: disable=unsubscriptable-object return self.args[0] def __repr__(self): # pylint: disable=unsubscriptable-object return "" % (self.args[0]) class GridspotResponse(JsonResponse): """ Response class for Gridspot """ def parse_body(self): body = super(GridspotResponse, self).parse_body() if 'exception_name' in body and body['exception_name']: raise GridspotAPIException(body['exception_name']) return body def parse_error(self): # Gridspot 404s on invalid api key or instance_id raise InvalidCredsError("Invalid api key/instance_id") class GridspotConnection(ConnectionKey): """ Connection class to connect to Gridspot's API servers """ host = 'gridspot.com' responseCls = GridspotResponse def add_default_params(self, params): params['api_key'] = self.key return params class GridspotNodeDriver(NodeDriver): """ Gridspot (http://www.gridspot.com/) node driver. """ type = Provider.GRIDSPOT name = 'Gridspot' website = 'http://www.gridspot.com/' connectionCls = GridspotConnection NODE_STATE_MAP = { 'Running': NodeState.RUNNING, 'Starting': NodeState.PENDING } def list_nodes(self): data = self.connection.request( '/compute_api/v1/list_instances').object return [self._to_node(n) for n in data['instances']] def destroy_node(self, node): data = {'instance_id': node.id} self.connection.request('/compute_api/v1/stop_instance', data).object return True def _get_node_state(self, state): result = self.NODE_STATE_MAP.get(state, NodeState.UNKNOWN) return result def _add_int_param(self, params, data, field): if data[field]: try: params[field] = int(data[field]) except Exception: pass def _to_node(self, data): port = None ip = None state = self._get_node_state(data['current_state']) if data['vm_ssh_wan_ip_endpoint'] != 'null': parts = data['vm_ssh_wan_ip_endpoint'].split(':') ip = parts[0] port = int(parts[1]) extra_params = { 'winning_bid_id': data['winning_bid_id'], 'port': port } # Spec is vague and doesn't indicate if these will always be present self._add_int_param(extra_params, data, 'vm_num_logical_cores') self._add_int_param(extra_params, data, 'vm_num_physical_cores') self._add_int_param(extra_params, data, 'vm_ram') self._add_int_param(extra_params, data, 'start_state_time') self._add_int_param(extra_params, data, 'ended_state_time') self._add_int_param(extra_params, data, 'running_state_time') return Node( id=data['instance_id'], name=data['instance_id'], state=state, public_ips=[ip], private_ips=[], driver=self.connection.driver, extra=extra_params)