Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
11
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ac9a0cb8
authored
Aug 07, 2019
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix flake8 errors
parent
db0c13a5
Pipeline
#819
failed with stages
in 1 minute 58 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
171 deletions
+0
-171
recircle/example.py
+0
-166
recircle/instance/views.py
+0
-5
No files found.
recircle/example.py
deleted
100644 → 0
View file @
db0c13a5
# This file is for testing the openstack api access
from
interface_openstack.implementation.vm.instance
import
OSVirtualMachineManager
from
interface_openstack.interface.vm.resources
import
BlockDeviceMapping
,
Flavor
import
openstack
import
os
# from interface_openstack.implementation.network.OpenstackFloatingIPManager import OpenstackFloatingIPManager
# from interface_openstack.implementation.network.OpenstackNetworkManager import OpenstackNetworkManager
# from interface_openstack.implementation.network.OpenstackPortManager import OpenstackPortManager
# from interface_openstack.implementation.network.OpenstackRouterManager import OpenstackRouterManager
# from interface_openstack.implementation.network.OpenstackSubnetManager import OpenstackSubnetManager
# openstack.enable_logging(debug=True)
CONNECTION
=
{
"auth_url"
:
os
.
getenv
(
"OS_AUTH_URL"
),
"project_id"
:
os
.
getenv
(
"OS_PROJECT_ID"
),
"project_name"
:
os
.
getenv
(
"OS_PROJECT_NAME"
),
"user_domain_name"
:
os
.
getenv
(
"OS_USER_DOMAIN_NAME"
,
"Default"
),
"user_domain_id"
:
os
.
getenv
(
"OS_USER_DOMAIN_ID"
,
"default"
),
"project_domain_id"
:
os
.
getenv
(
"OS_PROJECT_DOMAIN_ID"
,
"default"
),
"username"
:
os
.
getenv
(
"OS_USERNAME"
),
"password"
:
os
.
getenv
(
"OS_PASSWORD"
),
"region_name"
:
os
.
getenv
(
"OS_REGION_NAME"
),
"interface"
:
os
.
getenv
(
"OS_INTERFACE"
),
"identity_api_version"
:
os
.
getenv
(
"OS_IDENTITY_API_VERSION"
),
}
block_dev_map
=
BlockDeviceMapping
(
boot_index
=
0
,
uuid
=
"da51253f-867c-472d-8ce0-81e7b7126d60"
,
source_type
=
"image"
,
volume_size
=
10
,
destination_type
=
"volume"
,
delete_on_termination
=
True
,
disk_bus
=
"scsi"
)
networks
=
[{
"uuid"
:
"c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"
}]
interface
=
OSVirtualMachineManager
(
CONNECTION
)
print
(
'#'
*
40
)
# interface.create_vm_from_template('new_server', resource, "cirros-0.4.0-x86_64-disk")
# interface.stop_vm('a6bc504f-a422-4492-b429-e5dad2df12f4')
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server)
# print(interface.delete_flavor("flavorTest"))
for
flavor
in
interface
.
list_flavors
():
print
(
flavor
.
JSON
())
for
vm
in
interface
.
list_all_vm
():
print
(
vm
.
JSON
())
print
(
"*"
*
50
)
# print(interface.create_base_vm("BaseTest", "2", networks, block_dev_map).JSON())
print
(
"*********TEST SERVER**********"
)
# print(interface.get_vm("dd529142-9836-4f36-8288-8fc2c62ed185").JSON())
#
# print(interface.openstack.get_server("dd529142-9836-4f36-8288-8fc2c62ed185"))
print
(
interface
.
create_vm_from_template
(
name
=
"Print test"
,
flavor
=
"84"
,
networks
=
[{
"uuid"
:
"c7f81071-49e3-47af-8235-99d21997e238"
}],
image
=
"04451eac-7017-4f6c-a2ea-897c6dd3db04"
,
))
# print("*********TEST SUSPEND**********")
# interface.suspend_vm("fb91a363-e23b-4fb6-8770-357509b753da")
#
# interface.detach_volume("8e94c162-f8ed-4872-b9e5-50bf33040b5b",
# "83d4f11a-f6a8-4f50-8a95-8f5016604780")
# print(interface.convert_server_to_instance(server).JSON())
# print(interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b"))
# print(server.JSON())
# print(interface.get_vnc_console("8e94c162-f8ed-4872-b9e5-50bf33040b5b"))
# print(interface.convert_server_to_instance(server))
# print(interface.get_vnc_console("New test"))
# interface.create_template("New test", "test_template")
# interface.create_vm_from_template("test_template", resource, [{"uuid": "c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"}])
# interface.resize_vm(server, resource)
# interface.reboot_vm(server.id)
# interface.reset_vm(server.id)
# interface.suspend_vm(server.id)
# interface.wake_up_vm(server.id)
# interface.destroy_vm(server.id)
# ==============================================================================
# Network test
# ==============================================================================
# os = openstack.connect(cloud='openstack')
#
# router_manager = OpenstackRouterManager(os)
# network_manager = OpenstackNetworkManager(os)
# subnet_manager = OpenstackSubnetManager(os)
# port_manager = OpenstackPortManager(os)
# floating_ip_manager = OpenstackFloatingIPManager(os)
#
# '''
# Network setup steps:
# - Create inner network
# - Create subnet for inner network
# - Create router
# - Add public network to router as gateway
# - Add inner subnet to router as interface
# - Add interface (or port?) to vm
# - Get the port of the vm
# - Create floating ip to public network
# - Associate floating ip and vm port
# '''
#
# #router = router_manager.create()
# router = router_manager.get('3ee87bcd-b1b5-4e14-86a1-ce691bd3e5a2')
#
# print('Router:')
# print('\t%s' % router)
#
# #network = network_manager.create()
# public_network = network_manager.get('3b349c93-8b2c-4abd-b8ce-22b7db4cca98')
# inner_network = network_manager.get('8df0d7ab-7d56-4496-aca0-317af66b3ebc')
#
# print('Network:')
# print('\tPublic: %s' % public_network)
# print('\tInner: %s' % inner_network)
#
# #subnet = subnet_manager.create(network.id, 4, '10.34.0.0/16')
# public_subnet = subnet_manager.get('8a7e05f8-6358-48f7-9104-990d350425a0')
# # create(inner_network.id, 4, '10.0.0.0/24')
# inner_subnet = subnet_manager.get('34911571-c929-4433-b4e6-305fcb585a91')
#
# print('Subnet:')
# print('\tPublic: %s' % public_subnet)
# print('\tInner: %s' % inner_subnet)
#
# vm_port = port_manager.get('85202d6d-7aa0-44bc-a5eb-78b0519066c5') # inner
#
# print('Port:')
# print('\tVM: %s' % vm_port)
#
# #floating_ip = floating_ip_manager.create(public_network.id)
# floating_ip = floating_ip_manager.get('fe1e329f-aedb-4b3e-a649-9fec8eb3ece5')
#
# print('Floating IP:')
# print('\tFloating IP: %s' % floating_ip)
#
#
# print(router_manager.add_interface(router.id, inner_subnet.id)) # TODO: fix error msg
# print(router_manager.add_gateway(router.id, public_network.id)) # TODO: fix it!
#
# print(floating_ip_manager.update(floating_ip.id, {
# 'port_id': vm_port.id
# }))
recircle/instance/views.py
View file @
ac9a0cb8
from
instance.serializers
import
InstanceSerializer
,
FlavorSerializer
,
LeaseSerializer
from
django.http
import
Http404
from
django.conf
import
settings
from
rest_framework.viewsets
import
ViewSet
,
ModelViewSet
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
rest_framework.decorators
import
action
from
template.serializers
import
InstanceFromTemplateSerializer
from
interface_openstack.implementation.vm.instance
import
(
OSVirtualMachineManager
)
from
instance.models
import
Instance
,
Flavor
,
Lease
from
instance.serializers
import
InstanceSerializer
,
FlavorSerializer
from
template.models
import
ImageTemplate
from
template.serializers
import
ImageTemplateModelSerializer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment