Giter Site home page Giter Site logo

pyarubacloud's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyarubacloud's Issues

remove_ip broken

Error when calling CloudInterface.remove_ip(ip_id=resourceid)

Traceback (most recent call last):
  File "./getIps.py", line 45, in <module>
    ci.remove_ip(ip_id=467227)
  File "build/bdist.linux-x86_64/egg/ArubaCloud/PyArubaAPI.py", line 304, in remove_ip
  File "build/bdist.linux-x86_64/egg/ArubaCloud/base/__init__.py", line 29, in gen_def_json_scheme
ValueError: dictionary update sequence element #0 has length 1; 2 is required

Fix: Change line 303 of ArubaCloud/PyArubaAPI.py from:
ip_id = ' "IpAddressResourceId": %s' % ip_id
To:
ip_id = {'IpAddressResourceId': ip_id}

Full method:

def remove_ip(self, ip_id):
        """
        Delete an Ip from the boughs ip list
        @param (str) ip_id: a string representing the resource id of the IP
        @return: True if json method had success else False
        """
        #ip_id = '    "IpAddressResourceId": %s' % ip_id
        ip_id = {'IpAddressResourceId': ip_id}
        json_scheme = self.gen_def_json_scheme('SetRemoveIpAddress', ip_id)
        json_obj = self.call_method_post(method='SetRemoveIpAddress', json_scheme=json_scheme)
        pprint(json_obj)

ResultCode: -500

Hi, I'm receiving this error on smart VM creation:

{u'ResultCode': -500, u'Success': False, u'ResultMessage': u'Object reference not set to an instance of an object.\r\nExceptionCode=-500\r\n', u'ExceptionInfo': None}

Command executed:

python create_smart_vm.py -d 1 -u USERNAME -w PASSWORD -t 1608 --vmpassword VMPASSWORD --pkg small

REST API Documentation or Swagger ?

Hi ,
There is any documentation for API ? I am .NET programmer and I would like communicate with REST API from .NET Core app. But I cannot find any documentation.

Bug during/after python3 installation + temp fix

When installing the library from github with python3 setup.py install I get the following error:

byte-compiling build/bdist.linux-x86_64/egg/ArubaCloud/__init__.py to __init__.cpython-35.pyc
  File "build/bdist.linux-x86_64/egg/ArubaCloud/__init__.py", line 1
    __version__ = 0.7.6
                      ^
SyntaxError: invalid syntax

This error also shows up when trying to run one of the examples:

Traceback (most recent call last):
  File "print_vm.py", line 3, in <module>
    from ArubaCloud.PyArubaAPI import CloudInterface
  File "/usr/local/lib/python3.5/dist-packages/ArubaCloud/__init__.py", line 1
    __version__ = 0.7.6
                      ^
SyntaxError: invalid syntax

A temporary fix is to simply open the __init.py__ file in question and add quotes at the version number: __version__ = "0.7.6"
This seems to solve the issue.
I've briefly skimmed through the library, and found a similar error in multiple places.

The library is being too naive when calling commit()

The code is trying to json.loads() the reply of the server without actually checking the response code. If something didn't go right (for example, passing an invalid template ID to the Creator), the server returns plain HTML describing the error, but the library tries to load it as if it was JSON.

Backtrace:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Request Error</title>
    <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
  </head>
  <body>
    <div id="content">
      <p class="heading1">Request Error</p>
      <p>The server encountered an error processing the request. The exception message is 'There was an error deserializing the object of type Aruba.Cloud.WsEndUser.Json.SetEnqueueServerCreationRequest. The value 'centos-wp-template' cannot be parsed as the type 'Int32'.'. See server logs for more details. The exception stack trace is: </p>
      <p>   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
   at System.ServiceModel.Dispatcher.SingleBodyParameterDataContractMessageFormatter.ReadObject(Message message)
   at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>
    </div>
  </body>
</html>
Traceback (most recent call last):
  File "poc.py", line 36, in <module>
    print(c.commit(url=ci.wcf_baseurl, debug=True))
  File "/pyArubaCloud/ArubaCloud/objects/__init__.py", line 24, in commit
    parsed_response = json.loads(response.content)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

set_ssh_key when reinitializing smart vm

Hi,
I'm wondering if there is a way to set ssh key when reinitializing smart vm using set_ssh_key method on the vm object being reinitialized, by something like this: vm.set_ssh_key(string)
Thanks a lot for your thoughts ;)

Unknown error retrieving IP.

Hello,

When I try to create a new vm I get this error:

Traceback (most recent call last):
  File "./examples/create_pro_vm.py", line 20, in <module>
    ip = i.purchase_ip()
  File "/usr/local/lib/python2.7/site-packages/ArubaCloud/PyArubaAPI.py", line 251, in purchase_ip
    raise Exception('Unknown error retrieving IP.')
Exception: Unknown error retrieving IP.

Here is the command I typed:

python ./examples/create_pro_vm.py -d 4 -u my_login -w my_password -t 35 -n aruba-vps-0004 --vmpassword vmpass

Change OS

How can I change OS on smart or pro vm via API? It can handle only admin pass change.

List LoadBalancer and servers linked to it

Hi, I see there's a class LoadBalancer somewhere in the project, in the folder Compute
If I look in the folder test, there's a file LoadBalancer, which imports the Compute module
The fact is that Compute is not exported as a module for ArubaCloud and when I try to import the LoadBalancer class it says that the Compute module doesn't exist.

I don't know much about python, and I'm trying to tweak some of the code, but without success.

Is there a way to import the Compute module or a way to list only load balancers and the respective servers linked?

Upgrade Smart VM

Hi, please help me, how can I upgrade smart vm?
I found just edit pro vm hardware.

Thank You!
Regards: Gabor

Unable to create Smart VM by API ExceptionCode 19

Hi,

Could you explain me what does code 19 mean? I've been used that api for few months without any problems, but now I can't.
Provided parameters for python script looks good comparing to previous execution.

python create_smart_vm.py -d 1 -u MY_USER -w **** -t 542 -n myHostName --vmpassword **** '{"Username": "MY_USER", "Password": "****", "ApplicationId": "SetEnqueueServerCreation", "RequestId": "SetEnqueueServerCreation", "Server": {"Note": "Create by pyArubaCloud", "OSTemplateId": "542", "AdministratorPassword": "****", "SmartVMWarePackageID": 1, "Name": "myHostName"}}' {u'ResultCode': 19, u'Success': False, u'ResultMessage': u'Cannot create Hyper-V Low Cost Server anymore\r\nExceptionCode=19\r\n\r\nExceptionCode=19\r\n', u'ExceptionInfo': None} False

Remove ip from server

I want to remove the IP from the list of public IPs
Is it possible to remove the IP from the server before deleting it from the public IP list?
Because when I delete IP:

ci = CloudInterface(dc=1)
ci.login(username='*******', password='*******', load=True)
ci.remove_ip('2944713')

I receive the following message:
ArubaCloud.base.Errors.RequestFailed: Request: {"ApplicationId": "SetRemoveIpAddress", "RequestId": "SetRemoveIpAddress", "SessionId": "SetRemoveIpAddress", "Password": "******", "Username": "******", "IpAddressResourceId": "2944713"}, Response: {'ExceptionInfo': None, 'ResultCode': 8, 'ResultMessage': 'IP address with ResourceId=2944713 is associated with Server 468218\r\nExceptionCode=8\r\n\r\nExceptionCode=8\r\n', 'Success': False}
and the IP is not removed from the IP list

Can't get a list of scheduled tasks

What should I pass to get_scheduled_operations method as start/end-Date in order to get a list of ScheduledTasks?

I get always the following response
{ "ExceptionInfo": null, "ResultCode": 36, "ResultMessage": "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.\r\nExceptionCode=36\r\n", "Success": false, "Value": null }

Snapshot

Create, Restore and Delete Snapshot returns an error. Could you check it?

'ResultMessage': "There was an error while trying to serialize parameter http://services.cloud.it/WCFPlatform:snapshotOperation.
The InnerException message was 'Enum value '0' is invalid for type 'Aruba.Cloud.Provisioning.Entities.SnapshotOperationTypes' and cannot be serialized.
Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.'.

Python failed

Dear Developers,

I have an issue with this api:
On Ubuntu 14.04 I got this error message:
2016-03-08 09:26:08,074 MainThread ERROR CloudInterface: Caught Exception: <type 'exceptions.TypeError'> in: PyArubaAPI.py at line: 67
Msg: request() got an unexpected keyword argument 'json'
Traceback (most recent call last):
File "teszt.py", line 7, in
ci.login(username="FHU-29**", password="*******", load=True)
File "/usr/local/lib/python2.7/dist-packages/ArubaCloud/PyArubaAPI.py", line 74, in login
raise Exception(e)
Exception: request() got an unexpected keyword argument 'json'

After I upgrade Ubuntu 15.10 I got new one:
python examples/get_hypervisors.py -d 3 -u 29***** -w U********S
2016-03-16 17:06:24,058 MainThread ERROR CloudInterface: Caught Exception: <class 'requests.exceptions.ConnectionError'> in: PyArubaAPI.py at line: 67
Msg: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
Traceback (most recent call last):
File "examples/get_hypervisors.py", line 13, in
i.login(username=p.username, password=p.password, load=True)
File "/usr/local/lib/python2.7/dist-packages/ArubaCloud/PyArubaAPI.py", line 74, in login
raise Exception(e)
Exception: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

Please help me solve this issue.
Thank You and best regards:
Gabor Czipri
Melius-Group Kft

Provide HTTP RESTful API

Hopefully Arubacloud will support HTTP RESTful API as soon as possible so that my platform will be able to automatically send HTTP posts with JSON data to your system and to do tasks such as:

  • rent a server
  • cancel a server
  • shut down a server
  • make snapshots
  • restart a server

Support full DNS API

Hello,

are there plans to support more of the DNS API described here? In particular, we'd like to see TLD management support.
Thanks.

Support for location roulette

I've noticed that currently, in order to create a small SmartVM device with discounted price, we need to create machines in some special way, where server location is randomized - unfortunately, it's not specified anywhere how to do it.

Would it be possible to get support for this randomization in pyArubaCloud?

Reqs

Hi,

How can I upgrade smart VM?
How can I do snapshot?
How can I use console, or recovery console?

Thank You

Code Climate problem

Code Climate is no longer able to connect to this repo, so this data is out-of-date. Please see this help article or contact us for help.

Please connect CC to this repo.

GetVMMetrics

Please can you add support for used traffic?

https://admin.dc1.computing.cloud.it/Manage/Server/ServerList.aspx/GetVMMetrics
{"vmID":"12345"}

{"d":{"Result":"OK","Record":{"Total":12000000,"Value":304929}}}

ProVmCreator failing

Hello, I'm trying to create a pro vm on dc1, here are the 2 functions i defined:

from ArubaCloud.PyArubaAPI import CloudInterface
from ArubaCloud.objects import ProVmCreator

def create_new_provm(ci, cname, rootpw, idtemplate):
    ip = ci.purchase_ip(debug=True)
    c = ProVmCreator(name=cname, admin_password=rootpw, template_id=idtemplate, auth_obj=ci.auth)
    c.set_cpu_qty(1)
    c.set_ram_qty(1)
    c.add_public_ip(public_ip_address_resource_id=ip.resid)
    c.add_virtual_disk(size=10)
    print(c.commit(url=ci.wcf_baseurl, debug=True))
    return ip.ip_addr

def login(user, pword, datacenter):
    ci = CloudInterface(dc=datacenter, debug_level=logging.DEBUG)
    ci.login(username=user, password=pword, load=False)
    return ci

I'm trying to call the functions with:

ci = login("XXX-YYYYY", "mypassword", 1)
create_new_provm(ci, "vmname", "vmpassword", "2144") # 2144 is Ubuntu 16.04 x64

However it fails with following error code:

{u'ResultCode': 22, u'Success': False, u'ResultMessage': u'Product not in PriceList :: BillingManager.CheckProductsCost :: ProductID [320,321,322] not in PriceList\r\nExceptionCode=-900\r\n\r\nExceptionCode=22\r\n\r\nExceptionCode=22\r\n', u'ExceptionInfo': None}

I can see that the public ip is successfully purchased and unassigned, but the VM creation fails.

Authentication failed, token not found

I'm trying to use the print_reversedns module.

I launch it with these parameters:
--datacenter=1 (which is the IT1 datacenter)
--username=<my username>
--password=<my password>

Where <my username> is the username I see in the customer area page (it starts with ARU- followed by digits), and the password is the one I use to login to customerarea.aruba.it (for which I use the [email protected] username).

With those parameters, I have this exception:

RequestFailed
Request: {"ApplicationId": "GetPurchasedIpAddresses", "RequestId": "GetPurchasedIpAddresses", "SessionId": "GetPurchasedIpAddresses", "Password": "<my password>", "Username": "<my username>"}, Response: {'ExceptionInfo': None, 'ResultCode': 2, 'ResultMessage': 'Authentication failed, token not found.\r\nExceptionCode=2\r\n', 'Success': False}
  File "pyArubaCloud\ArubaCloud\base\__init__.py", line 43, in call_method_post
    raise RequestFailed("Request: {}, Response: {}".format(json_scheme, parsed_response))
  File "pyArubaCloud\ArubaCloud\PyArubaAPI.py", line 334, in get_ip
    json_obj = self.call_method_post(method='GetPurchasedIpAddresses ', json_scheme=json_scheme)
  File "pyArubaCloud\ArubaCloud\PyArubaAPI.py", line 66, in login
    self.get_ip()
  File "pyArubaCloud\examples\print_reversedns.py", line 15, in <module>
    ci.login(username=p.username, password=p.password, load=True)

Am I doing something wrong?

PS: I cloned this repository, I'm using master @ 5db264a

add_public_ip for vm Pro object

is there any way to add a CloudInterface.purchase_ip to a CloudInterface.vm ?
the add_public_ip method is a method of vmProCreator Object, not a method of VmPro Object.
so how can i add a public ip (that i purchased with CloudInterface.purchase_ip) to an already created vm?

Create multiple objects in one script

I want to make an object from every location (datacenter).
So that I can check all the servers available in each location(datacenter).
Doesn't creating multiple objects in a script create a problem(such as blocking ,....) for my arubacloud account?
As follows:
c1 = CloudInterface(dc=1)
c2 = CloudInterface(dc=2)
c3 = CloudInterface(dc=3)
c4 = CloudInterface(dc=4)
c5 = CloudInterface(dc=5)
c6 = CloudInterface(dc=6)
c1.login(username='******', password='******', load=True)
c2.login(username='******', password='******', load=True)
c3.login(username='******', password='******', load=True)
c4.login(username='******', password='******', load=True)
c5.login(username='******', password='******', load=True)

Content length has a wrong data type

Content-length (header) must be a string, not an integer, as per this

Backtrace:

Traceback (most recent call last):
  File "poc.py", line 36, in <module>
    print(c.commit(url=ci.wcf_baseurl, debug=True))
  File "/pyArubaCloud/ArubaCloud/objects/__init__.py", line 22, in commit
    response = Http.post(url=url, data=self.get_json(), headers=headers)
  File "/pyArubaCloud/ArubaCloud/helper/__init__.py", line 31, in post
    response = requests.post(url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/sessions.py", line 457, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/sessions.py", line 390, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/models.py", line 295, in prepare
    self.prepare_headers(headers)
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/models.py", line 409, in prepare_headers
    check_header_validity(header)
  File "/usr/local/lib/python2.7/dist-packages/requests-2.11.0-py2.7.egg/requests/utils.py", line 756, in check_header_validity
    "not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value 309 must be of type str or bytes, not <type 'int'>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.