3 # Copyright 2016 RIFT.IO Inc
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 @author Varun Prasad(varun.prasad@riftio.com)
26 gi
.require_version('RwcalYang', '1.0')
27 gi
.require_version('RwCal', '1.0')
28 gi
.require_version('RwLog', '1.0')
30 from gi
.repository
import RwcalYang
32 import rift
.cal
.utils
as cal_utils
35 class CloudsimClient(cal_utils
.CloudSimCalMixin
):
36 """Cloudsim client that handles interactions with the server.
38 def __init__(self
, log
):
44 _
, images
= self
.cal
.get_image_list(self
.account
)
45 return images
.imageinfo_list
or []
49 _
, vlinks
= self
.cal
.get_virtual_link_list(self
.account
)
50 return vlinks
.virtual_link_info_list
or []
54 _
, vdus
= self
.cal
.get_vdu_list(self
.account
)
55 return vdus
.vdu_info_list
or []
57 def upload_image(self
, location
, name
=None):
58 """Onboard image to cloudsim server."""
60 image
= RwcalYang
.ImageInfoItem()
61 image
.name
= name
or os
.path
.basename(location
)
62 image
.location
= location
63 image
.disk_format
= "qcow2"
64 rc
, image
.id = self
.cal
.create_image(self
.account
, image
)
66 self
.log
.info("Image created: {}".format(image
.as_dict()))